mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-28 08:33:54 +00:00
1e2b6695cf
When a PEP 517 project file is present, pip will not install prerequisites in `site-packages`: https://pip.pypa.io/en/stable/reference/pip/#pep-517-and-518-support For the shell hook, this has the consequence that the generated temporary directory that is added to PYTHONPATH does not contain `site.py`. As a result, Python does not discover the Python module. Thus when a user executes nix-shell in a project, they cannot import the project's Python module. This change adds the `--no-build-isolation` option to pip when creating the editable environment, to correctly generate `site.py`, even when a `pyproject.toml` is present.
49 lines
1.3 KiB
Bash
49 lines
1.3 KiB
Bash
# Setup hook for setuptools.
|
|
echo "Sourcing setuptools-build-hook"
|
|
|
|
setuptoolsBuildPhase() {
|
|
echo "Executing setuptoolsBuildPhase"
|
|
local args
|
|
runHook preBuild
|
|
|
|
cp -f @setuppy@ nix_run_setup
|
|
args=""
|
|
if [ -n "$setupPyGlobalFlags" ]; then
|
|
args+="$setupPyGlobalFlags"
|
|
fi
|
|
if [ -n "$setupPyBuildFlags" ]; then
|
|
args+="build_ext $setupPyBuildFlags"
|
|
fi
|
|
eval "@pythonInterpreter@ nix_run_setup $args bdist_wheel"
|
|
|
|
runHook postBuild
|
|
echo "Finished executing setuptoolsBuildPhase"
|
|
}
|
|
|
|
setuptoolsShellHook() {
|
|
echo "Executing setuptoolsShellHook"
|
|
runHook preShellHook
|
|
|
|
if test -e setup.py; then
|
|
tmp_path=$(mktemp -d)
|
|
export PATH="$tmp_path/bin:$PATH"
|
|
export PYTHONPATH="$tmp_path/@pythonSitePackages@:$PYTHONPATH"
|
|
mkdir -p "$tmp_path/@pythonSitePackages@"
|
|
eval "@pythonInterpreter@ -m pip install -e . --prefix $tmp_path \
|
|
--no-build-isolation >&2"
|
|
fi
|
|
|
|
runHook postShellHook
|
|
echo "Finished executing setuptoolsShellHook"
|
|
}
|
|
|
|
if [ -z "${dontUseSetuptoolsBuild-}" ] && [ -z "${buildPhase-}" ]; then
|
|
echo "Using setuptoolsBuildPhase"
|
|
buildPhase=setuptoolsBuildPhase
|
|
fi
|
|
|
|
if [ -z "${dontUseSetuptoolsShellHook-}" ] && [ -z "${shellHook-}" ]; then
|
|
echo "Using setuptoolsShellHook"
|
|
shellHook=setuptoolsShellHook
|
|
fi
|