nixpkgs-suyu/pkgs/development/python-modules/numba/default.nix
Frederik Rietdijk 1d63f89caa cudaPackages: overhaul of how we package cuda packages
There are many different versions of the `cudatoolkit` and related
cuda packages, and it can be tricky to ensure they remain compatible.

- `cudaPackages` is now a package set with `cudatoolkit`, `cudnn`, `cutensor`, `nccl`, as well as `cudatoolkit` split into smaller packages ("redist");
- expressions should now use `cudaPackages` as parameter instead of the individual cuda packages;
- `makeScope` is now used, so it is possible to use `.overrideScope'` to set e.g. a different `cudnn` version;
- `release-cuda.nix` is introduced to easily evaluate cuda packages using hydra.
2022-04-09 08:50:22 +02:00

80 lines
1.9 KiB
Nix

{ lib
, stdenv
, pythonAtLeast
, pythonOlder
, fetchPypi
, python
, buildPythonPackage
, numpy
, llvmlite
, setuptools
, libcxx
, substituteAll
# CUDA-only dependencies:
, addOpenGLRunpath ? null
, cudaPackages ? {}
# CUDA flags:
, cudaSupport ? false
}:
let
inherit (cudaPackages) cudatoolkit;
in buildPythonPackage rec {
version = "0.55.1";
pname = "numba";
disabled = pythonOlder "3.6" || pythonAtLeast "3.10";
src = fetchPypi {
inherit pname version;
sha256 = "sha256-A+kGmiZm0chPk7ANvXFvuP7d6Lssbvr6LwSEKkZELqM=";
};
postPatch = ''
# numpy
substituteInPlace setup.py \
--replace "1.22" "2"
substituteInPlace numba/__init__.py \
--replace "(1, 21)" "(2, 0)"
'';
NIX_CFLAGS_COMPILE = lib.optionalString stdenv.isDarwin "-I${lib.getDev libcxx}/include/c++/v1";
propagatedBuildInputs = [ numpy llvmlite setuptools ] ++ lib.optionals cudaSupport [ cudatoolkit cudatoolkit.lib ];
nativeBuildInputs = lib.optional cudaSupport [ addOpenGLRunpath ];
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; {
homepage = "https://numba.pydata.org/";
license = licenses.bsd2;
description = "Compiling Python code using LLVM";
maintainers = with maintainers; [ fridh ];
};
}