-
-
Notifications
You must be signed in to change notification settings - Fork 402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
venv with system-site-packages enabled invokes console scripts in the parent version context #435
Comments
To clarify the use case: I put things like language servers in site packages because they're used with every project. Project dependencies go in the virtualenv; this isolates the developer's environment from the project environment. Yes, the workaround is just install developer's dependencies into the venv, but that duplicates things and (depending on the dependency manager) can pollute the environment of collaborators with things they don't need. It's cleaner this way, and with proper pinning/locking, overlaps between site-packages and venv packages aren't a problem. |
To further clarify: I see a distinction between developer dependencies and development dependencies. A developer dependency is something a developer uses to be productive and consistent across all projects, but where toolchain may vary from developer to developer. Language servers, linters, and code analysis tools are good examples of these. In contrast, a development dependency is something required by a project but is not part of the release. Build and test frameworks are the typical examples. So when I say "developer dependency" above, that's what I mean. I don't want to install a language server as a development dependency, because (a) it's not needed to build, test, or run the code; and (b) you might use a different one. Virtualenvs with system-site-packages allows this to work, but pyenv is giving me fits. This actually is working on my personal Linux workstation, but poking around in there I see that there's something wonky on that install; |
Try this. It worked for me |
That works for imports, not for console scripts. |
When a pyenv virtualenv is created with system-site-packages enabled, console scripts installed in the parent pyenv version are invoked using the parent's environment, not the current virtual environment, and cannot load packages installed in the virtualenv.
Reproduction:
Create a venv from a parent version that has packages with console scripts. Here, package
pyright
has a console script.We pip install a package into the venv.
When invoked, pyright parses code and imports, but can't find the package in the venv.
When the console script is invoked as a module entry point, the import is resolved because python is executed in the venv.
Prerequisite
There are a couple of close issues, but nothing really seemed to match.
Description
All.
N/A
https://gist.github.com/Cerebus/bf0a32edd99d6d8c00a29401628771f8
The text was updated successfully, but these errors were encountered: