python3Packages.setuptools-rust: fix cross build for all setuptools-rust based packages (#467817)
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
rustPlatform,
|
||||
cargo,
|
||||
rustc,
|
||||
setuptoolsRustBuildHook,
|
||||
setuptools-rust,
|
||||
openssl,
|
||||
Security ? null,
|
||||
isPyPy,
|
||||
@@ -74,9 +74,12 @@ buildPythonPackage rec {
|
||||
|
||||
cargoRoot = "src/rust";
|
||||
|
||||
build-system = [
|
||||
setuptools-rust
|
||||
];
|
||||
|
||||
nativeBuildInputs = [
|
||||
rustPlatform.cargoSetupHook
|
||||
setuptoolsRustBuildHook
|
||||
cargo
|
||||
rustc
|
||||
pkg-config
|
||||
|
||||
@@ -442,20 +442,6 @@ in
|
||||
} ./setuptools-build-hook.sh
|
||||
) { };
|
||||
|
||||
setuptoolsRustBuildHook = callPackage (
|
||||
{ makePythonHook, setuptools-rust }:
|
||||
makePythonHook {
|
||||
name = "setuptools-rust-setup-hook";
|
||||
propagatedBuildInputs = [ setuptools-rust ];
|
||||
substitutions = {
|
||||
pyLibDir = "${python}/lib/${python.libPrefix}";
|
||||
cargoBuildTarget = stdenv.hostPlatform.rust.rustcTargetSpec;
|
||||
cargoLinkerVar = stdenv.hostPlatform.rust.cargoEnvVarTarget;
|
||||
targetLinker = "${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc";
|
||||
};
|
||||
} ./setuptools-rust-hook.sh
|
||||
) { };
|
||||
|
||||
unittestCheckHook = callPackage (
|
||||
{ makePythonHook }:
|
||||
makePythonHook {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
lib,
|
||||
stdenv,
|
||||
buildPythonPackage,
|
||||
fetchPypi,
|
||||
maturin,
|
||||
@@ -11,8 +12,9 @@
|
||||
setuptools,
|
||||
setuptools-rust,
|
||||
setuptools-scm,
|
||||
replaceVars,
|
||||
targetPackages,
|
||||
}:
|
||||
|
||||
buildPythonPackage rec {
|
||||
pname = "setuptools-rust";
|
||||
version = "1.12.0";
|
||||
@@ -40,6 +42,23 @@ buildPythonPackage rec {
|
||||
|
||||
doCheck = false;
|
||||
|
||||
# integrate the setup hook to set up the build environment for cross compilation
|
||||
# this hook is automatically propagated to consumers using setuptools-rust as build-system
|
||||
#
|
||||
# Only include the setup hook if targetPackages.python3 is defined.
|
||||
# targetPackages.python3 is not always available, for example when including
|
||||
# setuptools-rust via buildInputs instead of nativeBuildInputs or building it directly.
|
||||
setupHook =
|
||||
if !(targetPackages ? python3) then
|
||||
null
|
||||
else
|
||||
replaceVars ./setuptools-rust-hook.sh {
|
||||
pyLibDir = "${targetPackages.python3}/lib/${targetPackages.python3.libPrefix}";
|
||||
cargoBuildTarget = stdenv.targetPlatform.rust.rustcTargetSpec;
|
||||
cargoLinkerVar = stdenv.targetPlatform.rust.cargoEnvVarTarget;
|
||||
targetLinker = "${targetPackages.stdenv.cc}/bin/${targetPackages.stdenv.cc.targetPrefix}cc";
|
||||
};
|
||||
|
||||
passthru.tests = {
|
||||
pyo3 = maturin.tests.pyo3.override {
|
||||
format = "setuptools";
|
||||
|
||||
@@ -439,6 +439,7 @@ mapAliases {
|
||||
sentry-sdk_2 = throw "'sentry-sdk_2' has been renamed to/replaced by 'sentry-sdk'"; # Converted to throw 2025-10-29
|
||||
setuptools_dso = throw "'setuptools_dso' has been renamed to/replaced by 'setuptools-dso'"; # Converted to throw 2025-10-29
|
||||
setuptools_scm = throw "'setuptools_scm' has been renamed to/replaced by 'setuptools-scm'"; # Converted to throw 2025-10-29
|
||||
setuptoolsRustBuildHook = lib.warn "setuptoolsRustBuildHook is deprecated. Instead, include 'setuptools-rust' via 'build-system'" setuptools-rust; # added 2025-12-07
|
||||
setuptoolsTrial = throw "'setuptoolsTrial' has been renamed to/replaced by 'setuptools-trial'"; # Converted to throw 2025-10-29
|
||||
sharkiqpy = throw "'sharkiqpy' has been renamed to/replaced by 'sharkiq'"; # Converted to throw 2025-10-29
|
||||
shippai = throw "shippai has been removed because the upstream repository was archived in 2023"; # added 2025-07-09
|
||||
|
||||
Reference in New Issue
Block a user