buildPython*: wrap setuptools in hook for catching conflicts

By default buildPython* runs a hook for detecting conflicting packages.
This hook needs pkg_resources which is part of setuptools.

Before this commit, setuptools was simply added to the build. This meant
that when setuptools was forgotten to be added to the build, the build
and installation would still succeed because of this package from the
hook. During runtime (and cross-compilation) one would notice the
missing package.
This commit is contained in:
Frederik Rietdijk
2022-08-09 18:48:56 +02:00
committed by Frederik Rietdijk
parent 2444caed5a
commit 13bb0f49f7
3 changed files with 3 additions and 4 deletions

View File

@@ -92,9 +92,8 @@ in rec {
pythonCatchConflictsHook = callPackage ({ setuptools }: pythonCatchConflictsHook = callPackage ({ setuptools }:
makeSetupHook { makeSetupHook {
name = "python-catch-conflicts-hook"; name = "python-catch-conflicts-hook";
deps = [ setuptools ];
substitutions = { substitutions = {
inherit pythonInterpreter; inherit pythonInterpreter pythonSitePackages setuptools;
catchConflicts=../catch_conflicts/catch_conflicts.py; catchConflicts=../catch_conflicts/catch_conflicts.py;
}; };
} ./python-catch-conflicts-hook.sh) {}; } ./python-catch-conflicts-hook.sh) {};

View File

@@ -2,7 +2,7 @@
echo "Sourcing python-catch-conflicts-hook.sh" echo "Sourcing python-catch-conflicts-hook.sh"
pythonCatchConflictsPhase() { pythonCatchConflictsPhase() {
@pythonInterpreter@ @catchConflicts@ PYTHONPATH="@setuptools@/@pythonSitePackages@:$PYTHONPATH" @pythonInterpreter@ @catchConflicts@
} }
if [ -z "${dontUsePythonCatchConflicts-}" ]; then if [ -z "${dontUsePythonCatchConflicts-}" ]; then

View File

@@ -126,7 +126,7 @@ let
ensureNewerSourcesForZipFilesHook # move to wheel installer (pip) or builder (setuptools, flit, ...)? ensureNewerSourcesForZipFilesHook # move to wheel installer (pip) or builder (setuptools, flit, ...)?
pythonRemoveTestsDirHook pythonRemoveTestsDirHook
] ++ lib.optionals catchConflicts [ ] ++ lib.optionals catchConflicts [
setuptools pythonCatchConflictsHook pythonCatchConflictsHook
] ++ lib.optionals removeBinBytecode [ ] ++ lib.optionals removeBinBytecode [
pythonRemoveBinBytecodeHook pythonRemoveBinBytecodeHook
] ++ lib.optionals (lib.hasSuffix "zip" (attrs.src.name or "")) [ ] ++ lib.optionals (lib.hasSuffix "zip" (attrs.src.name or "")) [