1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
{ lib
, stdenv
, pythonAtLeast
, pythonOlder
, fetchPypi
, python
, buildPythonPackage
, setuptools
, numpy
, llvmlite
, libcxx
, importlib-metadata
, substituteAll
# CUDA-only dependencies:
, addOpenGLRunpath ? null
, cudaPackages ? {}
# CUDA flags:
, cudaSupport ? false
}:
let
inherit (cudaPackages) cudatoolkit;
in buildPythonPackage rec {
version = "0.56.2";
pname = "numba";
format = "setuptools";
disabled = pythonOlder "3.6" || pythonAtLeast "3.11";
src = fetchPypi {
inherit pname version;
hash = "sha256-NJLwpdCeJX/FIfU3emxrkH7sGSDRRznwskWLnSmUalo=";
};
postPatch = ''
substituteInPlace setup.py \
--replace "setuptools<60" "setuptools"
'';
NIX_CFLAGS_COMPILE = lib.optionalString stdenv.isDarwin "-I${lib.getDev libcxx}/include/c++/v1";
nativeBuildInputs = lib.optionals cudaSupport [
addOpenGLRunpath
];
propagatedBuildInputs = [
numpy
llvmlite
setuptools
] ++ lib.optionals (pythonOlder "3.9") [
importlib-metadata
] ++ lib.optionals cudaSupport [
cudatoolkit
cudatoolkit.lib
];
patches = lib.optionals cudaSupport [
(substituteAll {
src = ./cuda_path.patch;
cuda_toolkit_path = cudatoolkit;
cuda_toolkit_lib_path = cudatoolkit.lib;
})
];
postFixup = lib.optionalString cudaSupport ''
find $out -type f \( -name '*.so' -or -name '*.so.*' \) | while read lib; do
addOpenGLRunpath "$lib"
patchelf --set-rpath "${cudatoolkit}/lib:${cudatoolkit.lib}/lib:$(patchelf --print-rpath "$lib")" "$lib"
done
'';
# Copy test script into $out and run the test suite.
checkPhase = ''
${python.interpreter} -m numba.runtests
'';
# ImportError: cannot import name '_typeconv'
doCheck = false;
pythonImportsCheck = [
"numba"
];
meta = with lib; {
description = "Compiling Python code using LLVM";
homepage = "https://numba.pydata.org/";
license = licenses.bsd2;
maintainers = with maintainers; [ fridh ];
};
}
|