summary refs log tree commit diff
path: root/pkgs/development/interpreters/python/hooks
diff options
context:
space:
mode:
authorDaniël de Kok <me@danieldk.eu>2020-06-06 09:55:05 +0200
committerDaniël de Kok <me@danieldk.eu>2020-06-06 10:05:26 +0200
commit1e2b6695cf8c71b3a0605bf0edd53d8d19d4545e (patch)
treef5b26790f5cc4c7e84fd682e53bdad96c2c29cd7 /pkgs/development/interpreters/python/hooks
parente2309df85ead6611394693ead92ca99a94caec4a (diff)
downloadnixpkgs-1e2b6695cf8c71b3a0605bf0edd53d8d19d4545e.tar
nixpkgs-1e2b6695cf8c71b3a0605bf0edd53d8d19d4545e.tar.gz
nixpkgs-1e2b6695cf8c71b3a0605bf0edd53d8d19d4545e.tar.bz2
nixpkgs-1e2b6695cf8c71b3a0605bf0edd53d8d19d4545e.tar.lz
nixpkgs-1e2b6695cf8c71b3a0605bf0edd53d8d19d4545e.tar.xz
nixpkgs-1e2b6695cf8c71b3a0605bf0edd53d8d19d4545e.tar.zst
nixpkgs-1e2b6695cf8c71b3a0605bf0edd53d8d19d4545e.zip
pythonPackages.setuptoolsBuildHook: do not build in an isolated environment
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.
Diffstat (limited to 'pkgs/development/interpreters/python/hooks')
-rw-r--r--pkgs/development/interpreters/python/hooks/setuptools-build-hook.sh3
1 files changed, 2 insertions, 1 deletions
diff --git a/pkgs/development/interpreters/python/hooks/setuptools-build-hook.sh b/pkgs/development/interpreters/python/hooks/setuptools-build-hook.sh
index 2aec9279382..311590425e6 100644
--- a/pkgs/development/interpreters/python/hooks/setuptools-build-hook.sh
+++ b/pkgs/development/interpreters/python/hooks/setuptools-build-hook.sh
@@ -29,7 +29,8 @@ setuptoolsShellHook() {
         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 >&2"
+        eval "@pythonInterpreter@ -m pip install -e . --prefix $tmp_path \
+          --no-build-isolation >&2"
     fi
 
     runHook postShellHook