summaryrefslogtreecommitdiff
path: root/pkgs/development/interpreters/python/hooks/pip-install-hook.sh
blob: 0f718a6c4bb89d4f5fe83c25d0e8c363a8a3b8c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Setup hook for pip.
# shellcheck shell=bash

echo "Sourcing pip-install-hook"

pipInstallPhase() {
    echo "Executing pipInstallPhase"
    runHook preInstall

    # shellcheck disable=SC2154
    mkdir -p "$out/@pythonSitePackages@"
    export PYTHONPATH="$out/@pythonSitePackages@:$PYTHONPATH"

    local -a flagsArray=(
        --no-index
        --no-warn-script-location
        --prefix="$out"
        --no-cache
    )
    concatTo flagsArray pipInstallFlags

    pushd dist || return 1
    echoCmd 'pip install flags' "${flagsArray[@]}"
    @pythonInterpreter@ -m pip install ./*.whl "${flagsArray[@]}"
    popd || return 1

    runHook postInstall
    echo "Finished executing pipInstallPhase"
}

if [ -z "${dontUsePipInstall-}" ] && [ -z "${installPhase-}" ]; then
    echo "Using pipInstallPhase"
    installPhase=pipInstallPhase
fi