diff --git a/hooks/pip-build-hook.sh b/hooks/pip-build-hook.sh index 31e0690..9de4c7d 100644 --- a/hooks/pip-build-hook.sh +++ b/hooks/pip-build-hook.sh @@ -1,13 +1,22 @@ # Setup hook to use for pip projects echo "Sourcing pip-build-hook" +declare -a pipBuildFlags + pipBuildPhase() { echo "Executing pipBuildPhase" runHook preBuild mkdir -p dist echo "Creating a wheel..." - @pythonInterpreter@ -m pip wheel --verbose --no-index --no-deps --no-clean --no-build-isolation --wheel-dir dist . + @pythonInterpreter@ -m pip wheel \ + --verbose \ + --no-index \ + --no-deps \ + --no-clean \ + --no-build-isolation \ + --wheel-dir dist \ + $pipBuildFlags . echo "Finished creating a wheel..." runHook postBuild @@ -24,7 +33,8 @@ pipShellHook() { export PATH="$tmp_path/bin:$PATH" export PYTHONPATH="$tmp_path/@pythonSitePackages@:$PYTHONPATH" mkdir -p "$tmp_path/@pythonSitePackages@" - @pythonInterpreter@ -m pip install -e . --prefix "$tmp_path" >&2 + @pythonInterpreter@ -m pip install -e . --prefix "$tmp_path" \ + --no-build-isolation >&2 fi runHook postShellHook diff --git a/hooks/pip-install-hook.sh b/hooks/pip-install-hook.sh new file mode 100644 index 0000000..a4f08b8 --- /dev/null +++ b/hooks/pip-install-hook.sh @@ -0,0 +1,24 @@ +# Setup hook for pip. +echo "Sourcing pip-install-hook" + +declare -a pipInstallFlags + +pipInstallPhase() { + echo "Executing pipInstallPhase" + runHook preInstall + + mkdir -p "$out/@pythonSitePackages@" + export PYTHONPATH="$out/@pythonSitePackages@:$PYTHONPATH" + + pushd dist || return 1 + @pythonInterpreter@ -m pip install ./*.whl --no-index --no-warn-script-location --prefix="$out" --no-cache $pipInstallFlags + popd || return 1 + + runHook postInstall + echo "Finished executing pipInstallPhase" +} + +if [ -z "${dontUsePipInstall-}" ] && [ -z "${installPhase-}" ]; then + echo "Using pipInstallPhase" + installPhase=pipInstallPhase +fi diff --git a/hooks/pypa-build-hook.sh b/hooks/pypa-build-hook.sh new file mode 100644 index 0000000..dd49d93 --- /dev/null +++ b/hooks/pypa-build-hook.sh @@ -0,0 +1,19 @@ +# Setup hook to use for pypa/build projects +echo "Sourcing pypa-build-hook" + +pypaBuildPhase() { + echo "Executing pypaBuildPhase" + runHook preBuild + + echo "Creating a wheel..." + @build@/bin/pyproject-build --no-isolation --outdir dist/ --wheel $pypaBuildFlags + echo "Finished creating a wheel..." + + runHook postBuild + echo "Finished executing pypaBuildPhase" +} + +if [ -z "${dontUsePypaBuild-}" ] && [ -z "${buildPhase-}" ]; then + echo "Using pypaBuildPhase" + buildPhase=pypaBuildPhase +fi diff --git a/hooks/pypa-install-hook.sh b/hooks/pypa-install-hook.sh new file mode 100644 index 0000000..2d92574 --- /dev/null +++ b/hooks/pypa-install-hook.sh @@ -0,0 +1,26 @@ +# Setup hook for PyPA installer. +echo "Sourcing pypa-install-hook" + +pypaInstallPhase() { + echo "Executing pypaInstallPhase" + runHook preInstall + + pushd dist > /dev/null + + for wheel in *.whl; do + @pythonInterpreter@ -m installer --prefix "$out" "$wheel" + echo "Successfully installed $wheel" + done + + popd > /dev/null + + export PYTHONPATH="$out/@pythonSitePackages@:$PYTHONPATH" + + runHook postInstall + echo "Finished executing pypaInstallPhase" +} + +if [ -z "${dontUsePypaInstall-}" ] && [ -z "${installPhase-}" ]; then + echo "Using pypaInstallPhase" + installPhase=pypaInstallPhase +fi