1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 PYTHON_COMPAT=( python3_{6,7,8} )
7 PYTHON_REQ_USE="threads(+)"
11 inherit distutils-r1 flag-o-matic fortran-2 multiprocessing toolchain-funcs
14 DESCRIPTION="Fast array and numerical python library"
15 HOMEPAGE="https://www.numpy.org"
17 mirror://pypi/${PN:0:1}/${PN}/${P}.zip
19 https://numpy.org/doc/$(ver_cut 1-2 ${DOC_PV})/numpy-html.zip -> numpy-html-${DOC_PV}.zip
20 https://numpy.org/doc/$(ver_cut 1-2 ${DOC_PV})/numpy-ref.pdf -> numpy-ref-${DOC_PV}.pdf
21 https://numpy.org/doc/$(ver_cut 1-2 ${DOC_PV})/numpy-user.pdf -> numpy-user-${DOC_PV}.pdf
25 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~x64-solaris ~x86-solaris"
26 IUSE="doc lapack test"
27 RESTRICT="!test? ( test )"
35 BDEPEND="app-arch/unzip
36 dev-python/setuptools[${PYTHON_USEDEP}]
37 lapack? ( virtual/pkgconfig )
39 dev-python/pytest[${PYTHON_USEDEP}]
43 "${FILESDIR}"/${PN}-1.17.4-no-hardcode-blas.patch
49 unzip -qo "${DISTDIR}"/numpy-html-${DOC_PV}.zip -d html || die
54 $(tc-getPKG_CONFIG) --cflags-only-I $@ | \
55 sed -e 's/^-I//' -e 's/[ ]*-I/:/g' -e 's/[ ]*$//' -e 's|^:||'
59 $(tc-getPKG_CONFIG) --libs-only-L $@ | \
60 sed -e 's/^-L//' -e 's/[ ]*-L/:/g' -e 's/[ ]*$//' -e 's|^:||'
64 $(tc-getPKG_CONFIG) --libs-only-l $@ | \
65 sed -e 's/[ ]-l*\(pthread\|m\)\([ ]\|$\)//g' \
66 -e 's/^-l//' -e 's/[ ]*-l/,/g' -e 's/[ ]*$//' \
67 | tr ',' '\n' | sort -u | tr '\n' ',' | sed -e 's|,$||'
70 python_prepare_all() {
72 append-ldflags "$($(tc-getPKG_CONFIG) --libs-only-other cblas lapack)"
73 local incdir="${EPREFIX}"/usr/include
74 local libdir="${EPREFIX}"/usr/$(get_libdir)
75 cat >> site.cfg <<-EOF || die
77 include_dirs = $(pc_incdir cblas):${incdir}
78 library_dirs = $(pc_libdir cblas blas):${libdir}
79 blas_libs = $(pc_libs cblas blas)
81 library_dirs = $(pc_libdir lapack):${libdir}
82 lapack_libs = $(pc_libs lapack)
85 export {ATLAS,PTATLAS,BLAS,LAPACK,MKL}=None
88 export CC="$(tc-getCC) ${CFLAGS}"
90 append-flags -fno-strict-aliasing
92 # See progress in http://projects.scipy.org/scipy/numpy/ticket/573
93 # with the subtle difference that we don't want to break Darwin where
94 # -shared is not a valid linker argument
95 if [[ ${CHOST} != *-darwin* ]]; then
96 append-ldflags -shared
99 # only one fortran to link with:
100 # linking with cblas and lapack library will force
101 # autodetecting and linking to all available fortran compilers
104 NUMPY_FCONFIG="config_fc --noopt --noarch"
105 # workaround bug 335908
106 [[ $(tc-getFC) == *gfortran* ]] && NUMPY_FCONFIG+=" --fcompiler=gnu95"
109 # don't version f2py, we will handle it.
110 sed -i -e '/f2py_exe/s: + os\.path.*$::' numpy/f2py/setup.py || die
112 # disable fuzzed tests
113 find numpy/*/tests -name '*.py' -exec sed -i \
114 -e 's:def \(.*_fuzz\):def _\1:' {} + || die
115 # very memory- and disk-hungry
116 sed -i -e 's:test_large_zip:_&:' numpy/lib/tests/test_io.py || die
118 distutils-r1_python_prepare_all
122 export MAKEOPTS=-j1 #660754
124 local python_makeopts_jobs=""
125 python_is_python3 || python_makeopts_jobs="-j $(makeopts_jobs)"
126 distutils-r1_python_compile \
127 ${python_makeopts_jobs} \
132 distutils_install_for_testing --single-version-externally-managed \
133 --record "${TMPDIR}/record.txt" ${NUMPY_FCONFIG}
135 cd "${TMPDIR}" || die
139 r = numpy.test(label='full', verbose=3)
140 sys.exit(0 if r else 1)" || die "Tests fail with ${EPYTHON}"
144 distutils-r1_python_install ${NUMPY_FCONFIG}
148 python_install_all() {
149 local DOCS=( THANKS.txt )
152 local HTML_DOCS=( "${WORKDIR}"/html/. )
153 DOCS+=( "${DISTDIR}"/${PN}-{user,ref}-${DOC_PV}.pdf )
156 distutils-r1_python_install_all