Skip to content

Commit 63cf61e

Browse files
committed
pythonPackages: new functions to build numpy and scipy
1 parent e5b143a commit 63cf61e

4 files changed

Lines changed: 117 additions & 110 deletions

File tree

pkgs/development/python-modules/numpy-scipy-support.nix

Lines changed: 0 additions & 35 deletions
This file was deleted.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{lib, python, buildPythonPackage, isPyPy, gfortran, nose, blas}:
2+
3+
args:
4+
5+
let
6+
inherit (args) version;
7+
in buildPythonPackage (args // rec {
8+
9+
name = "numpy-${version}";
10+
11+
disabled = isPyPy;
12+
buildInputs = args.buildInputs or [ gfortran nose ];
13+
propagatedBuildInputs = args.propagatedBuildInputs or [ passthru.blas ];
14+
15+
preConfigure = ''
16+
sed -i 's/-faltivec//' numpy/distutils/system_info.py
17+
'';
18+
19+
preBuild = ''
20+
echo "Creating site.cfg file..."
21+
cat << EOF > site.cfg
22+
[openblas]
23+
include_dirs = ${passthru.blas}/include
24+
library_dirs = ${passthru.blas}/lib
25+
EOF
26+
'';
27+
28+
checkPhase = ''
29+
runHook preCheck
30+
pushd dist
31+
${python.interpreter} -c 'import numpy; numpy.test("fast", verbose=10)'
32+
popd
33+
runHook postCheck
34+
'';
35+
36+
passthru = {
37+
blas = blas;
38+
};
39+
40+
# The large file support test is disabled because it takes forever
41+
# and can cause the machine to run out of disk space when run.
42+
prePatch = ''
43+
sed -i 's/test_large_file_support/donttest/' numpy/lib/tests/test_format.py
44+
'';
45+
46+
meta = {
47+
description = "Scientific tools for Python";
48+
homepage = "http://numpy.scipy.org/";
49+
maintainers = with lib.maintainers; [ fridh ];
50+
} // (args.meta or {});
51+
})
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{lib, python, buildPythonPackage, isPyPy, gfortran, nose}:
2+
3+
args:
4+
5+
let
6+
inherit (args) version;
7+
inherit (args) numpy;
8+
in buildPythonPackage (args // rec {
9+
10+
name = "scipy-${version}";
11+
12+
buildInputs = (args.buildInputs or [ gfortran nose ]);
13+
propagatedBuildInputs = (args.propagatedBuildInputs or [ passthru.blas numpy]);
14+
15+
preConfigure = ''
16+
sed -i '0,/from numpy.distutils.core/s//import setuptools;from numpy.distutils.core/' setup.py
17+
'';
18+
19+
preBuild = ''
20+
echo "Creating site.cfg file..."
21+
cat << EOF > site.cfg
22+
[openblas]
23+
include_dirs = ${passthru.blas}/include
24+
library_dirs = ${passthru.blas}/lib
25+
EOF
26+
'';
27+
28+
checkPhase = ''
29+
runHook preCheck
30+
pushd dist
31+
${python.interpreter} -c 'import scipy; scipy.test("fast", verbose=10)'
32+
popd
33+
runHook postCheck
34+
'';
35+
36+
passthru = {
37+
blas = numpy.blas;
38+
};
39+
40+
setupPyBuildFlags = [ "--fcompiler='gnu95'" ];
41+
42+
meta = {
43+
description = "SciPy (pronounced 'Sigh Pie') is open-source software for mathematics, science, and engineering. ";
44+
homepage = http://www.scipy.org/;
45+
maintainers = with lib.maintainers; [ fridh ];
46+
} // (args.meta or {});
47+
})

pkgs/top-level/python-packages.nix

Lines changed: 19 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -12505,48 +12505,20 @@ in modules // {
1250512505
};
1250612506
};
1250712507

