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