chore: add hooks

This commit is contained in:
Phillip Cloud 2023-10-23 04:04:11 -04:00
parent 6761453ba8
commit 85feb8081f
No known key found for this signature in database
GPG key ID: D908212070FD785E
4 changed files with 81 additions and 2 deletions

View file

@ -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

24
hooks/pip-install-hook.sh Normal file
View file

@ -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

19
hooks/pypa-build-hook.sh Normal file
View file

@ -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

View file

@ -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