--- numpy-1.0.3.ebuild 2007-07-29 12:30:46.000000000 +0200 +++ numpy-1.0.3.ebuild.clean 2007-07-29 16:19:13.000000000 +0200 @@ -19,7 +19,7 @@ DEPEND="${RDEPEND} lapack? ( app-admin/eselect-cblas )" -IUSE="lapack" +IUSE="lapack fortran" SLOT="0" KEYWORDS="~alpha amd64 hppa ia64 ppc ppc64 sparc x86" LICENSE="BSD" @@ -28,22 +28,15 @@ FORTRAN="gfortran g77" -numpy_configure() { +lapack_configure() { local mycblas - if use lapack; then - for d in $(eselect cblas show); do mycblas=${d}; done - if [[ -z "${mycblas/reference/}" ]] && [[ -z "${mycblas/atlas/}" ]]; then - ewarn "You need to set cblas to atlas or reference. Do:" - ewarn " eselect cblas set " - ewarn "where is atlas, threaded-atlas or reference" - die "setup failed" - fi + for d in $(eselect cblas show); do mycblas=${d}; done + if [[ -z "${mycblas/reference/}" ]] && [[ -z "${mycblas/atlas/}" ]]; then + ewarn "You need to set cblas to atlas or reference. Do:" + ewarn " eselect cblas set " + ewarn "where is atlas, threaded-atlas or reference" + die "setup failed" fi - [[ -z "${F77FLAGS}" ]] && F77FLAGS="${CFLAGS}" - [[ -z "${FFLAGS}" ]] && FFLAGS="${F77FLAGS}" - - # remove default values - echo "# gentoo config" > site.cfg export BLAS=None export LAPACK=None @@ -51,29 +44,43 @@ export PTATLAS=None export MKL=None - if use lapack; then - echo "[blas_opt]" >> site.cfg - case "${mycblas}" in - reference) - echo "include_dirs = /usr/include/cblas" >> site.cfg - echo "libraries = blas, cblas" >> site.cfg - unset BLAS - ;; - atlas|threaded-atlas) - echo "include_dirs = /usr/include/atlas" >> site.cfg - echo "libraries = blas, cblas, atlas" >> site.cfg - unset ATLAS - ;; - *) - local msg="Invalid cblas implementation: ${cblas}" - eerror "${msg}" - die "${msg}" - ;; - esac - echo "[lapack_opt]" >> site.cfg - echo "libraries = lapack" >> site.cfg - unset LAPACK - fi + # Remove default values + echo "# gentoo config" > site.cfg + echo "[blas_opt]" >> site.cfg + case "${mycblas}" in + reference) + echo "include_dirs = /usr/include/cblas" >> site.cfg + echo "libraries = blas, cblas" >> site.cfg + unset BLAS + ;; + atlas|threaded-atlas) + echo "include_dirs = /usr/include/atlas" >> site.cfg + echo "libraries = blas, cblas, atlas" >> site.cfg + unset ATLAS + ;; + *) + local msg="Invalid cblas implementation: ${cblas}" + eerror "${msg}" + die "${msg}" + ;; + esac + echo "[lapack_opt]" >> site.cfg + echo "libraries = lapack" >> site.cfg + unset LAPACK +} + +require_fortran() { + # That was called at "inherit fortran" time, but this is now + # not done any more, look at pkg_setup() below + need_fortran "${FORTRAN}" +} + +fortran_configure() { + [[ -z "${F77FLAGS}" ]] && F77FLAGS="${CFLAGS}" + [[ -z "${FFLAGS}" ]] && FFLAGS="${F77FLAGS}" + + require_fortran + # Map compilers to what numpy calls them (same as scipy) case "${FORTRANC}" in gfortran) @@ -95,24 +102,35 @@ fi ;; *) - local msg="Invalid Fortran compiler \'${FORTRANC}\'" - eerror "${msg}" - die "${msg}" + if [[ -z "${FORTRANC}" ]]; then + die "No Fortran compiler" + else + die "Invalid Fortran compiler: \"${FORTRANC}\"" + fi ;; esac export NUMPY_FC - # http://projects.scipy.org/scipy/numpy/ticket/182 - # Can't set LDFLAGS +} + +linker_configure() { + if [[ -n "${LDFLAGS}" && -z "${NUMPY_LDFLAG_WARNED}" ]]; then + ewarn "Ignoring LDFLAGS=${LDFLAGS}, look at:" + ewarn "http://projects.scipy.org/scipy/numpy/ticket/182" + # Kludge for warn-once despite numpy_configure() being called repeatedly + # See comment before the distutils_src_install + NUMPY_LDFLAG_WARNED="TRUE" + fi unset LDFLAGS } -src_unpack() { - fortran_src_unpack - cd "${S}" - # fix some paths and docs in f2py - epatch "${FILESDIR}"/${PN}-1.0.1-f2py.patch +numpy_configure() { + use lapack && lapack_configure + use fortran && fortran_configure + linker_configure +} - # gentoo patch for ATLAS library names +# Gentoo patch for ATLAS library names +patch_atlas() { sed -i \ -e "s:'f77blas':'blas':g" \ -e "s:'ptblas':'blas':g" \ @@ -122,45 +140,71 @@ || die "sed system_info.py failed" } +src_unpack() { + unpack ${A} + cd ${S} + + if use fortran; then + require_fortran + + # Apply fortran compiler patches + patch_fortran + + # Fix some paths and docs in f2py + epatch "${FILESDIR}"/${PN}-1.0.1-f2py.patch + fi + patch_atlas +} + +# Do not configure numpy with a fortran compiler +if use fortran; then + NUMPY_FORTRAN_CONFIG="config_fc --fcompiler=${NUMPY_FC} --opt=\"${FFLAGS}\"" +fi + src_compile() { + # See comment before the distutils_src_install numpy_configure - distutils_src_compile \ - config_fc \ - --fcompiler=${NUMPY_FC} \ - --opt="${FFLAGS}" + distutils_src_compile ${NUMPY_FORTRAN_CONFIG} } src_test() { - # see comment before the distutils_src_install + # See comment before the distutils_src_install numpy_configure ${python} setup.py install \ --home="${S}"/test \ --no-compile \ - config_fc \ - --fcompiler=${NUMPY_FC} \ - --opt="${FFLAGS}" || die "install test failed" + ${NUMPY_FORTRAN_CONFIG} || die "install test failed" pushd "${S}"/test/lib*/python PYTHONPATH=. "${python}" -c "import numpy; numpy.test(10,3)" 2>&1 \ | tee test.log - grep -q OK test.log || die "test failed" + grep -q '^OK$' test.log || die "test failed" popd rm -rf test } +# Horrible kludge to avoid fortran.eclass::fortran_pkg_setup() +# to be called by the global "inherit fortran" +# Suggested in: https://bugs.gentoo.org/show_bug.cgi?id=186913 +pkg_setup() { + true +} + src_install() { - # we need to do the configuring again, for some reason, the + # We need to do the configuring again, for some reason, the # variables are not kept within setup.py functions numpy_configure - distutils_src_install \ - config_fc \ - --fcompiler=${NUMPY_FC} \ - --opt="${FFLAGS}" + distutils_src_install ${NUMPY_FORTRAN_CONFIG} docinto numpy dodoc numpy/doc/*txt - docinto f2py - dodoc numpy/f2py/docs/*txt - doman numpy/f2py/f2py.1 + + if use fortran; then + docinto f2py + dodoc numpy/f2py/docs/*txt + doman numpy/f2py/f2py.1 + else + ewarn "To use numpy's f2py you'll need \"USE=fortran emerge numpy\" and a previously installed fortran compiler (gfortran, g77)" + fi }