mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-18 19:51:17 +00:00
Merge pull request #212795 from Cynerd/setuptools-rust-hook
Setuptools rust hook for cross compilation
This commit is contained in:
commit
52d3944057
|
@ -160,6 +160,20 @@ in {
|
|||
};
|
||||
} ./setuptools-check-hook.sh) {};
|
||||
|
||||
setuptoolsRustBuildHook = callPackage ({ makePythonHook, setuptools-rust, rust }:
|
||||
makePythonHook {
|
||||
name = "setuptools-rust-setup-hook";
|
||||
propagatedBuildInputs = [ setuptools-rust ];
|
||||
substitutions = {
|
||||
pyLibDir = "${python}/lib/${python.libPrefix}";
|
||||
cargoBuildTarget = rust.toRustTargetSpec stdenv.hostPlatform;
|
||||
cargoLinkerVar = lib.toUpper (
|
||||
builtins.replaceStrings ["-"] ["_"] (
|
||||
rust.toRustTarget stdenv.hostPlatform));
|
||||
targetLinker = "${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc";
|
||||
};
|
||||
} ./setuptools-rust-hook.sh) {};
|
||||
|
||||
unittestCheckHook = callPackage ({ makePythonHook }:
|
||||
makePythonHook {
|
||||
name = "unittest-check-hook";
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
echo "Sourcing setuptools-rust-hook"
|
||||
|
||||
setuptoolsRustSetup() {
|
||||
# This can work only if rustPlatform.cargoSetupHook is also included
|
||||
if ! command -v cargoSetupPostPatchHook >/dev/null; then
|
||||
echo "ERROR: setuptools-rust has to be used alongside with rustPlatform.cargoSetupHook!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export PYO3_CROSS_LIB_DIR="@pyLibDir@"
|
||||
export CARGO_BUILD_TARGET=@cargoBuildTarget@
|
||||
# TODO theoretically setting linker should not be required because it is
|
||||
# already set in pkgs/build-support/rust/hooks/default.nix but build fails
|
||||
# on missing linker without this.
|
||||
export CARGO_TARGET_@cargoLinkerVar@_LINKER=@targetLinker@
|
||||
}
|
||||
|
||||
preConfigureHooks+=(setuptoolsRustSetup)
|
|
@ -6,7 +6,7 @@
|
|||
, rustPlatform
|
||||
, cargo
|
||||
, rustc
|
||||
, setuptools-rust
|
||||
, setuptoolsRustBuildHook
|
||||
, openssl
|
||||
, Security
|
||||
, isPyPy
|
||||
|
@ -54,7 +54,7 @@ buildPythonPackage rec {
|
|||
|
||||
nativeBuildInputs = [
|
||||
rustPlatform.cargoSetupHook
|
||||
setuptools-rust
|
||||
setuptoolsRustBuildHook
|
||||
cargo
|
||||
rustc
|
||||
pkg-config
|
||||
|
|
Loading…
Reference in a new issue