aboutsummaryrefslogtreecommitdiff
path: root/nixpkgs/pkgs/development/interpreters/python/mk-python-derivation.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/interpreters/python/mk-python-derivation.nix')
-rw-r--r--nixpkgs/pkgs/development/interpreters/python/mk-python-derivation.nix151
1 files changed, 78 insertions, 73 deletions
diff --git a/nixpkgs/pkgs/development/interpreters/python/mk-python-derivation.nix b/nixpkgs/pkgs/development/interpreters/python/mk-python-derivation.nix
index 22938a45585..df945c645a8 100644
--- a/nixpkgs/pkgs/development/interpreters/python/mk-python-derivation.nix
+++ b/nixpkgs/pkgs/development/interpreters/python/mk-python-derivation.nix
@@ -17,6 +17,7 @@
, pythonCatchConflictsHook
, pythonImportsCheckHook
, pythonNamespacesHook
+, pythonRecompileBytecodeHook
, pythonRemoveBinBytecodeHook
, pythonRemoveTestsDirHook
, setuptoolsBuildHook
@@ -104,77 +105,81 @@ let
"disabled" "checkPhase" "checkInputs" "doCheck" "doInstallCheck" "dontWrapPythonPrograms" "catchConflicts" "format"
]) // {
- name = namePrefix + name;
-
- nativeBuildInputs = [
- python
- wrapPython
- ensureNewerSourcesForZipFilesHook # move to wheel installer (pip) or builder (setuptools, flit, ...)?
- pythonRemoveTestsDirHook
- ] ++ lib.optionals catchConflicts [
- setuptools pythonCatchConflictsHook
- ] ++ lib.optionals removeBinBytecode [
- pythonRemoveBinBytecodeHook
- ] ++ lib.optionals (lib.hasSuffix "zip" (attrs.src.name or "")) [
- unzip
- ] ++ lib.optionals (format == "setuptools") [
- setuptoolsBuildHook
- ] ++ lib.optionals (format == "flit") [
- flitBuildHook
- ] ++ lib.optionals (format == "pyproject") [
- pipBuildHook
- ] ++ lib.optionals (format == "wheel") [
- wheelUnpackHook
- ] ++ lib.optionals (format == "egg") [
- eggUnpackHook eggBuildHook eggInstallHook
- ] ++ lib.optionals (!(format == "other") || dontUsePipInstall) [
- pipInstallHook
- ] ++ lib.optionals (stdenv.buildPlatform == stdenv.hostPlatform) [
- # This is a test, however, it should be ran independent of the checkPhase and checkInputs
- pythonImportsCheckHook
- ] ++ lib.optionals (python.pythonAtLeast "3.3") [
- # Optionally enforce PEP420 for python3
- pythonNamespacesHook
- ] ++ nativeBuildInputs;
-
- buildInputs = buildInputs ++ pythonPath;
-
- propagatedBuildInputs = propagatedBuildInputs ++ [ python ];
-
- inherit strictDeps;
-
- LANG = "${if python.stdenv.isDarwin then "en_US" else "C"}.UTF-8";
-
- # Python packages don't have a checkPhase, only an installCheckPhase
- doCheck = false;
- doInstallCheck = attrs.doCheck or true;
- installCheckInputs = [
- ] ++ lib.optionals (format == "setuptools") [
- # Longer-term we should get rid of this and require
- # users of this function to set the `installCheckPhase` or
- # pass in a hook that sets it.
- setuptoolsCheckHook
- ] ++ checkInputs;
-
- postFixup = lib.optionalString (!dontWrapPythonPrograms) ''
- wrapPythonPrograms
- '' + attrs.postFixup or '''';
-
- # Python packages built through cross-compilation are always for the host platform.
- disallowedReferences = lib.optionals (python.stdenv.hostPlatform != python.stdenv.buildPlatform) [ python.pythonForBuild ];
-
- meta = {
- # default to python's platforms
- platforms = python.meta.platforms;
- isBuildPythonPackage = python.meta.platforms;
- } // meta;
-} // lib.optionalAttrs (attrs?checkPhase) {
- # If given use the specified checkPhase, otherwise use the setup hook.
- # Longer-term we should get rid of `checkPhase` and use `installCheckPhase`.
- installCheckPhase = attrs.checkPhase;
-}));
-
-passthru.updateScript = let
- filename = builtins.head (lib.splitString ":" self.meta.position);
- in attrs.passthru.updateScript or [ update-python-libraries filename ];
+ name = namePrefix + name;
+
+ nativeBuildInputs = [
+ python
+ wrapPython
+ ensureNewerSourcesForZipFilesHook # move to wheel installer (pip) or builder (setuptools, flit, ...)?
+ pythonRecompileBytecodeHook # Remove when solved https://github.com/NixOS/nixpkgs/issues/81441
+ pythonRemoveTestsDirHook
+ ] ++ lib.optionals catchConflicts [
+ setuptools pythonCatchConflictsHook
+ ] ++ lib.optionals removeBinBytecode [
+ pythonRemoveBinBytecodeHook
+ ] ++ lib.optionals (lib.hasSuffix "zip" (attrs.src.name or "")) [
+ unzip
+ ] ++ lib.optionals (format == "setuptools") [
+ setuptoolsBuildHook
+ ] ++ lib.optionals (format == "flit") [
+ flitBuildHook
+ ] ++ lib.optionals (format == "pyproject") [
+ pipBuildHook
+ ] ++ lib.optionals (format == "wheel") [
+ wheelUnpackHook
+ ] ++ lib.optionals (format == "egg") [
+ eggUnpackHook eggBuildHook eggInstallHook
+ ] ++ lib.optionals (!(format == "other") || dontUsePipInstall) [
+ pipInstallHook
+ ] ++ lib.optionals (stdenv.buildPlatform == stdenv.hostPlatform) [
+ # This is a test, however, it should be ran independent of the checkPhase and checkInputs
+ pythonImportsCheckHook
+ ] ++ lib.optionals (python.pythonAtLeast "3.3") [
+ # Optionally enforce PEP420 for python3
+ pythonNamespacesHook
+ ] ++ nativeBuildInputs;
+
+ buildInputs = buildInputs ++ pythonPath;
+
+ propagatedBuildInputs = propagatedBuildInputs ++ [ python ];
+
+ inherit strictDeps;
+
+ LANG = "${if python.stdenv.isDarwin then "en_US" else "C"}.UTF-8";
+
+ # Python packages don't have a checkPhase, only an installCheckPhase
+ doCheck = false;
+ doInstallCheck = attrs.doCheck or true;
+ installCheckInputs = [
+ ] ++ lib.optionals (format == "setuptools") [
+ # Longer-term we should get rid of this and require
+ # users of this function to set the `installCheckPhase` or
+ # pass in a hook that sets it.
+ setuptoolsCheckHook
+ ] ++ checkInputs;
+
+ postFixup = lib.optionalString (!dontWrapPythonPrograms) ''
+ wrapPythonPrograms
+ '' + attrs.postFixup or '''';
+
+ # Python packages built through cross-compilation are always for the host platform.
+ disallowedReferences = lib.optionals (python.stdenv.hostPlatform != python.stdenv.buildPlatform) [ python.pythonForBuild ];
+
+ # For now, revert recompilation of bytecode.
+ dontUsePythonRecompileBytecode = true;
+
+ meta = {
+ # default to python's platforms
+ platforms = python.meta.platforms;
+ isBuildPythonPackage = python.meta.platforms;
+ } // meta;
+ } // lib.optionalAttrs (attrs?checkPhase) {
+ # If given use the specified checkPhase, otherwise use the setup hook.
+ # Longer-term we should get rid of `checkPhase` and use `installCheckPhase`.
+ installCheckPhase = attrs.checkPhase;
+ }));
+
+ passthru.updateScript = let
+ filename = builtins.head (lib.splitString ":" self.meta.position);
+ in attrs.passthru.updateScript or [ update-python-libraries filename ];
in lib.extendDerivation true passthru self