From 631d41a767b47205d53f38d198d591308fed48e9 Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Wed, 21 Aug 2024 10:21:28 +0300 Subject: [PATCH 1/8] python312Packages.numpy_2: 2.0.1 -> 2.1.0 Changelog: https://github.com/numpy/numpy/releases/tag/v2.1.0 --- pkgs/development/python-modules/numpy/2.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/python-modules/numpy/2.nix b/pkgs/development/python-modules/numpy/2.nix index a94badd18c6f9..4164b7c80a93c 100644 --- a/pkgs/development/python-modules/numpy/2.nix +++ b/pkgs/development/python-modules/numpy/2.nix @@ -58,7 +58,7 @@ let in buildPythonPackage rec { pname = "numpy"; - version = "2.0.1"; + version = "2.1.0"; pyproject = true; disabled = pythonOlder "3.10"; @@ -66,7 +66,7 @@ buildPythonPackage rec { src = fetchPypi { inherit pname version; extension = "tar.gz"; - hash = "sha256-SFuHI1eWQQw1GaaZz+H6qwl+UJ6Q67BdzQmNsq6H57M="; + hash = "sha256-fckNoAgffh2knsTjmO3mqOnMT16+X54GtEPtiJ7pqqI="; }; patches = lib.optionals python.hasDistutilsCxxPatch [ From 1623a677da33f2dbf694a8f25af5cc6917910724 Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Wed, 21 Aug 2024 10:51:36 +0300 Subject: [PATCH 2/8] python312Packages.llvmlite: use pytestCheckHook --- pkgs/development/python-modules/llvmlite/default.nix | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pkgs/development/python-modules/llvmlite/default.nix b/pkgs/development/python-modules/llvmlite/default.nix index 2d92814a1835d..d382e5487c2d4 100644 --- a/pkgs/development/python-modules/llvmlite/default.nix +++ b/pkgs/development/python-modules/llvmlite/default.nix @@ -11,7 +11,7 @@ setuptools, # tests - python, + pytestCheckHook, }: buildPythonPackage rec { @@ -46,10 +46,12 @@ buildPythonPackage rec { export LLVM_CONFIG=${llvm.dev}/bin/llvm-config ''; - checkPhase = '' - runHook preCheck - ${python.executable} runtests.py - runHook postCheck + nativeCheckInputs = [ + pytestCheckHook + ]; + # https://github.com/NixOS/nixpkgs/issues/255262 + preCheck = '' + cd $out ''; __impureHostDeps = lib.optionals stdenv.isDarwin [ "/usr/lib/libm.dylib" ]; From deac6c1c187a409dc4835b014d2766534b116ba4 Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Wed, 21 Aug 2024 10:51:50 +0300 Subject: [PATCH 3/8] python312Packages.llvmlite: don't use with lib in meta --- pkgs/development/python-modules/llvmlite/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/python-modules/llvmlite/default.nix b/pkgs/development/python-modules/llvmlite/default.nix index d382e5487c2d4..10a89f2392c0f 100644 --- a/pkgs/development/python-modules/llvmlite/default.nix +++ b/pkgs/development/python-modules/llvmlite/default.nix @@ -58,11 +58,11 @@ buildPythonPackage rec { passthru.llvm = llvm; - meta = with lib; { + meta = { changelog = "https://github.com/numba/llvmlite/blob/v${version}/CHANGE_LOG"; description = "Lightweight LLVM python binding for writing JIT compilers"; downloadPage = "https://github.com/numba/llvmlite"; homepage = "http://llvmlite.pydata.org/"; - license = licenses.bsd2; + license = lib.licenses.bsd2; }; } From bf47ce9bc746927eede1675bcf1d165991824c09 Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Wed, 21 Aug 2024 10:52:18 +0300 Subject: [PATCH 4/8] python312Packages.llvmlite: remove outdated substitution --- pkgs/development/python-modules/llvmlite/default.nix | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pkgs/development/python-modules/llvmlite/default.nix b/pkgs/development/python-modules/llvmlite/default.nix index 10a89f2392c0f..187387f0f5b4b 100644 --- a/pkgs/development/python-modules/llvmlite/default.nix +++ b/pkgs/development/python-modules/llvmlite/default.nix @@ -33,11 +33,7 @@ buildPythonPackage rec { setuptools ]; - # Disable static linking - # https://github.com/numba/llvmlite/issues/93 postPatch = '' - substituteInPlace ffi/Makefile.linux --replace "-static-libstdc++" "" - substituteInPlace llvmlite/tests/test_binding.py --replace "test_linux" "nope" ''; From 5d2d5555514a86929d83e40af99492434741cc98 Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Wed, 21 Aug 2024 10:52:40 +0300 Subject: [PATCH 5/8] python312Packages.llvmlite: use --replace-fail in test_binding substitution --- pkgs/development/python-modules/llvmlite/default.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/development/python-modules/llvmlite/default.nix b/pkgs/development/python-modules/llvmlite/default.nix index 187387f0f5b4b..9fdcab6d7534e 100644 --- a/pkgs/development/python-modules/llvmlite/default.nix +++ b/pkgs/development/python-modules/llvmlite/default.nix @@ -34,7 +34,8 @@ buildPythonPackage rec { ]; postPatch = '' - substituteInPlace llvmlite/tests/test_binding.py --replace "test_linux" "nope" + substituteInPlace llvmlite/tests/test_binding.py \ + --replace-fail "test_linux" "nope" ''; # Set directory containing llvm-config binary From 3bad18825ec132da9f34a41f37cc28e26084862e Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Wed, 21 Aug 2024 10:54:45 +0300 Subject: [PATCH 6/8] python312Packages.numba: use a single numpy version; don't propagate it --- pkgs/development/python-modules/numba/default.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkgs/development/python-modules/numba/default.nix b/pkgs/development/python-modules/numba/default.nix index 27b34f6a3b26b..1f9ce6ad767c9 100644 --- a/pkgs/development/python-modules/numba/default.nix +++ b/pkgs/development/python-modules/numba/default.nix @@ -7,7 +7,6 @@ python, buildPythonPackage, setuptools, - numpy, numpy_2, llvmlite, libcxx, @@ -68,7 +67,6 @@ buildPythonPackage rec { build-system = [ setuptools - numpy_2 ]; nativeBuildInputs = lib.optionals cudaSupport [ @@ -76,10 +74,12 @@ buildPythonPackage rec { cudaPackages.cuda_nvcc ]; - buildInputs = lib.optionals cudaSupport [ cudaPackages.cuda_cudart ]; + buildInputs = [ + # Not propagating it, because it numba can work with either numpy_2 or numpy_1 + numpy_2 + ] ++ lib.optionals cudaSupport [ cudaPackages.cuda_cudart ]; dependencies = [ - numpy llvmlite setuptools ] ++ lib.optionals (pythonOlder "3.9") [ importlib-metadata ]; From ec6142092edaf39f84798571751764597e2f7920 Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Thu, 22 Aug 2024 19:21:19 +0300 Subject: [PATCH 7/8] python312Packages.numba: rewrite testing details --- .../python-modules/numba/default.nix | 62 ++++++++++--------- 1 file changed, 34 insertions(+), 28 deletions(-) diff --git a/pkgs/development/python-modules/numba/default.nix b/pkgs/development/python-modules/numba/default.nix index 1f9ce6ad767c9..f0f5574a6d186 100644 --- a/pkgs/development/python-modules/numba/default.nix +++ b/pkgs/development/python-modules/numba/default.nix @@ -15,6 +15,7 @@ runCommand, writers, numba, + pytestCheckHook, config, @@ -25,6 +26,8 @@ # CUDA flags: cudaSupport ? config.cudaSupport, + testsWithoutSandbox ? false, + doFullCheck ? false, }: let @@ -92,20 +95,28 @@ buildPythonPackage rec { }) ]; - # run a smoke test in a temporary directory so that - # a) Python picks up the installed library in $out instead of the build files - # b) we have somewhere to put $HOME so some caching tests work - # c) it doesn't take 6 CPU hours for the full suite - checkPhase = '' - runHook preCheck - - pushd $(mktemp -d) - HOME=. ${python.interpreter} -m numba.runtests -m $NIX_BUILD_CORES numba.tests.test_usecases - popd + nativeCheckInputs = [ + pytestCheckHook + ]; - runHook postCheck + preCheck = '' + export HOME="$(mktemp -d)" + # https://github.com/NixOS/nixpkgs/issues/255262 + cd $out ''; + pytestFlagsArray = lib.optionals (!doFullCheck) [ + # These are the most basic tests. Running all tests is too expensive, and + # some of them fail (also differently on different platforms), so it will + # be too hard to maintain such a `disabledTests` list. + "${python.sitePackages}/numba/tests/test_usecases.py" + ]; + + disabledTestPaths = lib.optionals (!testsWithoutSandbox) [ + # See NOTE near passthru.tests.withoutSandbox + "${python.sitePackages}/numba/cuda/tests" + ]; + pythonImportsCheck = [ "numba" ]; passthru.testers.cuda-detect = @@ -117,23 +128,18 @@ buildPythonPackage rec { ''; passthru.tests = { # CONTRIBUTOR NOTE: numba also contains CUDA tests, though these cannot be run in - # this sandbox environment. Consider running similar commands to those below outside the - # sandbox manually if you have the appropriate hardware; support will be detected - # and the corresponding tests enabled automatically. - # Also, the full suite currently does not complete on anything but x86_64-linux. - fullSuite = runCommand "${pname}-test" { } '' - pushd $(mktemp -d) - # pip and python in $PATH is needed for the test suite to pass fully - PATH=${ - python.withPackages (p: [ - p.numba - p.pip - ]) - }/bin:$PATH - HOME=$PWD python -m numba.runtests -m $NIX_BUILD_CORES - popd - touch $out # stop Nix from complaining no output was generated and failing the build - ''; + # this sandbox environment. Consider building the derivation below with + # --no-sandbox to get a view of how many tests succeed outside the sandbox. + withoutSandbox = numba.override { + doFullCheck = true; + cudaSupport = true; + testsWithoutSandbox = true; + }; + withSandbox = numba.override { + cudaSupport = false; + doFullCheck = true; + testsWithoutSandbox = false; + }; }; meta = with lib; { From 4865fc4870b2b3a30ab0b2f8a1c19ad6d4c6b3ed Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Wed, 21 Aug 2024 13:33:23 +0300 Subject: [PATCH 8/8] python312Packages.numba: 0.60.0 -> 0.61.0dev0 Add a temporary hack to pretend the version as 0.61.0dev0 --- .../development/python-modules/numba/default.nix | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/pkgs/development/python-modules/numba/default.nix b/pkgs/development/python-modules/numba/default.nix index f0f5574a6d186..c9285322ca29c 100644 --- a/pkgs/development/python-modules/numba/default.nix +++ b/pkgs/development/python-modules/numba/default.nix @@ -34,7 +34,7 @@ let cudatoolkit = cudaPackages.cuda_nvcc; in buildPythonPackage rec { - version = "0.60.0"; + version = "0.61.0dev0"; pname = "numba"; pyproject = true; @@ -55,8 +55,18 @@ buildPythonPackage rec { # that upstream relies on those strings to be valid, that's why we don't # use `forceFetchGit = true;`.` If in the future we'll observe the hash # changes too often, we can always use forceFetchGit, and inject the - # relevant strings ourselves, using `sed` commands, in extraPostFetch. - hash = "sha256-hUL281wHLA7wo8umzBNhiGJikyIF2loCzjLECuC+pO0="; + # relevant strings ourselves, using `substituteInPlace`, in postFetch. + hash = "sha256-KF9YQ6/FIfUQTJCAMgfIqnb/D8mdMbCC/tJvfYlSkgI="; + # TEMPORARY: The way upstream knows it's source version is explained above, + # and without this upstream sets the version in ${python.sitePackages} as + # 0.61.0dev0, which causes dependent packages fail to find a valid + # version of numba. + postFetch = '' + substituteInPlace $out/numba/_version.py \ + --replace-fail \ + 'git_refnames = " (tag: ${version})"' \ + 'git_refnames = " (tag: 0.61.0, release0.61)"' + ''; }; postPatch = ''