rustPlatform.maturinBuildHook: init
This build hook can be used to build Python packages using maturin.
This commit is contained in:
parent
7876d1c252
commit
160cf87086
@ -4,6 +4,7 @@
|
|||||||
, diffutils
|
, diffutils
|
||||||
, lib
|
, lib
|
||||||
, makeSetupHook
|
, makeSetupHook
|
||||||
|
, maturin
|
||||||
, rust
|
, rust
|
||||||
, stdenv
|
, stdenv
|
||||||
, target ? rust.toRustTargetSpec stdenv.hostPlatform
|
, target ? rust.toRustTargetSpec stdenv.hostPlatform
|
||||||
@ -62,4 +63,14 @@ in {
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
} ./cargo-setup-hook.sh) {};
|
} ./cargo-setup-hook.sh) {};
|
||||||
|
|
||||||
|
maturinBuildHook = callPackage ({ }:
|
||||||
|
makeSetupHook {
|
||||||
|
name = "maturin-build-hook.sh";
|
||||||
|
deps = [ cargo maturin ];
|
||||||
|
substitutions = {
|
||||||
|
inherit ccForBuild ccForHost cxxForBuild cxxForHost
|
||||||
|
rustBuildPlatform rustTargetPlatform rustTargetPlatformSpec;
|
||||||
|
};
|
||||||
|
} ./maturin-build-hook.sh) {};
|
||||||
}
|
}
|
||||||
|
39
pkgs/build-support/rust/hooks/maturin-build-hook.sh
Normal file
39
pkgs/build-support/rust/hooks/maturin-build-hook.sh
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
maturinBuildHook() {
|
||||||
|
echo "Executing maturinBuildHook"
|
||||||
|
|
||||||
|
runHook preBuild
|
||||||
|
|
||||||
|
if [ ! -z "${buildAndTestSubdir-}" ]; then
|
||||||
|
pushd "${buildAndTestSubdir}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
(
|
||||||
|
set -x
|
||||||
|
env \
|
||||||
|
"CC_@rustBuildPlatform@=@ccForBuild@" \
|
||||||
|
"CXX_@rustBuildPlatform@=@cxxForBuild@" \
|
||||||
|
"CC_@rustTargetPlatform@=@ccForHost@" \
|
||||||
|
"CXX_@rustTargetPlatform@=@cxxForHost@" \
|
||||||
|
maturin build \
|
||||||
|
--cargo-extra-args="-j $NIX_BUILD_CORES --frozen" \
|
||||||
|
--target @rustTargetPlatformSpec@ \
|
||||||
|
--manylinux off \
|
||||||
|
--strip \
|
||||||
|
--release \
|
||||||
|
${maturinBuildFlags-}
|
||||||
|
)
|
||||||
|
|
||||||
|
runHook postBuild
|
||||||
|
|
||||||
|
if [ ! -z "${buildAndTestSubdir-}" ]; then
|
||||||
|
popd
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Move the wheel to dist/ so that regular Python tooling can find it.
|
||||||
|
mkdir -p dist
|
||||||
|
mv target/wheels/*.whl dist/
|
||||||
|
|
||||||
|
echo "Finished maturinBuildHook"
|
||||||
|
}
|
||||||
|
|
||||||
|
buildPhase=maturinBuildHook
|
@ -26,5 +26,5 @@ rec {
|
|||||||
# Hooks
|
# Hooks
|
||||||
inherit (callPackage ../../../build-support/rust/hooks {
|
inherit (callPackage ../../../build-support/rust/hooks {
|
||||||
inherit cargo;
|
inherit cargo;
|
||||||
}) cargoBuildHook cargoSetupHook;
|
}) cargoBuildHook cargoSetupHook maturinBuildHook;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user