From 4e7188c39a4b4c5d21134ae4496af0c799a8a264 Mon Sep 17 00:00:00 2001 From: Theodore Ni <3806110+tjni@users.noreply.github.com> Date: Fri, 28 Jul 2023 00:10:41 -0700 Subject: [PATCH] python3.pkgs.buildPythonPackage: disable conflict check for setuptools and wheel We can do this automatically for packages we know cannot use the conflict check hook when it would lead to infinite recursion. --- .../python/mk-python-derivation.nix | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/pkgs/development/interpreters/python/mk-python-derivation.nix b/pkgs/development/interpreters/python/mk-python-derivation.nix index b848c85e3b28..8a75dbf43a74 100644 --- a/pkgs/development/interpreters/python/mk-python-derivation.nix +++ b/pkgs/development/interpreters/python/mk-python-derivation.nix @@ -171,6 +171,10 @@ let "tomli" ]); + isSetuptoolsDependency = builtins.elem (attrs.pname or null) [ + "setuptools" "wheel" + ]; + # Keep extra attributes from `attrs`, e.g., `patchPhase', etc. self = toPythonModule (stdenv.mkDerivation ((builtins.removeAttrs attrs [ "disabled" "checkPhase" "checkInputs" "nativeCheckInputs" "doCheck" "doInstallCheck" "dontWrapPythonPrograms" "catchConflicts" "format" @@ -184,10 +188,15 @@ let wrapPython ensureNewerSourcesForZipFilesHook # move to wheel installer (pip) or builder (setuptools, flit, ...)? pythonRemoveTestsDirHook - ] ++ lib.optionals (catchConflicts && !isBootstrapPackage) [ - # When building a package that is also part of the bootstrap chain, we - # must ignore conflicts after installation, because there will be one with - # the package in the bootstrap. + ] ++ lib.optionals (catchConflicts && !isBootstrapPackage && !isSetuptoolsDependency) [ + # + # 1. When building a package that is also part of the bootstrap chain, we + # must ignore conflicts after installation, because there will be one with + # the package in the bootstrap. + # + # 2. When a package is a dependency of setuptools, we must ignore conflicts + # because the hook that checks for conflicts uses setuptools. + # pythonCatchConflictsHook ] ++ lib.optionals removeBinBytecode [ pythonRemoveBinBytecodeHook