python310Packages.buildPythonPackage: introduce pyproject option

figsoda 68932019 aa17cca9

+28 -10
+28 -10
pkgs/development/interpreters/python/mk-python-derivation.nix
··· 82 # However, some packages do provide executables with extensions, and thus bytecode is generated. 83 , removeBinBytecode ? true 84 85 # Several package formats are supported. 86 # "setuptools" : Install a common setuptools/distutils based package. This builds a wheel. 87 # "wheel" : Install from a pre-compiled wheel. ··· 89 # "pyproject": Install a package using a ``pyproject.toml`` file (PEP517). This builds a wheel. 90 # "egg": Install a package from an egg. 91 # "other" : Provide your own buildPhase and installPhase. 92 - , format ? "setuptools" 93 94 , meta ? {} 95 ··· 101 102 , ... } @ attrs: 103 104 let 105 inherit (python) stdenv; 106 107 - withDistOutput = lib.elem format ["pyproject" "setuptools" "flit" "wheel"]; 108 109 name_ = name; 110 ··· 177 178 # Keep extra attributes from `attrs`, e.g., `patchPhase', etc. 179 self = toPythonModule (stdenv.mkDerivation ((builtins.removeAttrs attrs [ 180 - "disabled" "checkPhase" "checkInputs" "nativeCheckInputs" "doCheck" "doInstallCheck" "dontWrapPythonPrograms" "catchConflicts" "format" 181 "disabledTestPaths" "outputs" 182 ]) // { 183 ··· 202 pythonRemoveBinBytecodeHook 203 ] ++ lib.optionals (lib.hasSuffix "zip" (attrs.src.name or "")) [ 204 unzip 205 - ] ++ lib.optionals (format == "setuptools") [ 206 setuptoolsBuildHook 207 - ] ++ lib.optionals (format == "flit") [ 208 flitBuildHook 209 - ] ++ lib.optionals (format == "pyproject") [( 210 if isBootstrapPackage then 211 pypaBuildHook.override { 212 inherit (python.pythonForBuild.pkgs.bootstrap) build; ··· 214 } 215 else 216 pypaBuildHook 217 - )] ++ lib.optionals (format == "wheel") [ 218 wheelUnpackHook 219 - ] ++ lib.optionals (format == "egg") [ 220 eggUnpackHook eggBuildHook eggInstallHook 221 - ] ++ lib.optionals (format != "other") [( 222 if isBootstrapInstallPackage then 223 pypaInstallHook.override { 224 inherit (python.pythonForBuild.pkgs.bootstrap) installer; ··· 252 doCheck = false; 253 doInstallCheck = attrs.doCheck or true; 254 nativeInstallCheckInputs = [ 255 - ] ++ lib.optionals (format == "setuptools") [ 256 # Longer-term we should get rid of this and require 257 # users of this function to set the `installCheckPhase` or 258 # pass in a hook that sets it.
··· 82 # However, some packages do provide executables with extensions, and thus bytecode is generated. 83 , removeBinBytecode ? true 84 85 + # pyproject = true <-> format = "pyproject" 86 + # pyproject = false <-> format = "other" 87 + # https://github.com/NixOS/nixpkgs/issues/253154 88 + , pyproject ? null 89 + 90 # Several package formats are supported. 91 # "setuptools" : Install a common setuptools/distutils based package. This builds a wheel. 92 # "wheel" : Install from a pre-compiled wheel. ··· 94 # "pyproject": Install a package using a ``pyproject.toml`` file (PEP517). This builds a wheel. 95 # "egg": Install a package from an egg. 96 # "other" : Provide your own buildPhase and installPhase. 97 + , format ? null 98 99 , meta ? {} 100 ··· 106 107 , ... } @ attrs: 108 109 + assert (pyproject != null) -> (format == null); 110 + 111 let 112 inherit (python) stdenv; 113 114 + format' = 115 + if pyproject != null then 116 + if pyproject then 117 + "pyproject" 118 + else 119 + "other" 120 + else if format != null then 121 + format 122 + else 123 + "setuptools"; 124 + 125 + withDistOutput = lib.elem format' ["pyproject" "setuptools" "flit" "wheel"]; 126 127 name_ = name; 128 ··· 195 196 # Keep extra attributes from `attrs`, e.g., `patchPhase', etc. 197 self = toPythonModule (stdenv.mkDerivation ((builtins.removeAttrs attrs [ 198 + "disabled" "checkPhase" "checkInputs" "nativeCheckInputs" "doCheck" "doInstallCheck" "dontWrapPythonPrograms" "catchConflicts" "pyproject" "format" 199 "disabledTestPaths" "outputs" 200 ]) // { 201 ··· 220 pythonRemoveBinBytecodeHook 221 ] ++ lib.optionals (lib.hasSuffix "zip" (attrs.src.name or "")) [ 222 unzip 223 + ] ++ lib.optionals (format' == "setuptools") [ 224 setuptoolsBuildHook 225 + ] ++ lib.optionals (format' == "flit") [ 226 flitBuildHook 227 + ] ++ lib.optionals (format' == "pyproject") [( 228 if isBootstrapPackage then 229 pypaBuildHook.override { 230 inherit (python.pythonForBuild.pkgs.bootstrap) build; ··· 232 } 233 else 234 pypaBuildHook 235 + )] ++ lib.optionals (format' == "wheel") [ 236 wheelUnpackHook 237 + ] ++ lib.optionals (format' == "egg") [ 238 eggUnpackHook eggBuildHook eggInstallHook 239 + ] ++ lib.optionals (format' != "other") [( 240 if isBootstrapInstallPackage then 241 pypaInstallHook.override { 242 inherit (python.pythonForBuild.pkgs.bootstrap) installer; ··· 270 doCheck = false; 271 doInstallCheck = attrs.doCheck or true; 272 nativeInstallCheckInputs = [ 273 + ] ++ lib.optionals (format' == "setuptools") [ 274 # Longer-term we should get rid of this and require 275 # users of this function to set the `installCheckPhase` or 276 # pass in a hook that sets it.