1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 PYTHON_COMPAT=( python2_7 python3_{6,7} )
7 PYTHON_REQ_USE="threads(+)"
11 inherit distutils-r1 flag-o-matic fortran-2 multiprocessing toolchain-funcs
14 DOC_P="${PN}-${DOC_PV}"
16 DESCRIPTION="Fast array and numerical python library"
17 HOMEPAGE="https://www.numpy.org"
19 mirror://pypi/${PN:0:1}/${PN}/${P}.zip
21 http://docs.scipy.org/doc/${DOC_P}/${PN}-html-${DOC_PV}.zip
22 http://docs.scipy.org/doc/${DOC_P}/${PN}-ref-${DOC_PV}.pdf
23 http://docs.scipy.org/doc/${DOC_P}/${PN}-user-${DOC_PV}.pdf
27 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"
28 IUSE="doc lapack test"
29 RESTRICT="!test? ( test )"
31 RDEPEND="lapack? ( virtual/cblas virtual/lapack )"
34 dev-python/setuptools[${PYTHON_USEDEP}]
35 lapack? ( virtual/pkgconfig )
37 dev-python/pytest[${PYTHON_USEDEP}]
41 "${FILESDIR}"/${PN}-1.15.4-no-hardcode-blas.patch
47 unzip -qo "${DISTDIR}"/${PN}-html-${DOC_PV}.zip -d html || die
52 $(tc-getPKG_CONFIG) --cflags-only-I $@ | \
53 sed -e 's/^-I//' -e 's/[ ]*-I/:/g' -e 's/[ ]*$//' -e 's|^:||'
57 $(tc-getPKG_CONFIG) --libs-only-L $@ | \
58 sed -e 's/^-L//' -e 's/[ ]*-L/:/g' -e 's/[ ]*$//' -e 's|^:||'
62 $(tc-getPKG_CONFIG) --libs-only-l $@ | \
63 sed -e 's/[ ]-l*\(pthread\|m\)\([ ]\|$\)//g' \
64 -e 's/^-l//' -e 's/[ ]*-l/,/g' -e 's/[ ]*$//' \
65 | tr ',' '\n' | sort -u | tr '\n' ',' | sed -e 's|,$||'
68 python_prepare_all() {
70 append-ldflags "$($(tc-getPKG_CONFIG) --libs-only-other cblas lapack)"
71 local incdir="${EPREFIX}"/usr/include
72 local libdir="${EPREFIX}"/usr/$(get_libdir)
73 cat >> site.cfg <<-EOF || die
75 include_dirs = $(pc_incdir cblas):${incdir}
76 library_dirs = $(pc_libdir cblas blas):${libdir}
77 blas_libs = $(pc_libs cblas blas)
79 library_dirs = $(pc_libdir lapack):${libdir}
80 lapack_libs = $(pc_libs lapack)
83 export {ATLAS,PTATLAS,BLAS,LAPACK,MKL}=None
86 export CC="$(tc-getCC) ${CFLAGS}"
88 append-flags -fno-strict-aliasing
90 # See progress in http://projects.scipy.org/scipy/numpy/ticket/573
91 # with the subtle difference that we don't want to break Darwin where
92 # -shared is not a valid linker argument
93 if [[ ${CHOST} != *-darwin* ]]; then
94 append-ldflags -shared
97 # only one fortran to link with:
98 # linking with cblas and lapack library will force
99 # autodetecting and linking to all available fortran compilers
102 NUMPY_FCONFIG="config_fc --noopt --noarch"
103 # workaround bug 335908
104 [[ $(tc-getFC) == *gfortran* ]] && NUMPY_FCONFIG+=" --fcompiler=gnu95"
107 # don't version f2py, we will handle it.
108 sed -i -e '/f2py_exe/s: + os\.path.*$::' numpy/f2py/setup.py || die
110 distutils-r1_python_prepare_all
114 export MAKEOPTS=-j1 #660754
116 local python_makeopts_jobs=""
117 python_is_python3 || python_makeopts_jobs="-j $(makeopts_jobs)"
118 distutils-r1_python_compile \
119 ${python_makeopts_jobs} \
124 distutils_install_for_testing --single-version-externally-managed --record "${TMPDIR}/record.txt" ${NUMPY_FCONFIG}
126 cd "${TMPDIR}" || die
130 r = numpy.test(label='full', verbose=3)
131 sys.exit(0 if r else 1)" || die "Tests fail with ${EPYTHON}"
135 distutils-r1_python_install ${NUMPY_FCONFIG}
138 python_install_all() {
139 local DOCS=( THANKS.txt )
142 local HTML_DOCS=( "${WORKDIR}"/html/. )
143 DOCS+=( "${DISTDIR}"/${PN}-{user,ref}-${DOC_PV}.pdf )
146 distutils-r1_python_install_all