diff --git a/pkgs/by-name/ce/ceph/old-python-packages/cryptography.nix b/pkgs/by-name/ce/ceph/old-python-packages/cryptography.nix index f10d285617a78..f6129b7c05547 100644 --- a/pkgs/by-name/ce/ceph/old-python-packages/cryptography.nix +++ b/pkgs/by-name/ce/ceph/old-python-packages/cryptography.nix @@ -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 diff --git a/pkgs/development/interpreters/python/hooks/default.nix b/pkgs/development/interpreters/python/hooks/default.nix index b3c97de303179..602030cae5e3c 100644 --- a/pkgs/development/interpreters/python/hooks/default.nix +++ b/pkgs/development/interpreters/python/hooks/default.nix @@ -441,20 +441,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 { diff --git a/pkgs/development/python-modules/setuptools-rust/default.nix b/pkgs/development/python-modules/setuptools-rust/default.nix index 087e5026c33b7..3e7dd96253f07 100644 --- a/pkgs/development/python-modules/setuptools-rust/default.nix +++ b/pkgs/development/python-modules/setuptools-rust/default.nix @@ -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"; diff --git a/pkgs/development/interpreters/python/hooks/setuptools-rust-hook.sh b/pkgs/development/python-modules/setuptools-rust/setuptools-rust-hook.sh similarity index 100% rename from pkgs/development/interpreters/python/hooks/setuptools-rust-hook.sh rename to pkgs/development/python-modules/setuptools-rust/setuptools-rust-hook.sh diff --git a/pkgs/top-level/python-aliases.nix b/pkgs/top-level/python-aliases.nix index 321d01c9ba128..c0afe1d97df40 100644 --- a/pkgs/top-level/python-aliases.nix +++ b/pkgs/top-level/python-aliases.nix @@ -437,6 +437,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