From 3d00848ace5ae948f049aa8aa0651a3de22f7040 Mon Sep 17 00:00:00 2001 From: Allen Nelson Date: Thu, 28 May 2015 12:30:29 -0700 Subject: [PATCH 1/3] using atlasWithLapack dependency. running test suites for numpy and scipy. --- pkgs/top-level/python-packages.nix | 64 ++++++++++++++++++++++++------ 1 file changed, 52 insertions(+), 12 deletions(-) diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index b33448fa944..33a76d8f264 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -7802,6 +7802,49 @@ let }; }; + # Special check phase for numpy and scipy, following the same set of steps: + # First "install" the package, then import what was installed, and call the + # .test() function, which will run the test suite. + numpyScipyCheckPhase = python: pkgName: '' + runHook preCheck + + _python=${python}/bin/${python.executable} + + # We will "install" into a temp directory, so that we can run the numpy + # tests (see below). + install_dir="$TMPDIR/test_install" + install_lib="$install_dir/lib/${python.libPrefix}/site-packages" + mkdir -p $install_dir + $_python setup.py install \ + --install-lib=$install_lib \ + --old-and-unmanageable \ + --prefix=$install_dir > /dev/null + + # Create a directory in which to run tests (you get an error if you try to + # import the package when you're in the current directory). + mkdir $TMPDIR/run_tests + pushd $TMPDIR/run_tests > /dev/null + # Temporarily add the directory we installed in to the python path + # (not permanently, or this pythonpath will wind up getting exported), + # and run the test suite. + PYTHONPATH="$install_lib:$PYTHONPATH" $_python -c \ + 'import ${pkgName}; ${pkgName}.test("fast", verbose=10)' + popd > /dev/null + + runHook postCheck + ''; + + # Special prebuild step for numpy and scipy. Creates a site.cfg telling + # the setup script where to find depended-on math libraries. + numpyScipyPrebuild = '' + echo "Creating site.cfg file..." + cat << EOF > site.cfg + [atlas] + include_dirs = ${pkgs.atlasWithLapack}/include + library_dirs = ${pkgs.atlasWithLapack}/lib + EOF + ''; + numpy = buildPythonPackage ( rec { name = "numpy-1.9.2"; @@ -7817,17 +7860,14 @@ let sed -i '0,/from numpy.distutils.core/s//import setuptools;from numpy.distutils.core/' setup.py ''; - preBuild = '' - export BLAS=${pkgs.openblas} LAPACK=${pkgs.openblas} - ''; + preBuild = self.numpyScipyPrebuild; setupPyBuildFlags = ["--fcompiler='gnu95'"]; - # error: invalid command 'test' - doCheck = false; + buildInputs = [ pkgs.gfortran self.nose ]; + propagatedBuildInputs = [ pkgs.atlas ]; - buildInputs = with self; [ pkgs.gfortran ]; - propagatedBuildInputs = with self; [ pkgs.openblas ]; + checkPhase = self.numpyScipyCheckPhase python "numpy"; meta = { description = "Scientific tools for Python"; @@ -11187,19 +11227,19 @@ let sha256 = "16i5iksaas3m0hgbxrxpgsyri4a9ncbwbiazlhx5d6lynz1wn4m2"; }; - buildInputs = [ pkgs.gfortran ]; - propagatedBuildInputs = with self; [ numpy ]; + buildInputs = [ pkgs.gfortran self.nose ]; + propagatedBuildInputs = [ self.numpy ]; # TODO: add ATLAS=${pkgs.atlas} preConfigure = '' - export BLAS=${pkgs.blas} LAPACK=${pkgs.liblapack} sed -i '0,/from numpy.distutils.core/s//import setuptools;from numpy.distutils.core/' setup.py ''; + preBuild = self.numpyScipyPrebuild; + setupPyBuildFlags = [ "--fcompiler='gnu95'" ]; - # error: invalid command 'test' - doCheck = false; + checkPhase = self.numpyScipyCheckPhase python "scipy"; meta = { description = "SciPy (pronounced 'Sigh Pie') is open-source software for mathematics, science, and engineering. "; From 6c238d1d5f4da8b20ecaeb0cec32cbbbec5be5e5 Mon Sep 17 00:00:00 2001 From: Allen Nelson Date: Fri, 29 May 2015 11:03:18 -0500 Subject: [PATCH 2/3] moving non-packages into a separate file --- pkgs/top-level/python-packages.nix | 68 +++++-------------- .../python-support/numpy-scipy-support.nix | 53 +++++++++++++++ 2 files changed, 69 insertions(+), 52 deletions(-) create mode 100644 pkgs/top-level/python-support/numpy-scipy-support.nix diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 33a76d8f264..38636840b9b 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -7802,50 +7802,13 @@ let }; }; - # Special check phase for numpy and scipy, following the same set of steps: - # First "install" the package, then import what was installed, and call the - # .test() function, which will run the test suite. - numpyScipyCheckPhase = python: pkgName: '' - runHook preCheck - - _python=${python}/bin/${python.executable} - - # We will "install" into a temp directory, so that we can run the numpy - # tests (see below). - install_dir="$TMPDIR/test_install" - install_lib="$install_dir/lib/${python.libPrefix}/site-packages" - mkdir -p $install_dir - $_python setup.py install \ - --install-lib=$install_lib \ - --old-and-unmanageable \ - --prefix=$install_dir > /dev/null - - # Create a directory in which to run tests (you get an error if you try to - # import the package when you're in the current directory). - mkdir $TMPDIR/run_tests - pushd $TMPDIR/run_tests > /dev/null - # Temporarily add the directory we installed in to the python path - # (not permanently, or this pythonpath will wind up getting exported), - # and run the test suite. - PYTHONPATH="$install_lib:$PYTHONPATH" $_python -c \ - 'import ${pkgName}; ${pkgName}.test("fast", verbose=10)' - popd > /dev/null - - runHook postCheck - ''; - - # Special prebuild step for numpy and scipy. Creates a site.cfg telling - # the setup script where to find depended-on math libraries. - numpyScipyPrebuild = '' - echo "Creating site.cfg file..." - cat << EOF > site.cfg - [atlas] - include_dirs = ${pkgs.atlasWithLapack}/include - library_dirs = ${pkgs.atlasWithLapack}/lib - EOF - ''; - - numpy = buildPythonPackage ( rec { + numpy = let + support = import ./python-support/numpy-scipy-support.nix { + inherit python; + atlas = atlasWithLapack; + pkgName = "numpy"; + }; + in buildPythonPackage ( rec { name = "numpy-1.9.2"; src = pkgs.fetchurl { @@ -7860,15 +7823,13 @@ let sed -i '0,/from numpy.distutils.core/s//import setuptools;from numpy.distutils.core/' setup.py ''; - preBuild = self.numpyScipyPrebuild; + inherit (support) preBuild checkPhase; setupPyBuildFlags = ["--fcompiler='gnu95'"]; buildInputs = [ pkgs.gfortran self.nose ]; propagatedBuildInputs = [ pkgs.atlas ]; - checkPhase = self.numpyScipyCheckPhase python "numpy"; - meta = { description = "Scientific tools for Python"; homepage = "http://numpy.scipy.org/"; @@ -11219,7 +11180,13 @@ let }; - scipy = buildPythonPackage rec { + scipy = let + support = import ./python-support/numpy-scipy-support.nix { + inherit python; + atlas = atlasWithLapack; + pkgName = "numpy"; + }; + in buildPythonPackage rec { name = "scipy-0.15.1"; src = pkgs.fetchurl { @@ -11230,17 +11197,14 @@ let buildInputs = [ pkgs.gfortran self.nose ]; propagatedBuildInputs = [ self.numpy ]; - # TODO: add ATLAS=${pkgs.atlas} preConfigure = '' sed -i '0,/from numpy.distutils.core/s//import setuptools;from numpy.distutils.core/' setup.py ''; - preBuild = self.numpyScipyPrebuild; + inherit (support) preBuild checkPhase; setupPyBuildFlags = [ "--fcompiler='gnu95'" ]; - checkPhase = self.numpyScipyCheckPhase python "scipy"; - meta = { description = "SciPy (pronounced 'Sigh Pie') is open-source software for mathematics, science, and engineering. "; homepage = http://www.scipy.org/; diff --git a/pkgs/top-level/python-support/numpy-scipy-support.nix b/pkgs/top-level/python-support/numpy-scipy-support.nix new file mode 100644 index 00000000000..d991a98925a --- /dev/null +++ b/pkgs/top-level/python-support/numpy-scipy-support.nix @@ -0,0 +1,53 @@ +{ + # Python package expression + python, + # Name of package (e.g. numpy or scipy) + pkgName, + # Atlas math library + atlas +}: + +{ + + # First "install" the package, then import what was installed, and call the + # .test() function, which will run the test suite. + checkPhase = '' + runHook preCheck + + _python=${python}/bin/${python.executable} + + # We will "install" into a temp directory, so that we can run the numpy + # tests (see below). + install_dir="$TMPDIR/test_install" + install_lib="$install_dir/lib/${python.libPrefix}/site-packages" + mkdir -p $install_dir + $_python setup.py install \ + --install-lib=$install_lib \ + --old-and-unmanageable \ + --prefix=$install_dir > /dev/null + + # Create a directory in which to run tests (you get an error if you try to + # import the package when you're in the current directory). + mkdir $TMPDIR/run_tests + pushd $TMPDIR/run_tests > /dev/null + # Temporarily add the directory we installed in to the python path + # (not permanently, or this pythonpath will wind up getting exported), + # and run the test suite. + PYTHONPATH="$install_lib:$PYTHONPATH" $_python -c \ + 'import ${pkgName}; ${pkgName}.test("fast", verbose=10)' + popd > /dev/null + + runHook postCheck + ''; + + # Creates a site.cfg telling the setup script where to find depended-on + # math libraries. + preBuild = '' + echo "Creating site.cfg file..." + cat << EOF > site.cfg + [atlas] + include_dirs = ${atlas}/include + library_dirs = ${atlas}/lib + EOF + ''; +} From 18bb7a40478c883c539d7e268cf93fe0902899db Mon Sep 17 00:00:00 2001 From: Allen Nelson Date: Fri, 29 May 2015 11:02:21 -0700 Subject: [PATCH 3/3] fix undefined variable --- pkgs/top-level/python-packages.nix | 4 ++-- pkgs/top-level/python-support/numpy-scipy-support.nix | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 38636840b9b..bf5ee48579f 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -7805,7 +7805,7 @@ let numpy = let support = import ./python-support/numpy-scipy-support.nix { inherit python; - atlas = atlasWithLapack; + atlas = pkgs.atlasWithLapack; pkgName = "numpy"; }; in buildPythonPackage ( rec { @@ -11183,7 +11183,7 @@ let scipy = let support = import ./python-support/numpy-scipy-support.nix { inherit python; - atlas = atlasWithLapack; + atlas = pkgs.atlasWithLapack; pkgName = "numpy"; }; in buildPythonPackage rec { diff --git a/pkgs/top-level/python-support/numpy-scipy-support.nix b/pkgs/top-level/python-support/numpy-scipy-support.nix index d991a98925a..6cca704dcda 100644 --- a/pkgs/top-level/python-support/numpy-scipy-support.nix +++ b/pkgs/top-level/python-support/numpy-scipy-support.nix @@ -16,7 +16,7 @@ _python=${python}/bin/${python.executable} - # We will "install" into a temp directory, so that we can run the numpy + # We will "install" into a temp directory, so that we can run the # tests (see below). install_dir="$TMPDIR/test_install" install_lib="$install_dir/lib/${python.libPrefix}/site-packages"