1# Setup hook to use for pip projects
2echo "Sourcing pip-build-hook"
3
4pipBuildPhase() {
5 echo "Executing pipBuildPhase"
6 runHook preBuild
7
8 mkdir -p dist
9 echo "Creating a wheel..."
10 @pythonInterpreter@ -m pip wheel --verbose --no-index --no-deps --no-clean --no-build-isolation --wheel-dir dist .
11 echo "Finished creating a wheel..."
12
13 runHook postBuild
14 echo "Finished executing pipBuildPhase"
15}
16
17pipShellHook() {
18 echo "Executing pipShellHook"
19 runHook preShellHook
20
21 # Long-term setup.py should be dropped.
22 if [ -e pyproject.toml ]; then
23 tmp_path=$(mktemp -d)
24 export PATH="$tmp_path/bin:$PATH"
25 export PYTHONPATH="$tmp_path/@pythonSitePackages@:$PYTHONPATH"
26 mkdir -p "$tmp_path/@pythonSitePackages@"
27 @pythonInterpreter@ -m pip install -e . --prefix "$tmp_path" \
28 --no-build-isolation >&2
29 fi
30
31 runHook postShellHook
32 echo "Finished executing pipShellHook"
33}
34
35if [ -z "${dontUsePipBuild-}" ] && [ -z "${buildPhase-}" ]; then
36 echo "Using pipBuildPhase"
37 buildPhase=pipBuildPhase
38fi
39
40if [ -z "${shellHook-}" ]; then
41 echo "Using pipShellHook"
42 shellHook=pipShellHook
43fi