2024-06-05 15:53:02 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
stdenv,
|
|
|
|
python,
|
|
|
|
build,
|
|
|
|
flit-core,
|
|
|
|
installer,
|
|
|
|
packaging,
|
|
|
|
pyproject-hooks,
|
|
|
|
tomli,
|
|
|
|
makeWrapper,
|
2023-10-09 19:29:22 +00:00
|
|
|
}:
|
|
|
|
let
|
2024-06-05 15:53:02 +00:00
|
|
|
buildBootstrapPythonModule =
|
|
|
|
basePackage: attrs:
|
|
|
|
stdenv.mkDerivation (
|
|
|
|
{
|
|
|
|
pname = "${python.libPrefix}-bootstrap-${basePackage.pname}";
|
|
|
|
inherit (basePackage) version src meta;
|
2023-10-09 19:29:22 +00:00
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
2023-10-09 19:29:22 +00:00
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
2023-10-09 19:29:22 +00:00
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
PYTHONPATH="${flit-core}/${python.sitePackages}" \
|
|
|
|
${python.interpreter} -m flit_core.wheel
|
2023-10-09 19:29:22 +00:00
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
runHook postBuild
|
|
|
|
'';
|
2023-10-09 19:29:22 +00:00
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
2023-10-09 19:29:22 +00:00
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
PYTHONPATH="${installer}/${python.sitePackages}" \
|
|
|
|
${python.interpreter} -m installer \
|
|
|
|
--destdir "$out" --prefix "" dist/*.whl
|
2023-10-09 19:29:22 +00:00
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
}
|
|
|
|
// attrs
|
|
|
|
);
|
2023-10-09 19:29:22 +00:00
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
bootstrap-packaging = buildBootstrapPythonModule packaging { };
|
2023-10-09 19:29:22 +00:00
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
bootstrap-pyproject-hooks = buildBootstrapPythonModule pyproject-hooks { };
|
2023-10-09 19:29:22 +00:00
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
bootstrap-tomli = buildBootstrapPythonModule tomli { };
|
2023-10-09 19:29:22 +00:00
|
|
|
|
|
|
|
sitePkgs = python.sitePackages;
|
|
|
|
in
|
|
|
|
buildBootstrapPythonModule build {
|
|
|
|
# like the installPhase above, but wrapping the pyproject-build command
|
|
|
|
# to set up PYTHONPATH with the correct dependencies.
|
|
|
|
# This allows using `pyproject-build` without propagating its dependencies
|
|
|
|
# into the build environment, which is necessary to prevent
|
|
|
|
# pythonCatchConflicts from raising false positive alerts.
|
|
|
|
# This would happen whenever the package to build has a dependency on
|
|
|
|
# another version of a package that is also a dependency of pyproject-build.
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
|
|
|
|
PYTHONPATH="${installer}/${python.sitePackages}" \
|
|
|
|
${python.interpreter} -m installer \
|
|
|
|
--destdir "$out" --prefix "" dist/*.whl
|
|
|
|
|
|
|
|
wrapProgram $out/bin/pyproject-build \
|
|
|
|
--prefix PYTHONPATH : "$out/${sitePkgs}" \
|
|
|
|
--prefix PYTHONPATH : "${bootstrap-pyproject-hooks}/${sitePkgs}" \
|
|
|
|
--prefix PYTHONPATH : "${bootstrap-packaging}/${sitePkgs}" \
|
|
|
|
--prefix PYTHONPATH : "${bootstrap-tomli}/${sitePkgs}"
|
|
|
|
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
}
|