python3.pkgs.pypaInstallHook: init

This commit is contained in:
Theodore Ni
2023-08-20 10:59:46 +02:00
committed by Frederik Rietdijk
parent b53cef70f2
commit a4d66bcc5f
2 changed files with 34 additions and 1 deletions
@@ -1,7 +1,8 @@
self: dontUse: with self;
let
pythonInterpreter = python.pythonForBuild.interpreter;
inherit (python) pythonForBuild;
pythonInterpreter = pythonForBuild.interpreter;
pythonSitePackages = python.sitePackages;
pythonCheckInterpreter = python.interpreter;
setuppy = ../run_setup.py;
@@ -81,6 +82,17 @@ in {
};
} ./pip-install-hook.sh) {};
pypaInstallHook = callPackage ({ makePythonHook, installer }:
makePythonHook {
name = "pypa-install-hook";
propagatedBuildInputs = [ installer ];
substitutions = {
inherit pythonInterpreter pythonSitePackages;
};
} ./pypa-install-hook.sh) {
inherit (pythonForBuild.pkgs) installer;
};
pytestCheckHook = callPackage ({ makePythonHook, pytest }:
makePythonHook {
name = "pytest-check-hook";
@@ -0,0 +1,21 @@
# Setup hook for PyPA installer.
echo "Sourcing pypa-install-hook"
pypaInstallPhase() {
echo "Executing pypaInstallPhase"
runHook preInstall
for wheel in dist/*.whl; do
@pythonInterpreter@ -m installer --prefix "$out" "$wheel"
done
export PYTHONPATH="$out/@pythonSitePackages@:$PYTHONPATH"
runHook postInstall
echo "Finished executing pypaInstallPhase"
}
if [ -z "${dontUsePypaInstall-}" ] && [ -z "${installPhase-}" ]; then
echo "Using pypaInstallPhase"
installPhase=pypaInstallPhase
fi