2021-01-24 00:29:22 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
2021-03-02 01:50:41 +00:00
|
|
|
, pythonAtLeast
|
2020-02-13 07:13:50 +00:00
|
|
|
, pythonOlder
|
2017-12-30 11:25:04 +00:00
|
|
|
, fetchPypi
|
2016-11-14 11:20:13 +00:00
|
|
|
, python
|
|
|
|
, buildPythonPackage
|
2022-09-15 21:22:50 +00:00
|
|
|
, setuptools
|
2016-11-14 11:20:13 +00:00
|
|
|
, numpy
|
|
|
|
, llvmlite
|
|
|
|
, libcxx
|
2022-09-15 21:22:50 +00:00
|
|
|
, importlib-metadata
|
2022-04-04 15:10:31 +00:00
|
|
|
, substituteAll
|
2022-11-06 21:13:45 +00:00
|
|
|
, runCommand
|
|
|
|
, fetchpatch
|
2022-04-04 15:10:31 +00:00
|
|
|
|
|
|
|
# CUDA-only dependencies:
|
|
|
|
, addOpenGLRunpath ? null
|
2022-04-03 09:19:04 +00:00
|
|
|
, cudaPackages ? {}
|
2016-11-14 11:20:13 +00:00
|
|
|
|
2022-04-04 15:10:31 +00:00
|
|
|
# CUDA flags:
|
|
|
|
, cudaSupport ? false
|
|
|
|
}:
|
2022-04-03 09:19:04 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
inherit (cudaPackages) cudatoolkit;
|
|
|
|
in buildPythonPackage rec {
|
2022-11-06 21:13:45 +00:00
|
|
|
version = "0.56.4";
|
2017-05-27 09:25:35 +00:00
|
|
|
pname = "numba";
|
2022-09-15 21:22:50 +00:00
|
|
|
format = "setuptools";
|
2022-05-23 11:09:45 +00:00
|
|
|
disabled = pythonOlder "3.6" || pythonAtLeast "3.11";
|
2016-11-14 11:20:13 +00:00
|
|
|
|
2017-12-30 11:25:04 +00:00
|
|
|
src = fetchPypi {
|
|
|
|
inherit pname version;
|
2022-11-06 21:13:45 +00:00
|
|
|
hash = "sha256-Mtn+9BLIFIPX7+DOts9NMxD96LYkqc7MoA95BXOslu4=";
|
2016-11-14 11:20:13 +00:00
|
|
|
};
|
|
|
|
|
2021-08-26 19:32:39 +00:00
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace setup.py \
|
2022-09-15 21:22:50 +00:00
|
|
|
--replace "setuptools<60" "setuptools"
|
2021-08-26 19:32:39 +00:00
|
|
|
'';
|
|
|
|
|
llvmPackages: Multuple outputs for everythting
Also begin to start work on cross compilation, though that will have to
be finished later.
The patches are based on the first version of
https://reviews.llvm.org/D99484. It's very annoying to do the
back-porting but the review has uncovered nothing super major so I'm
fine sticking with what I've got.
Beyond making the outputs work, I also strove to re-sync the packages,
as they have been drifting pointlessly apart for some time.
----
Other misc notes, highly incomplete
- lvm-config-native and llvm-config are put in `dev` because they are
tools just for build time.
- Clang no longer has an lld dep. That was introduced in
db29857eb391ed002046090851a44c452b80bdbd, but if clang needs help
finding lld when it is used we should just pass it flags / put in the
resource dir. Providing it at build time increases critical path
length for no good reason.
----
A note on `nativeCC`:
`stdenv` takes tools from the previous stage, so:
1. `pkgsBuildBuild`: `(?1, x, x)`
2. `pkgsBuildBuild.stdenv.cc`: `(?0, ?1, x)`
while:
1. `pkgsBuildBuild`: `(?1, x, x)`
2. `pkgsBuildBuild.targetPackages`: `(x, x, ?2)`
3. `pkgsBuildBuild.targetPackages.stdenv.cc`: `(?1, x, x)`
2020-10-15 08:23:57 +00:00
|
|
|
NIX_CFLAGS_COMPILE = lib.optionalString stdenv.isDarwin "-I${lib.getDev libcxx}/include/c++/v1";
|
2016-11-14 11:20:13 +00:00
|
|
|
|
2022-10-06 16:38:53 +00:00
|
|
|
nativeBuildInputs = lib.optionals cudaSupport [
|
2022-09-15 21:22:50 +00:00
|
|
|
addOpenGLRunpath
|
|
|
|
];
|
|
|
|
|
2022-05-23 11:09:45 +00:00
|
|
|
propagatedBuildInputs = [
|
|
|
|
numpy
|
|
|
|
llvmlite
|
|
|
|
setuptools
|
2022-09-15 21:22:50 +00:00
|
|
|
] ++ lib.optionals (pythonOlder "3.9") [
|
|
|
|
importlib-metadata
|
2022-05-23 11:09:45 +00:00
|
|
|
] ++ lib.optionals cudaSupport [
|
|
|
|
cudatoolkit
|
|
|
|
cudatoolkit.lib
|
|
|
|
];
|
2021-08-26 19:32:39 +00:00
|
|
|
|
2022-11-06 21:13:45 +00:00
|
|
|
patches = [
|
|
|
|
# fix failure in test_cache_invalidate (numba.tests.test_caching.TestCache)
|
|
|
|
# remove when upgrading past version 0.56
|
|
|
|
(fetchpatch {
|
|
|
|
name = "fix-test-cache-invalidate-readonly.patch";
|
|
|
|
url = "https://github.com/numba/numba/commit/993e8c424055a7677b2755b184fc9e07549713b9.patch";
|
|
|
|
hash = "sha256-IhIqRLmP8gazx+KWIyCxZrNLMT4jZT8CWD3KcH4KjOo=";
|
|
|
|
})
|
|
|
|
] ++ lib.optionals cudaSupport [
|
2022-04-04 15:10:31 +00:00
|
|
|
(substituteAll {
|
|
|
|
src = ./cuda_path.patch;
|
|
|
|
cuda_toolkit_path = cudatoolkit;
|
|
|
|
cuda_toolkit_lib_path = cudatoolkit.lib;
|
|
|
|
})
|
|
|
|
];
|
2016-11-14 11:20:13 +00:00
|
|
|
|
2022-04-04 15:10:31 +00:00
|
|
|
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-08-26 19:32:39 +00:00
|
|
|
|
2022-11-06 21:13:45 +00:00
|
|
|
# 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
|
2016-11-14 11:20:13 +00:00
|
|
|
checkPhase = ''
|
2022-11-06 21:13:45 +00:00
|
|
|
runHook preCheck
|
2021-08-26 19:32:39 +00:00
|
|
|
|
2022-11-06 21:13:45 +00:00
|
|
|
pushd $(mktemp -d)
|
|
|
|
HOME=. ${python.interpreter} -m numba.runtests -m $NIX_BUILD_CORES numba.tests.test_usecases
|
|
|
|
popd
|
|
|
|
|
|
|
|
runHook postCheck
|
|
|
|
'';
|
2016-11-14 11:20:13 +00:00
|
|
|
|
2022-05-23 11:09:45 +00:00
|
|
|
pythonImportsCheck = [
|
|
|
|
"numba"
|
|
|
|
];
|
2021-08-26 19:32:39 +00:00
|
|
|
|
2022-11-06 21:13:45 +00:00
|
|
|
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
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2021-01-24 00:29:22 +00:00
|
|
|
meta = with lib; {
|
2022-05-23 11:09:45 +00:00
|
|
|
description = "Compiling Python code using LLVM";
|
2021-08-26 19:32:39 +00:00
|
|
|
homepage = "https://numba.pydata.org/";
|
2021-01-24 00:29:22 +00:00
|
|
|
license = licenses.bsd2;
|
|
|
|
maintainers = with maintainers; [ fridh ];
|
2016-11-14 11:20:13 +00:00
|
|
|
};
|
2017-02-13 10:00:12 +00:00
|
|
|
}
|