1{ lib 2, stdenv 3, python 4, build 5, flit-core 6, installer 7, packaging 8, pyproject-hooks 9, tomli 10, makeWrapper 11}: 12let 13 buildBootstrapPythonModule = basePackage: attrs: stdenv.mkDerivation ({ 14 pname = "${python.libPrefix}-bootstrap-${basePackage.pname}"; 15 inherit (basePackage) version src meta; 16 17 nativeBuildInputs = [ makeWrapper ]; 18 19 buildPhase = '' 20 runHook preBuild 21 22 PYTHONPATH="${flit-core}/${python.sitePackages}" \ 23 ${python.interpreter} -m flit_core.wheel 24 25 runHook postBuild 26 ''; 27 28 installPhase = '' 29 runHook preInstall 30 31 PYTHONPATH="${installer}/${python.sitePackages}" \ 32 ${python.interpreter} -m installer \ 33 --destdir "$out" --prefix "" dist/*.whl 34 35 runHook postInstall 36 ''; 37 } // attrs); 38 39 bootstrap-packaging = buildBootstrapPythonModule packaging {}; 40 41 bootstrap-pyproject-hooks = buildBootstrapPythonModule pyproject-hooks {}; 42 43 bootstrap-tomli = buildBootstrapPythonModule tomli {}; 44 45 sitePkgs = python.sitePackages; 46in 47buildBootstrapPythonModule build { 48 # like the installPhase above, but wrapping the pyproject-build command 49 # to set up PYTHONPATH with the correct dependencies. 50 # This allows using `pyproject-build` without propagating its dependencies 51 # into the build environment, which is necessary to prevent 52 # pythonCatchConflicts from raising false positive alerts. 53 # This would happen whenever the package to build has a dependency on 54 # another version of a package that is also a dependency of pyproject-build. 55 installPhase = '' 56 runHook preInstall 57 58 PYTHONPATH="${installer}/${python.sitePackages}" \ 59 ${python.interpreter} -m installer \ 60 --destdir "$out" --prefix "" dist/*.whl 61 62 wrapProgram $out/bin/pyproject-build \ 63 --prefix PYTHONPATH : "$out/${sitePkgs}" \ 64 --prefix PYTHONPATH : "${bootstrap-pyproject-hooks}/${sitePkgs}" \ 65 --prefix PYTHONPATH : "${bootstrap-packaging}/${sitePkgs}" \ 66 --prefix PYTHONPATH : "${bootstrap-tomli}/${sitePkgs}" 67 68 runHook postInstall 69 ''; 70}