Merge pull request #8045 from adnelson/numpy_scipy_osx

Test suites and working OSX builds for numpy and scipy

+74 -17
+21 -17
pkgs/top-level/python-packages.nix
··· 7800 7800 }; 7801 7801 }; 7802 7802 7803 - numpy = buildPythonPackage ( rec { 7803 + numpy = let 7804 + support = import ./python-support/numpy-scipy-support.nix { 7805 + inherit python; 7806 + atlas = pkgs.atlasWithLapack; 7807 + pkgName = "numpy"; 7808 + }; 7809 + in buildPythonPackage ( rec { 7804 7810 name = "numpy-1.9.2"; 7805 7811 7806 7812 src = pkgs.fetchurl { ··· 7815 7821 sed -i '0,/from numpy.distutils.core/s//import setuptools;from numpy.distutils.core/' setup.py 7816 7822 ''; 7817 7823 7818 - preBuild = '' 7819 - export BLAS=${pkgs.openblas} LAPACK=${pkgs.openblas} 7820 - ''; 7824 + inherit (support) preBuild checkPhase; 7821 7825 7822 7826 setupPyBuildFlags = ["--fcompiler='gnu95'"]; 7823 7827 7824 - # error: invalid command 'test' 7825 - doCheck = false; 7826 - 7827 - buildInputs = with self; [ pkgs.gfortran ]; 7828 - propagatedBuildInputs = with self; [ pkgs.openblas ]; 7828 + buildInputs = [ pkgs.gfortran self.nose ]; 7829 + propagatedBuildInputs = [ pkgs.atlas ]; 7829 7830 7830 7831 meta = { 7831 7832 description = "Scientific tools for Python"; ··· 11203 11204 }; 11204 11205 11205 11206 11206 - scipy = buildPythonPackage rec { 11207 + scipy = let 11208 + support = import ./python-support/numpy-scipy-support.nix { 11209 + inherit python; 11210 + atlas = pkgs.atlasWithLapack; 11211 + pkgName = "numpy"; 11212 + }; 11213 + in buildPythonPackage rec { 11207 11214 name = "scipy-0.15.1"; 11208 11215 11209 11216 src = pkgs.fetchurl { ··· 11211 11218 sha256 = "16i5iksaas3m0hgbxrxpgsyri4a9ncbwbiazlhx5d6lynz1wn4m2"; 11212 11219 }; 11213 11220 11214 - buildInputs = [ pkgs.gfortran ]; 11215 - propagatedBuildInputs = with self; [ numpy ]; 11221 + buildInputs = [ pkgs.gfortran self.nose ]; 11222 + propagatedBuildInputs = [ self.numpy ]; 11216 11223 11217 - # TODO: add ATLAS=${pkgs.atlas} 11218 11224 preConfigure = '' 11219 - export BLAS=${pkgs.blas} LAPACK=${pkgs.liblapack} 11220 11225 sed -i '0,/from numpy.distutils.core/s//import setuptools;from numpy.distutils.core/' setup.py 11221 11226 ''; 11222 11227 11223 - setupPyBuildFlags = [ "--fcompiler='gnu95'" ]; 11228 + inherit (support) preBuild checkPhase; 11224 11229 11225 - # error: invalid command 'test' 11226 - doCheck = false; 11230 + setupPyBuildFlags = [ "--fcompiler='gnu95'" ]; 11227 11231 11228 11232 meta = { 11229 11233 description = "SciPy (pronounced 'Sigh Pie') is open-source software for mathematics, science, and engineering. ";
+53
pkgs/top-level/python-support/numpy-scipy-support.nix
··· 1 + { 2 + # Python package expression 3 + python, 4 + # Name of package (e.g. numpy or scipy) 5 + pkgName, 6 + # Atlas math library 7 + atlas 8 + }: 9 + 10 + { 11 + 12 + # First "install" the package, then import what was installed, and call the 13 + # .test() function, which will run the test suite. 14 + checkPhase = '' 15 + runHook preCheck 16 + 17 + _python=${python}/bin/${python.executable} 18 + 19 + # We will "install" into a temp directory, so that we can run the 20 + # tests (see below). 21 + install_dir="$TMPDIR/test_install" 22 + install_lib="$install_dir/lib/${python.libPrefix}/site-packages" 23 + mkdir -p $install_dir 24 + $_python setup.py install \ 25 + --install-lib=$install_lib \ 26 + --old-and-unmanageable \ 27 + --prefix=$install_dir > /dev/null 28 + 29 + # Create a directory in which to run tests (you get an error if you try to 30 + # import the package when you're in the current directory). 31 + mkdir $TMPDIR/run_tests 32 + pushd $TMPDIR/run_tests > /dev/null 33 + # Temporarily add the directory we installed in to the python path 34 + # (not permanently, or this pythonpath will wind up getting exported), 35 + # and run the test suite. 36 + PYTHONPATH="$install_lib:$PYTHONPATH" $_python -c \ 37 + 'import ${pkgName}; ${pkgName}.test("fast", verbose=10)' 38 + popd > /dev/null 39 + 40 + runHook postCheck 41 + ''; 42 + 43 + # Creates a site.cfg telling the setup script where to find depended-on 44 + # math libraries. 45 + preBuild = '' 46 + echo "Creating site.cfg file..." 47 + cat << EOF > site.cfg 48 + [atlas] 49 + include_dirs = ${atlas}/include 50 + library_dirs = ${atlas}/lib 51 + EOF 52 + ''; 53 + }