mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-25 16:33:15 +00:00
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
|
||||
, lib
|
||||
, makeSetupHook
|
||||
, maturin
|
||||
, rust
|
||||
, stdenv
|
||||
, target ? rust.toRustTargetSpec stdenv.hostPlatform
|
||||
@ -62,4 +63,14 @@ in {
|
||||
'';
|
||||
};
|
||||
} ./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
|
||||
inherit (callPackage ../../../build-support/rust/hooks {
|
||||
inherit cargo;
|
||||
}) cargoBuildHook cargoSetupHook;
|
||||
}) cargoBuildHook cargoSetupHook maturinBuildHook;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user