2021-02-05 17:12:51 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
2021-03-09 03:18:52 +00:00
|
|
|
, pythonAtLeast
|
2020-04-24 23:36:52 +00:00
|
|
|
, pythonOlder
|
|
|
|
, fetchPypi
|
|
|
|
, python
|
|
|
|
, buildPythonPackage
|
|
|
|
, numpy
|
|
|
|
, llvmlite
|
2021-02-22 21:28:39 +00:00
|
|
|
, setuptools
|
2020-04-24 23:36:52 +00:00
|
|
|
, libcxx
|
2022-04-15 01:41:22 +00:00
|
|
|
, substituteAll
|
|
|
|
|
|
|
|
# CUDA-only dependencies:
|
|
|
|
, addOpenGLRunpath ? null
|
|
|
|
, cudaPackages ? {}
|
|
|
|
|
|
|
|
# CUDA flags:
|
|
|
|
, cudaSupport ? false
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
2022-04-15 01:41:22 +00:00
|
|
|
let
|
|
|
|
inherit (cudaPackages) cudatoolkit;
|
|
|
|
in buildPythonPackage rec {
|
2022-06-16 17:23:12 +00:00
|
|
|
version = "0.55.2";
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "numba";
|
2022-06-16 17:23:12 +00:00
|
|
|
disabled = pythonOlder "3.6" || pythonAtLeast "3.11";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchPypi {
|
|
|
|
inherit pname version;
|
2022-06-16 17:23:12 +00:00
|
|
|
hash = "sha256-5CjZ4R2bpZKEnMyfegCQA+t9MGEgB+Nlr+dDznEYxvQ=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-09-18 10:52:07 +00:00
|
|
|
postPatch = ''
|
2022-04-15 01:41:22 +00:00
|
|
|
# numpy
|
2021-09-18 10:52:07 +00:00
|
|
|
substituteInPlace setup.py \
|
2022-04-15 01:41:22 +00:00
|
|
|
--replace "1.22" "2"
|
2021-09-18 10:52:07 +00:00
|
|
|
|
|
|
|
substituteInPlace numba/__init__.py \
|
2022-04-15 01:41:22 +00:00
|
|
|
--replace "(1, 21)" "(2, 0)"
|
2021-09-18 10:52:07 +00:00
|
|
|
'';
|
|
|
|
|
2021-05-20 23:08:51 +00:00
|
|
|
NIX_CFLAGS_COMPILE = lib.optionalString stdenv.isDarwin "-I${lib.getDev libcxx}/include/c++/v1";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-06-16 17:23:12 +00:00
|
|
|
propagatedBuildInputs = [
|
|
|
|
numpy
|
|
|
|
llvmlite
|
|
|
|
setuptools
|
|
|
|
] ++ lib.optionals cudaSupport [
|
|
|
|
cudatoolkit
|
|
|
|
cudatoolkit.lib
|
|
|
|
];
|
2022-04-15 01:41:22 +00:00
|
|
|
|
2022-06-16 17:23:12 +00:00
|
|
|
nativeBuildInputs = lib.optional cudaSupport [
|
|
|
|
addOpenGLRunpath
|
|
|
|
];
|
2022-04-15 01:41:22 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
'';
|
2021-09-18 10:52:07 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
# Copy test script into $out and run the test suite.
|
|
|
|
checkPhase = ''
|
|
|
|
${python.interpreter} -m numba.runtests
|
|
|
|
'';
|
2021-09-18 10:52:07 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
# ImportError: cannot import name '_typeconv'
|
|
|
|
doCheck = false;
|
|
|
|
|
2022-06-16 17:23:12 +00:00
|
|
|
pythonImportsCheck = [
|
|
|
|
"numba"
|
|
|
|
];
|
2021-09-18 10:52:07 +00:00
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2022-06-16 17:23:12 +00:00
|
|
|
description = "Compiling Python code using LLVM";
|
2021-09-18 10:52:07 +00:00
|
|
|
homepage = "https://numba.pydata.org/";
|
2021-02-05 17:12:51 +00:00
|
|
|
license = licenses.bsd2;
|
|
|
|
maintainers = with maintainers; [ fridh ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|