app-editors/kakoune: drop old 0_pre20160620
[gentoo.git] / sci-libs / scipy / scipy-9999.ebuild
1 # Copyright 1999-2017 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 PYTHON_COMPAT=( python2_7 python3_{4,5,6} )
7 PYTHON_REQ_USE="threads(+)"
8
9 DOC_PV=${PV}
10
11 inherit fortran-2 distutils-r1 flag-o-matic git-r3 multiprocessing toolchain-funcs
12
13 DESCRIPTION="Scientific algorithms library for Python"
14 HOMEPAGE="https://www.scipy.org/"
15 EGIT_REPO_URI="https://github.com/scipy/scipy.git"
16
17 LICENSE="BSD LGPL-2"
18 SLOT="0"
19 KEYWORDS=""
20 IUSE="sparse test"
21
22 CDEPEND="
23         >=dev-python/numpy-1.10[lapack,${PYTHON_USEDEP}]
24         sci-libs/arpack:0=
25         virtual/cblas
26         virtual/lapack
27         sparse? ( sci-libs/umfpack:0= )"
28 DEPEND="${CDEPEND}
29         dev-lang/swig
30         >=dev-python/cython-0.23.4[${PYTHON_USEDEP}]
31         virtual/pkgconfig
32         test? ( dev-python/nose[${PYTHON_USEDEP}] )
33         "
34
35 RDEPEND="${CDEPEND}
36         dev-python/pillow[${PYTHON_USEDEP}]"
37
38 DOCS=( HACKING.rst.txt THANKS.txt )
39
40 DISTUTILS_IN_SOURCE_BUILD=1
41
42 pc_incdir() {
43         $(tc-getPKG_CONFIG) --cflags-only-I $@ | \
44                 sed -e 's/^-I//' -e 's/[ ]*-I/:/g' -e 's/[ ]*$//' -e 's|^:||'
45 }
46
47 pc_libdir() {
48         $(tc-getPKG_CONFIG) --libs-only-L $@ | \
49                 sed -e 's/^-L//' -e 's/[ ]*-L/:/g' -e 's/[ ]*$//' -e 's|^:||'
50 }
51
52 pc_libs() {
53         $(tc-getPKG_CONFIG) --libs-only-l $@ | \
54                 sed -e 's/[ ]-l*\(pthread\|m\)\([ ]\|$\)//g' \
55                 -e 's/^-l//' -e 's/[ ]*-l/,/g' -e 's/[ ]*$//' \
56                 | tr ',' '\n' | sort -u | tr '\n' ',' | sed -e 's|,$||'
57 }
58
59 python_prepare_all() {
60         # scipy automatically detects libraries by default
61         export {FFTW,FFTW3,UMFPACK}=None
62         use sparse && unset UMFPACK
63         # the missing symbols are in -lpythonX.Y, but since the version can
64         # differ, we just introduce the same scaryness as on Linux/ELF
65         [[ ${CHOST} == *-darwin* ]] \
66                 && append-ldflags -bundle "-undefined dynamic_lookup" \
67                 || append-ldflags -shared
68         [[ -z ${FC}  ]] && export FC="$(tc-getFC)"
69         # hack to force F77 to be FC until bug #278772 is fixed
70         [[ -z ${F77} ]] && export F77="$(tc-getFC)"
71         export F90="${FC}"
72         export SCIPY_FCONFIG="config_fc --noopt --noarch"
73         append-fflags -fPIC
74
75         local libdir="${EPREFIX}"/usr/$(get_libdir)
76         cat >> site.cfg <<-EOF || die
77                 [blas]
78                 include_dirs = $(pc_incdir cblas)
79                 library_dirs = $(pc_libdir cblas blas):${libdir}
80                 blas_libs = $(pc_libs cblas blas)
81                 [lapack]
82                 library_dirs = $(pc_libdir lapack):${libdir}
83                 lapack_libs = $(pc_libs lapack)
84         EOF
85
86         # Drop hashes to force rebuild of cython based .c code
87         rm cythonize.dat || die
88
89         distutils-r1_python_prepare_all
90 }
91
92 python_compile() {
93         ${EPYTHON} tools/cythonize.py || die
94         distutils-r1_python_compile \
95                 $(usex python_targets_python3_5 "" "-j $(makeopts_jobs)") \
96                 ${SCIPY_FCONFIG}
97 }
98
99 python_test() {
100         # fails with bdist_egg. should it be fixed in distutils-r1 eclass?
101         distutils_install_for_testing ${SCIPY_FCONFIG}
102         cd "${TEST_DIR}" || die "no ${TEST_DIR} available"
103         einfo "Run test I"
104         "${PYTHON}" -c \
105                 'import numpy as np; print("relaxed strides checking:", np.ones((10,1),order="C").flags.f_contiguous)' \
106                 || die
107         einfo "Run test II"
108         # https://github.com/scipy/scipy/issues/5426
109         "${EPYTHON}" -c \
110                 "import scipy, sys; r = scipy.test('fast', verbose=2, raise_warnings='release'); sys.exit(0 if r.wasSuccessful() else 1)" \
111                 || die "Tests fail with ${EPYTHON}"
112 #       "${EPYTHON}" -c \
113 #               "import scipy, sys; r = scipy.test('fast',verbose=2); sys.exit(0 if r.wasSuccessful() else 1)" \
114 #               || die "Tests fail with ${EPYTHON}"
115 }
116
117 python_install() {
118         distutils-r1_python_install ${SCIPY_FCONFIG}
119 }
120
121 pkg_postinst() {
122         elog "You might want to set the variable SCIPY_PIL_IMAGE_VIEWER"
123         elog "to your prefered image viewer. Example:"
124         elog "\t echo \"export SCIPY_PIL_IMAGE_VIEWER=display\" >> ~/.bashrc"
125 }