35 assert (!blas.isILP64) && (!lapack.isILP64);
40 text = lib.generators.toINI { } {
41 ${blas.implementation} = {
42 include_dirs = "${lib.getDev blas}/include:${lib.getDev lapack}/include";
43 library_dirs = "${blas}/lib:${lapack}/lib";
44 runtime_library_dirs = "${blas}/lib:${lapack}/lib";
45 libraries = "lapack,lapacke,blas,cblas";
48 include_dirs = "${lib.getDev lapack}/include";
49 library_dirs = "${lapack}/lib";
50 runtime_library_dirs = "${lapack}/lib";
53 include_dirs = "${lib.getDev blas}/include";
54 library_dirs = "${blas}/lib";
55 runtime_library_dirs = "${blas}/lib";
60 buildPythonPackage rec {
65 disabled = pythonOlder "3.10";
68 inherit pname version;
70 hash = "sha256-E1MqCIIX+mJMmbhD7rVGQN4js0FLFKpm0COAXrcxBmw=";
73 patches = lib.optionals python.hasDistutilsCxxPatch [
74 # We patch cpython/distutils to fix https://bugs.python.org/issue1222585
75 # Patching of numpy.distutils is needed to prevent it from undoing the
77 ./numpy-distutils-C++.patch
81 # remove needless reference to full Python path stored in built wheel
82 substituteInPlace numpy/meson.build \
83 --replace-fail 'py.full_path()' "'python'"
93 ++ lib.optionals stdenv.hostPlatform.isDarwin [ xcbuild.xcrun ]
94 ++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [ mesonEmulatorHook ];
96 # we default openblas to build with 64 threads
97 # if a machine has more than 64 threads, it will segfault
98 # see https://github.com/OpenMathLib/OpenBLAS/issues/2993
100 sed -i 's/-faltivec//' numpy/distutils/system_info.py
101 export OMP_NUM_THREADS=$((NIX_BUILD_CORES > 64 ? 64 : NIX_BUILD_CORES))
104 # HACK: copy mesonEmulatorHook's flags to the variable used by meson-python
106 mesonFlags="$mesonFlags ''${mesonFlagsArray[@]}"
115 ln -s ${cfg} site.cfg
118 enableParallelBuilding = true;
120 nativeCheckInputs = [
136 # https://github.com/numpy/numpy/blob/a277f6210739c11028f281b8495faf7da298dbef/numpy/_pytesttester.py#L180
139 "not\\ slow" # fast test suite
144 # Tries to import numpy.distutils.msvccompiler, removed in setuptools 74.0
145 "test_api_importable"
147 ++ lib.optionals (pythonAtLeast "3.13") [
148 # https://github.com/numpy/numpy/issues/26713
151 ++ lib.optionals stdenv.hostPlatform.isAarch32 [
152 # https://github.com/numpy/numpy/issues/24548
153 "test_impossible_feature_enable" # AssertionError: Failed to generate error
154 "test_features" # AssertionError: Failure Detection
155 "test_new_policy" # AssertionError: assert False
156 "test_identityless_reduction_huge_array" # ValueError: Maximum allowed dimension exceeded
157 "test_unary_spurious_fpexception" # AssertionError: Got warnings: [<warnings.WarningMessage object at 0xd1197430>]
158 "test_int" # AssertionError: selectedintkind(19): expected 16 but got -1
159 "test_real" # AssertionError: selectedrealkind(16): expected 10 but got -1
160 "test_quad_precision" # AssertionError: selectedrealkind(32): expected 16 but got -1
161 "test_big_arrays" # ValueError: array is too big; `arr.size * arr.dtype.itemsize` is larger tha...
162 "test_multinomial_pvals_float32" # Failed: DID NOT RAISE <class 'ValueError'>
164 ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) [
165 # AssertionError: (np.int64(0), np.longdouble('9.9999999999999994515e-21'), np.longdouble('3.9696755572509052902e+20'), 'arctanh')
166 "test_loss_of_precision"
170 # just for backwards compatibility
171 blas = blas.provider;
172 blasImplementation = blas.implementation;
174 coreIncludeDir = "${numpy_2}/${python.sitePackages}/numpy/_core/include";
181 changelog = "https://github.com/numpy/numpy/releases/tag/v${version}";
182 description = "Scientific tools for Python";
183 homepage = "https://numpy.org/";
184 license = lib.licenses.bsd3;
185 maintainers = with lib.maintainers; [ doronbehar ];