···7 python,
8 buildPythonPackage,
9 setuptools,
10- numpy,
11 numpy_2,
12 llvmlite,
13 libcxx,
···17 runCommand,
18 writers,
19 numba,
02021 config,
22···2728 # CUDA flags:
29 cudaSupport ? config.cudaSupport,
0030}:
3132let
33 cudatoolkit = cudaPackages.cuda_nvcc;
34in
35buildPythonPackage rec {
36- version = "0.60.0";
37 pname = "numba";
38 pyproject = true;
39···54 # that upstream relies on those strings to be valid, that's why we don't
55 # use `forceFetchGit = true;`.` If in the future we'll observe the hash
56 # changes too often, we can always use forceFetchGit, and inject the
57- # relevant strings ourselves, using `sed` commands, in extraPostFetch.
58- hash = "sha256-hUL281wHLA7wo8umzBNhiGJikyIF2loCzjLECuC+pO0=";
000000000059 };
6061 postPatch = ''
···6970 build-system = [
71 setuptools
72- numpy_2
73 ];
7475 nativeBuildInputs = lib.optionals cudaSupport [
···77 cudaPackages.cuda_nvcc
78 ];
7980- buildInputs = lib.optionals cudaSupport [ cudaPackages.cuda_cudart ];
0008182 dependencies = [
83- numpy
84 llvmlite
85 setuptools
86 ] ++ lib.optionals (pythonOlder "3.9") [ importlib-metadata ];
···103 })
104 ];
105106- # run a smoke test in a temporary directory so that
107- # a) Python picks up the installed library in $out instead of the build files
108- # b) we have somewhere to put $HOME so some caching tests work
109- # c) it doesn't take 6 CPU hours for the full suite
110- checkPhase = ''
111- runHook preCheck
112-113- pushd $(mktemp -d)
114- HOME=. ${python.interpreter} -m numba.runtests -m $NIX_BUILD_CORES numba.tests.test_usecases
115- popd
116117- runHook postCheck
000118 '';
119000000000000120 pythonImportsCheck = [ "numba" ];
121122 passthru.testers.cuda-detect =
···128 '';
129 passthru.tests = {
130 # CONTRIBUTOR NOTE: numba also contains CUDA tests, though these cannot be run in
131- # this sandbox environment. Consider running similar commands to those below outside the
132- # sandbox manually if you have the appropriate hardware; support will be detected
133- # and the corresponding tests enabled automatically.
134- # Also, the full suite currently does not complete on anything but x86_64-linux.
135- fullSuite = runCommand "${pname}-test" { } ''
136- pushd $(mktemp -d)
137- # pip and python in $PATH is needed for the test suite to pass fully
138- PATH=${
139- python.withPackages (p: [
140- p.numba
141- p.pip
142- ])
143- }/bin:$PATH
144- HOME=$PWD python -m numba.runtests -m $NIX_BUILD_CORES
145- popd
146- touch $out # stop Nix from complaining no output was generated and failing the build
147- '';
148 };
149150 meta = with lib; {
···7 python,
8 buildPythonPackage,
9 setuptools,
010 numpy_2,
11 llvmlite,
12 libcxx,
···16 runCommand,
17 writers,
18 numba,
19+ pytestCheckHook,
2021 config,
22···2728 # CUDA flags:
29 cudaSupport ? config.cudaSupport,
30+ testsWithoutSandbox ? false,
31+ doFullCheck ? false,
32}:
3334let
35 cudatoolkit = cudaPackages.cuda_nvcc;
36in
37buildPythonPackage rec {
38+ version = "0.61.0dev0";
39 pname = "numba";
40 pyproject = true;
41···56 # that upstream relies on those strings to be valid, that's why we don't
57 # use `forceFetchGit = true;`.` If in the future we'll observe the hash
58 # changes too often, we can always use forceFetchGit, and inject the
59+ # relevant strings ourselves, using `substituteInPlace`, in postFetch.
60+ hash = "sha256-KF9YQ6/FIfUQTJCAMgfIqnb/D8mdMbCC/tJvfYlSkgI=";
61+ # TEMPORARY: The way upstream knows it's source version is explained above,
62+ # and without this upstream sets the version in ${python.sitePackages} as
63+ # 0.61.0dev0, which causes dependent packages fail to find a valid
64+ # version of numba.
65+ postFetch = ''
66+ substituteInPlace $out/numba/_version.py \
67+ --replace-fail \
68+ 'git_refnames = " (tag: ${version})"' \
69+ 'git_refnames = " (tag: 0.61.0, release0.61)"'
70+ '';
71 };
7273 postPatch = ''
···8182 build-system = [
83 setuptools
084 ];
8586 nativeBuildInputs = lib.optionals cudaSupport [
···88 cudaPackages.cuda_nvcc
89 ];
9091+ buildInputs = [
92+ # Not propagating it, because it numba can work with either numpy_2 or numpy_1
93+ numpy_2
94+ ] ++ lib.optionals cudaSupport [ cudaPackages.cuda_cudart ];
9596 dependencies = [
097 llvmlite
98 setuptools
99 ] ++ lib.optionals (pythonOlder "3.9") [ importlib-metadata ];
···116 })
117 ];
118119+ nativeCheckInputs = [
120+ pytestCheckHook
121+ ];
0000000122123+ preCheck = ''
124+ export HOME="$(mktemp -d)"
125+ # https://github.com/NixOS/nixpkgs/issues/255262
126+ cd $out
127 '';
128129+ pytestFlagsArray = lib.optionals (!doFullCheck) [
130+ # These are the most basic tests. Running all tests is too expensive, and
131+ # some of them fail (also differently on different platforms), so it will
132+ # be too hard to maintain such a `disabledTests` list.
133+ "${python.sitePackages}/numba/tests/test_usecases.py"
134+ ];
135+136+ disabledTestPaths = lib.optionals (!testsWithoutSandbox) [
137+ # See NOTE near passthru.tests.withoutSandbox
138+ "${python.sitePackages}/numba/cuda/tests"
139+ ];
140+141 pythonImportsCheck = [ "numba" ];
142143 passthru.testers.cuda-detect =
···149 '';
150 passthru.tests = {
151 # CONTRIBUTOR NOTE: numba also contains CUDA tests, though these cannot be run in
152+ # this sandbox environment. Consider building the derivation below with
153+ # --no-sandbox to get a view of how many tests succeed outside the sandbox.
154+ withoutSandbox = numba.override {
155+ doFullCheck = true;
156+ cudaSupport = true;
157+ testsWithoutSandbox = true;
158+ };
159+ withSandbox = numba.override {
160+ cudaSupport = false;
161+ doFullCheck = true;
162+ testsWithoutSandbox = false;
163+ };
00000164 };
165166 meta = with lib; {