Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at python-updates 93 lines 2.4 kB view raw
1{ 2 lib, 3 stdenv, 4 buildPythonPackage, 5 fetchPypi, 6 maturin, 7 rustPlatform, 8 rustc, 9 cargo, 10 semantic-version, 11 setuptools, 12 setuptools-rust, 13 setuptools-scm, 14 replaceVars, 15 python, 16 targetPackages, 17}: 18buildPythonPackage rec { 19 pname = "setuptools-rust"; 20 version = "1.12.0"; 21 pyproject = true; 22 23 src = fetchPypi { 24 pname = "setuptools_rust"; 25 inherit version; 26 hash = "sha256-2UqT8Ml3UcFwFFZfB73DJL7kXTls0buoPY56+SuUXww="; 27 }; 28 29 build-system = [ 30 setuptools 31 setuptools-scm 32 ]; 33 34 dependencies = [ 35 semantic-version 36 setuptools 37 ]; 38 39 pythonImportsCheck = [ "setuptools_rust" ]; 40 41 doCheck = false; 42 43 # integrate the setup hook to set up the build environment for cross compilation 44 # this hook is automatically propagated to consumers using setuptools-rust as build-system 45 # 46 # No need for the setup hook when python.pythonOnTargetForTarget is empty, 47 # or when the host & target platforms are the same. 48 # 49 # python.pythonOnTargetForTarget is not always available, for example in 50 # pkgsLLVM.python3.pythonOnTargetForTarget. cross build with pkgsLLVM should not be affected. 51 setupHook = 52 if 53 python.pythonOnTargetForTarget == { } 54 || (lib.systems.equals stdenv.hostPlatform stdenv.targetPlatform) 55 then 56 null 57 else 58 replaceVars ./setuptools-rust-hook.sh { 59 pyLibDir = "${python.pythonOnTargetForTarget}/lib/${python.pythonOnTargetForTarget.libPrefix}"; 60 cargoBuildTarget = stdenv.targetPlatform.rust.rustcTargetSpec; 61 cargoLinkerVar = stdenv.targetPlatform.rust.cargoEnvVarTarget; 62 targetLinker = "${targetPackages.stdenv.cc}/bin/${targetPackages.stdenv.cc.targetPrefix}cc"; 63 }; 64 65 passthru.tests = { 66 pyo3 = maturin.tests.pyo3.override { 67 buildAndTestSubdir = null; 68 69 nativeBuildInputs = [ 70 setuptools-rust 71 ] 72 ++ [ 73 rustPlatform.cargoSetupHook 74 cargo 75 rustc 76 ]; 77 78 preConfigure = '' 79 # sourceRoot puts Cargo.lock in the wrong place due to the 80 # example setup. 81 cd examples/word-count 82 ''; 83 }; 84 }; 85 86 meta = { 87 description = "Setuptools plugin for Rust support"; 88 homepage = "https://github.com/PyO3/setuptools-rust"; 89 changelog = "https://github.com/PyO3/setuptools-rust/releases/tag/v${version}"; 90 license = lib.licenses.mit; 91 maintainers = [ ]; 92 }; 93}