Lines 19-25
Link Here
|
19 |
DEPEND="${RDEPEND} |
19 |
DEPEND="${RDEPEND} |
20 |
lapack? ( app-admin/eselect-cblas )" |
20 |
lapack? ( app-admin/eselect-cblas )" |
21 |
|
21 |
|
22 |
IUSE="lapack" |
22 |
IUSE="lapack fortran" |
23 |
SLOT="0" |
23 |
SLOT="0" |
24 |
KEYWORDS="~alpha amd64 hppa ia64 ppc ppc64 sparc x86" |
24 |
KEYWORDS="~alpha amd64 hppa ia64 ppc ppc64 sparc x86" |
25 |
LICENSE="BSD" |
25 |
LICENSE="BSD" |
Lines 28-49
Link Here
|
28 |
|
28 |
|
29 |
FORTRAN="gfortran g77" |
29 |
FORTRAN="gfortran g77" |
30 |
|
30 |
|
31 |
numpy_configure() { |
31 |
lapack_configure() { |
32 |
local mycblas |
32 |
local mycblas |
33 |
if use lapack; then |
33 |
for d in $(eselect cblas show); do mycblas=${d}; done |
34 |
for d in $(eselect cblas show); do mycblas=${d}; done |
34 |
if [[ -z "${mycblas/reference/}" ]] && [[ -z "${mycblas/atlas/}" ]]; then |
35 |
if [[ -z "${mycblas/reference/}" ]] && [[ -z "${mycblas/atlas/}" ]]; then |
35 |
ewarn "You need to set cblas to atlas or reference. Do:" |
36 |
ewarn "You need to set cblas to atlas or reference. Do:" |
36 |
ewarn " eselect cblas set <impl>" |
37 |
ewarn " eselect cblas set <impl>" |
37 |
ewarn "where <impl> is atlas, threaded-atlas or reference" |
38 |
ewarn "where <impl> is atlas, threaded-atlas or reference" |
38 |
die "setup failed" |
39 |
die "setup failed" |
|
|
40 |
fi |
41 |
fi |
39 |
fi |
42 |
[[ -z "${F77FLAGS}" ]] && F77FLAGS="${CFLAGS}" |
|
|
43 |
[[ -z "${FFLAGS}" ]] && FFLAGS="${F77FLAGS}" |
44 |
|
45 |
# remove default values |
46 |
echo "# gentoo config" > site.cfg |
47 |
|
40 |
|
48 |
export BLAS=None |
41 |
export BLAS=None |
49 |
export LAPACK=None |
42 |
export LAPACK=None |
Lines 51-79
Link Here
|
51 |
export PTATLAS=None |
44 |
export PTATLAS=None |
52 |
export MKL=None |
45 |
export MKL=None |
53 |
|
46 |
|
54 |
if use lapack; then |
47 |
# Remove default values |
55 |
echo "[blas_opt]" >> site.cfg |
48 |
echo "# gentoo config" > site.cfg |
56 |
case "${mycblas}" in |
49 |
echo "[blas_opt]" >> site.cfg |
57 |
reference) |
50 |
case "${mycblas}" in |
58 |
echo "include_dirs = /usr/include/cblas" >> site.cfg |
51 |
reference) |
59 |
echo "libraries = blas, cblas" >> site.cfg |
52 |
echo "include_dirs = /usr/include/cblas" >> site.cfg |
60 |
unset BLAS |
53 |
echo "libraries = blas, cblas" >> site.cfg |
61 |
;; |
54 |
unset BLAS |
62 |
atlas|threaded-atlas) |
55 |
;; |
63 |
echo "include_dirs = /usr/include/atlas" >> site.cfg |
56 |
atlas|threaded-atlas) |
64 |
echo "libraries = blas, cblas, atlas" >> site.cfg |
57 |
echo "include_dirs = /usr/include/atlas" >> site.cfg |
65 |
unset ATLAS |
58 |
echo "libraries = blas, cblas, atlas" >> site.cfg |
66 |
;; |
59 |
unset ATLAS |
67 |
*) |
60 |
;; |
68 |
local msg="Invalid cblas implementation: ${cblas}" |
61 |
*) |
69 |
eerror "${msg}" |
62 |
local msg="Invalid cblas implementation: ${cblas}" |
70 |
die "${msg}" |
63 |
eerror "${msg}" |
71 |
;; |
64 |
die "${msg}" |
72 |
esac |
65 |
;; |
73 |
echo "[lapack_opt]" >> site.cfg |
66 |
esac |
74 |
echo "libraries = lapack" >> site.cfg |
67 |
echo "[lapack_opt]" >> site.cfg |
75 |
unset LAPACK |
68 |
echo "libraries = lapack" >> site.cfg |
76 |
fi |
69 |
unset LAPACK |
|
|
70 |
} |
71 |
|
72 |
require_fortran() { |
73 |
# That was called at "inherit fortran" time, but this is now |
74 |
# not done any more, look at pkg_setup() below |
75 |
need_fortran "${FORTRAN}" |
76 |
} |
77 |
|
78 |
fortran_configure() { |
79 |
[[ -z "${F77FLAGS}" ]] && F77FLAGS="${CFLAGS}" |
80 |
[[ -z "${FFLAGS}" ]] && FFLAGS="${F77FLAGS}" |
81 |
|
82 |
require_fortran |
83 |
|
77 |
# Map compilers to what numpy calls them (same as scipy) |
84 |
# Map compilers to what numpy calls them (same as scipy) |
78 |
case "${FORTRANC}" in |
85 |
case "${FORTRANC}" in |
79 |
gfortran) |
86 |
gfortran) |
Lines 95-118
Link Here
|
95 |
fi |
102 |
fi |
96 |
;; |
103 |
;; |
97 |
*) |
104 |
*) |
98 |
local msg="Invalid Fortran compiler \'${FORTRANC}\'" |
105 |
if [[ -z "${FORTRANC}" ]]; then |
99 |
eerror "${msg}" |
106 |
die "No Fortran compiler" |
100 |
die "${msg}" |
107 |
else |
|
|
108 |
die "Invalid Fortran compiler: \"${FORTRANC}\"" |
109 |
fi |
101 |
;; |
110 |
;; |
102 |
esac |
111 |
esac |
103 |
export NUMPY_FC |
112 |
export NUMPY_FC |
104 |
# http://projects.scipy.org/scipy/numpy/ticket/182 |
113 |
} |
105 |
# Can't set LDFLAGS |
114 |
|
|
|
115 |
linker_configure() { |
116 |
if [[ -n "${LDFLAGS}" && -z "${NUMPY_LDFLAG_WARNED}" ]]; then |
117 |
ewarn "Ignoring LDFLAGS=${LDFLAGS}, look at:" |
118 |
ewarn "http://projects.scipy.org/scipy/numpy/ticket/182" |
119 |
# Kludge for warn-once despite numpy_configure() being called repeatedly |
120 |
# See comment before the distutils_src_install |
121 |
NUMPY_LDFLAG_WARNED="TRUE" |
122 |
fi |
106 |
unset LDFLAGS |
123 |
unset LDFLAGS |
107 |
} |
124 |
} |
108 |
|
125 |
|
109 |
src_unpack() { |
126 |
numpy_configure() { |
110 |
fortran_src_unpack |
127 |
use lapack && lapack_configure |
111 |
cd "${S}" |
128 |
use fortran && fortran_configure |
112 |
# fix some paths and docs in f2py |
129 |
linker_configure |
113 |
epatch "${FILESDIR}"/${PN}-1.0.1-f2py.patch |
130 |
} |
114 |
|
131 |
|
115 |
# gentoo patch for ATLAS library names |
132 |
# Gentoo patch for ATLAS library names |
|
|
133 |
patch_atlas() { |
116 |
sed -i \ |
134 |
sed -i \ |
117 |
-e "s:'f77blas':'blas':g" \ |
135 |
-e "s:'f77blas':'blas':g" \ |
118 |
-e "s:'ptblas':'blas':g" \ |
136 |
-e "s:'ptblas':'blas':g" \ |
Lines 122-166
Link Here
|
122 |
|| die "sed system_info.py failed" |
140 |
|| die "sed system_info.py failed" |
123 |
} |
141 |
} |
124 |
|
142 |
|
|
|
143 |
src_unpack() { |
144 |
unpack ${A} |
145 |
cd ${S} |
146 |
|
147 |
if use fortran; then |
148 |
require_fortran |
149 |
|
150 |
# Apply fortran compiler patches |
151 |
patch_fortran |
152 |
|
153 |
# Fix some paths and docs in f2py |
154 |
epatch "${FILESDIR}"/${PN}-1.0.1-f2py.patch |
155 |
fi |
156 |
patch_atlas |
157 |
} |
158 |
|
159 |
# Do not configure numpy with a fortran compiler |
160 |
if use fortran; then |
161 |
NUMPY_FORTRAN_CONFIG="config_fc --fcompiler=${NUMPY_FC} --opt=\"${FFLAGS}\"" |
162 |
fi |
163 |
|
125 |
src_compile() { |
164 |
src_compile() { |
|
|
165 |
# See comment before the distutils_src_install |
126 |
numpy_configure |
166 |
numpy_configure |
127 |
distutils_src_compile \ |
167 |
distutils_src_compile ${NUMPY_FORTRAN_CONFIG} |
128 |
config_fc \ |
|
|
129 |
--fcompiler=${NUMPY_FC} \ |
130 |
--opt="${FFLAGS}" |
131 |
} |
168 |
} |
132 |
|
169 |
|
133 |
src_test() { |
170 |
src_test() { |
134 |
# see comment before the distutils_src_install |
171 |
# See comment before the distutils_src_install |
135 |
numpy_configure |
172 |
numpy_configure |
136 |
${python} setup.py install \ |
173 |
${python} setup.py install \ |
137 |
--home="${S}"/test \ |
174 |
--home="${S}"/test \ |
138 |
--no-compile \ |
175 |
--no-compile \ |
139 |
config_fc \ |
176 |
${NUMPY_FORTRAN_CONFIG} || die "install test failed" |
140 |
--fcompiler=${NUMPY_FC} \ |
|
|
141 |
--opt="${FFLAGS}" || die "install test failed" |
142 |
|
177 |
|
143 |
pushd "${S}"/test/lib*/python |
178 |
pushd "${S}"/test/lib*/python |
144 |
PYTHONPATH=. "${python}" -c "import numpy; numpy.test(10,3)" 2>&1 \ |
179 |
PYTHONPATH=. "${python}" -c "import numpy; numpy.test(10,3)" 2>&1 \ |
145 |
| tee test.log |
180 |
| tee test.log |
146 |
grep -q OK test.log || die "test failed" |
181 |
grep -q '^OK$' test.log || die "test failed" |
147 |
popd |
182 |
popd |
148 |
|
183 |
|
149 |
rm -rf test |
184 |
rm -rf test |
150 |
} |
185 |
} |
151 |
|
186 |
|
|
|
187 |
# Horrible kludge to avoid fortran.eclass::fortran_pkg_setup() |
188 |
# to be called by the global "inherit fortran" |
189 |
# Suggested in: https://bugs.gentoo.org/show_bug.cgi?id=186913 |
190 |
pkg_setup() { |
191 |
true |
192 |
} |
193 |
|
152 |
src_install() { |
194 |
src_install() { |
153 |
# we need to do the configuring again, for some reason, the |
195 |
# We need to do the configuring again, for some reason, the |
154 |
# variables are not kept within setup.py functions |
196 |
# variables are not kept within setup.py functions |
155 |
numpy_configure |
197 |
numpy_configure |
156 |
distutils_src_install \ |
198 |
distutils_src_install ${NUMPY_FORTRAN_CONFIG} |
157 |
config_fc \ |
|
|
158 |
--fcompiler=${NUMPY_FC} \ |
159 |
--opt="${FFLAGS}" |
160 |
|
199 |
|
161 |
docinto numpy |
200 |
docinto numpy |
162 |
dodoc numpy/doc/*txt |
201 |
dodoc numpy/doc/*txt |
163 |
docinto f2py |
202 |
|
164 |
dodoc numpy/f2py/docs/*txt |
203 |
if use fortran; then |
165 |
doman numpy/f2py/f2py.1 |
204 |
docinto f2py |
|
|
205 |
dodoc numpy/f2py/docs/*txt |
206 |
doman numpy/f2py/f2py.1 |
207 |
else |
208 |
ewarn "To use numpy's f2py you'll need \"USE=fortran emerge numpy\" and a previously installed fortran compiler (gfortran, g77)" |
209 |
fi |
166 |
} |
210 |
} |