nixpkgs/pkgs/development/interpreters/python/hooks/python-imports-check-hook.sh
Jonathan Ringer cd97c055a0 python: execute pythonImportsCheckPhase in subshell
Execute in subshell so that the cwd returns back
to the original directory. This is important as
it enables pythonImportsCheck to work with checkPhase
2020-02-19 22:30:50 -08:00

17 lines
641 B
Bash

# 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