From 516366f11a89a66e1bb44681b690001417406754 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Sun, 28 Jun 2026 14:09:38 +0200 Subject: [PATCH] python3Packages.numba: fix numpy 2.5 compat --- .../python-modules/numba/default.nix | 29 +++++++++++-------- .../python-modules/numba/numpy2.4.patch | 28 ------------------ .../python-modules/numba/numpy2.5.patch | 26 +++++++++++++++++ 3 files changed, 43 insertions(+), 40 deletions(-) delete mode 100644 pkgs/development/python-modules/numba/numpy2.4.patch create mode 100644 pkgs/development/python-modules/numba/numpy2.5.patch diff --git a/pkgs/development/python-modules/numba/default.nix b/pkgs/development/python-modules/numba/default.nix index 0e38f0392cde..11c25c98168d 100644 --- a/pkgs/development/python-modules/numba/default.nix +++ b/pkgs/development/python-modules/numba/default.nix @@ -4,7 +4,6 @@ fetchFromGitHub, buildPythonPackage, replaceVars, - fetchpatch, # nativeBuildInputs setuptools, @@ -16,8 +15,8 @@ # tests numba, pytestCheckHook, + pytest-xdist, writableTmpDirAsHomeHook, - numpy_1, writers, python, @@ -56,11 +55,26 @@ buildPythonPackage (finalAttrs: { hash = "sha256-DMmUyTElDFyMK4BUQ4EhDNmG43lOWQHurKbnSyhAs5k="; }; + patches = [ + ./numpy2.5.patch + ] + ++ lib.optionals cudaSupport [ + (replaceVars ./cuda_path.patch { + cuda_toolkit_path = cudatoolkit; + cuda_toolkit_lib_path = lib.getLib cudatoolkit; + }) + ]; + postPatch = '' substituteInPlace numba/cuda/cudadrv/driver.py \ --replace-fail \ "dldir = [" \ "dldir = [ '${addDriverRunpath.driverLink}/lib', " + + substituteInPlace setup.py \ + --replace-fail 'max_numpy_run_version = "2.5"' 'max_numpy_run_version = "2.6"' + substituteInPlace numba/__init__.py \ + --replace-fail "(2, 4)" "(2, 6)" ''; build-system = [ @@ -84,15 +98,9 @@ buildPythonPackage (finalAttrs: { llvmlite ]; - patches = lib.optionals cudaSupport [ - (replaceVars ./cuda_path.patch { - cuda_toolkit_path = cudatoolkit; - cuda_toolkit_lib_path = lib.getLib cudatoolkit; - }) - ]; - nativeCheckInputs = [ pytestCheckHook + pytest-xdist writableTmpDirAsHomeHook ]; @@ -145,9 +153,6 @@ buildPythonPackage (finalAttrs: { doFullCheck = true; testsWithoutSandbox = false; }; - numpy_1 = numba.override { - numpy = numpy_1; - }; }; meta = { diff --git a/pkgs/development/python-modules/numba/numpy2.4.patch b/pkgs/development/python-modules/numba/numpy2.4.patch deleted file mode 100644 index 37fd13bd9582..000000000000 --- a/pkgs/development/python-modules/numba/numpy2.4.patch +++ /dev/null @@ -1,28 +0,0 @@ -diff --git a/numba/__init__.py b/numba/__init__.py -index 33f752018..7d3b3ae8d 100644 ---- a/numba/__init__.py -+++ b/numba/__init__.py -@@ -39,8 +39,8 @@ def _ensure_critical_deps(): - f"{numpy_version[0]}.{numpy_version[1]}.") - raise ImportError(msg) - -- if numpy_version > (2, 3): -- msg = (f"Numba needs NumPy 2.3 or less. Got NumPy " -+ if numpy_version > (2, 4): -+ msg = (f"Numba needs NumPy 2.4 or less. Got NumPy " - f"{numpy_version[0]}.{numpy_version[1]}.") - raise ImportError(msg) - -diff --git a/setup.py b/setup.py -index 9eaa191cb..a5febef1e 100644 ---- a/setup.py -+++ b/setup.py -@@ -23,7 +23,7 @@ min_python_version = "3.10" - max_python_version = "3.15" # exclusive - min_numpy_build_version = "2.0.0rc1" - min_numpy_run_version = "1.22" --max_numpy_run_version = "2.4" -+max_numpy_run_version = "2.5" - min_llvmlite_version = "0.46.0dev0" - max_llvmlite_version = "0.47" - diff --git a/pkgs/development/python-modules/numba/numpy2.5.patch b/pkgs/development/python-modules/numba/numpy2.5.patch new file mode 100644 index 000000000000..7cc84679ced9 --- /dev/null +++ b/pkgs/development/python-modules/numba/numpy2.5.patch @@ -0,0 +1,26 @@ +diff --git a/numba/np/arrayobj.py b/numba/np/arrayobj.py +index ae81627ec..dd69a2a45 100644 +--- a/numba/np/arrayobj.py ++++ b/numba/np/arrayobj.py +@@ -6639,7 +6639,7 @@ def impl_np_vstack(tup): + return impl + + +-if numpy_version >= (2, 0): ++if (2, 0) <= numpy_version < (2, 5): + overload(np.row_stack)(impl_np_vstack) + + +diff --git a/numba/tests/test_dyn_array.py b/numba/tests/test_dyn_array.py +index 99328052c..dfbf57589 100644 +--- a/numba/tests/test_dyn_array.py ++++ b/numba/tests/test_dyn_array.py +@@ -36,7 +36,7 @@ def np_vstack(a, b, c): + return np.vstack((a, b, c)) + + def np_row_stack(a, b, c): +- return np.row_stack((a, b, c)) ++ return np.vstack((a, b, c)) + + def np_dstack(a, b, c): + return np.dstack((a, b, c))