mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-03-14 08:26:37 +01:00
Prior to this change all python packages using `setuptools-rust` were broken when cross compiled as they built binaries for the build platform instead of for the host platform. The setuptoolsRustBuildHook hook would have to be included as a native build input instead of the `setuptools-rust` package, but practically wasn't used anywhere. This change makes it so that `setuptoolsRustBuildHook` becomes unnecessary, and instead `setuptools-rust` propagates a setup-hook directly setting up the build environment, similar to how cmake does it when included via nativeBuildInputs. This change fixes cross on all packages using `setuptools-rust` as a build-system.
20 lines
734 B
Bash
20 lines
734 B
Bash
# shellcheck shell=bash
|
|
|
|
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)
|