python310Packages.buildPythonPackage: introduce pyproject option

figsoda 68932019 aa17cca9

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