summary refs log tree commit diff
path: root/pkgs/development/interpreters/python/hooks/python-imports-check-hook.sh
blob: 7e2b3f69d6dd78b43b41ab8c726417bae64fa524 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# Setup hook for checking whether Python imports succeed
echo "Sourcing python-imports-check-hook.sh"

pythonImportsCheckPhase () {
    echo "Executing pythonImportsCheckPhase"

    if [ -n "$pythonImportsCheck" ]; then
        echo "Check whether the following modules can be imported: $pythonImportsCheck"
        cd $out && eval "@pythonCheckInterpreter@ -c 'import os; import importlib; list(map(lambda mod: importlib.import_module(mod), os.environ[\"pythonImportsCheck\"].split()))'"
    fi
}

if [ -z "$dontUsePythonImportsCheck" ]; then
    echo "Using pythonImportsCheckPhase"
    preDistPhases+=" pythonImportsCheckPhase"
fi