12508-
numpy = let
12509-
support = import ../development/python-modules/numpy-scipy-support.nix {
12510-
inherit python;
12511-
openblas = pkgs.openblasCompat;
12512-
pkgName = "numpy";
12513-
};
12514-
in buildPythonPackage ( rec {
12515-
name = "numpy-${version}";
12516-
version = "1.10.4";
12508+
buildNumpyPackage = callPackage ../development/python-modules/numpy.nix {
12509+
gfortran = pkgs.gfortran;
12510+
blas = pkgs.openblasCompat;
12511+
};
12512+
12513+
numpy = self.numpy_1_10;
1251712514

12515+
numpy_1_10 = self.buildNumpyPackage rec {
12516+
version = "1.10.4";
1251812517
src = pkgs.fetchurl {
12519-
url = "https://pypi.python.org/packages/source/n/numpy/${name}.tar.gz";
12518+
url = "https://pypi.python.org/packages/source/n/numpy/numpy-${version}.tar.gz";
1252012519
sha256 = "7356e98fbcc529e8d540666f5a919912752e569150e9a4f8d869c686f14c720b";
1252112520
};
12522-
12523-
disabled = isPyPy; # WIP
12524-
12525-
preConfigure = ''
12526-
sed -i 's/-faltivec//' numpy/distutils/system_info.py
12527-
'';
12528-
12529-
inherit (support) preBuild checkPhase;
12530-
12531-
buildInputs = [ pkgs.gfortran self.nose ];
12532-
propagatedBuildInputs = [ support.openblas ];
12533-
12534-
# Disable failing test_f2py test.
12535-
# f2py couldn't be found by test,
12536-
# even though it was used successfully to build numpy
12537-
12538-
# The large file support test is disabled because it takes forever
12539-
# and can cause the machine to run out of disk space when run.
12540-
prePatch = ''
12541-
sed -i 's/test_f2py/donttest/' numpy/tests/test_scripts.py
12542-
sed -i 's/test_large_file_support/donttest/' numpy/lib/tests/test_format.py
12543-
'';
12544-
12545-
meta = {
12546-
description = "Scientific tools for Python";
12547-
homepage = "http://numpy.scipy.org/";
12548-
};
12549-
});
12521+
};
1255012522

1255112523
numpydoc = buildPythonPackage rec {
1255212524
name = "numpydoc-${version}";
@@ -18488,47 +18460,19 @@ in modules // {
1848818460
};
1848918461
};
1849018462

18463+
buildScipyPackage = callPackage ../development/python-modules/scipy.nix {
18464+
gfortran = pkgs.gfortran;
18465+
};
1849118466

18492-
scipy = let
18493-
support = import ../development/python-modules/numpy-scipy-support.nix {
18494-
inherit python;
18495-
openblas = pkgs.openblasCompat;
18496-
pkgName = "scipy";
18497-
};
18498-
in buildPythonPackage rec {
18499-
name = "scipy-${version}";
18500-
version = "0.16.1";
18467+
scipy = self.scipy_0_16;
1850118468

18469+
scipy_0_16 = self.buildScipyPackage rec {
18470+
version = "0.16.1";
1850218471
src = pkgs.fetchurl {
18503-
url = "http://pypi.python.org/packages/source/s/scipy/${name}.tar.gz";
18472+
url = "https://pypi.python.org/packages/source/s/scipy/scipy-${version}.tar.gz";
1850418473
sha256 = "ecd1efbb1c038accb0516151d1e6679809c6010288765eb5da6051550bf52260";
1850518474
};
18506-
18507-
buildInputs = [ pkgs.gfortran self.nose ];
18508-
propagatedBuildInputs = [ self.numpy ];
18509-
18510-
preConfigure = ''
18511-
sed -i '0,/from numpy.distutils.core/s//import setuptools;from numpy.distutils.core/' setup.py
18512-
'';
18513-
18514-
# First test: RuntimeWarning: Mean of empty slice.
18515-
# Second: SyntaxError: invalid syntax. Due to wrapper?
18516-
# Third: test checks permissions
18517-
prePatch = ''
18518-
substituteInPlace scipy/stats/tests/test_stats.py --replace "test_chisquare_masked_arrays" "remove_this_one"
18519-
rm scipy/linalg/tests/test_lapack.py
18520-
substituteInPlace scipy/weave/tests/test_catalog.py --replace "test_user" "remove_this_one"
18521-
'';
18522-
18523-
inherit (support) preBuild checkPhase;
18524-
18525-
patches = [../development/python-modules/scipy-0.16.1-decorator-fix.patch];
18526-
setupPyBuildFlags = [ "--fcompiler='gnu95'" ];
18527-
18528-
meta = {
18529-
description = "SciPy (pronounced 'Sigh Pie') is open-source software for mathematics, science, and engineering. ";
18530-
homepage = http://www.scipy.org/;
18531-
};
18475+
numpy = self.numpy_1_10;
1853218476
};
1853318477

1853418478
scikitimage = buildPythonPackage rec {
@@ -18563,7 +18507,7 @@ in modules // {
1856318507
};
1856418508

1856518509
buildInputs = with self; [ nose pillow pkgs.gfortran pkgs.glibcLocales ];
18566-
propagatedBuildInputs = with self; [ numpy scipy pkgs.openblas ];
18510+
propagatedBuildInputs = with self; [ numpy scipy numpy.blas ];
1856718511

1856818512
LC_ALL="en_US.UTF-8";
1856918513

0 commit comments

Comments
 (0)