python3.pkgs.buildPythonPackage: switch to PyPA build and installer

This commit is contained in:
Theodore Ni 2023-07-27 23:29:57 -07:00 committed by Frederik Rietdijk
parent e8cca499a8
commit 6c85fff302

View File

@ -12,8 +12,8 @@
, update-python-libraries , update-python-libraries
, setuptools , setuptools
, flitBuildHook , flitBuildHook
, pipBuildHook , pypaBuildHook
, pipInstallHook , pypaInstallHook
, pythonCatchConflictsHook , pythonCatchConflictsHook
, pythonImportsCheckHook , pythonImportsCheckHook
, pythonNamespacesHook , pythonNamespacesHook
@ -161,6 +161,16 @@ let
in inputs: builtins.map (checkDrv) inputs; in inputs: builtins.map (checkDrv) inputs;
isBootstrapInstallPackage = builtins.elem (attrs.pname or null) [
"flit-core" "installer"
];
isBootstrapPackage = isBootstrapInstallPackage || builtins.elem (attrs.pname or null) ([
"build" "packaging" "pyproject-hooks" "wheel"
] ++ lib.optionals (python.pythonOlder "3.11") [
"tomli"
]);
# Keep extra attributes from `attrs`, e.g., `patchPhase', etc. # Keep extra attributes from `attrs`, e.g., `patchPhase', etc.
self = toPythonModule (stdenv.mkDerivation ((builtins.removeAttrs attrs [ self = toPythonModule (stdenv.mkDerivation ((builtins.removeAttrs attrs [
"disabled" "checkPhase" "checkInputs" "nativeCheckInputs" "doCheck" "doInstallCheck" "dontWrapPythonPrograms" "catchConflicts" "format" "disabled" "checkPhase" "checkInputs" "nativeCheckInputs" "doCheck" "doInstallCheck" "dontWrapPythonPrograms" "catchConflicts" "format"
@ -174,7 +184,10 @@ let
wrapPython wrapPython
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 && !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.
pythonCatchConflictsHook pythonCatchConflictsHook
] ++ lib.optionals removeBinBytecode [ ] ++ lib.optionals removeBinBytecode [
pythonRemoveBinBytecodeHook pythonRemoveBinBytecodeHook
@ -184,15 +197,26 @@ let
setuptoolsBuildHook setuptoolsBuildHook
] ++ lib.optionals (format == "flit") [ ] ++ lib.optionals (format == "flit") [
flitBuildHook flitBuildHook
] ++ lib.optionals (format == "pyproject") [ ] ++ lib.optionals (format == "pyproject") [(
pipBuildHook if isBootstrapPackage then
] ++ lib.optionals (format == "wheel") [ pypaBuildHook.override {
inherit (python.pythonForBuild.pkgs.bootstrap) build;
wheel = null;
}
else
pypaBuildHook
)] ++ lib.optionals (format == "wheel") [
wheelUnpackHook wheelUnpackHook
] ++ lib.optionals (format == "egg") [ ] ++ lib.optionals (format == "egg") [
eggUnpackHook eggBuildHook eggInstallHook eggUnpackHook eggBuildHook eggInstallHook
] ++ lib.optionals (!(format == "other") || dontUsePipInstall) [ ] ++ lib.optionals (format != "other") [(
pipInstallHook if isBootstrapInstallPackage then
] ++ lib.optionals (stdenv.buildPlatform == stdenv.hostPlatform) [ pypaInstallHook.override {
inherit (python.pythonForBuild.pkgs.bootstrap) installer;
}
else
pypaInstallHook
)] ++ lib.optionals (stdenv.buildPlatform == stdenv.hostPlatform) [
# This is a test, however, it should be ran independent of the checkPhase and checkInputs # This is a test, however, it should be ran independent of the checkPhase and checkInputs
pythonImportsCheckHook pythonImportsCheckHook
] ++ lib.optionals (python.pythonAtLeast "3.3") [ ] ++ lib.optionals (python.pythonAtLeast "3.3") [