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