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