-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Document why virtual environments should (nearly) always be used, and system site-packages is considered harmful #6398
Comments
Please do not do this. This would seriously break Docker workflows, and really, that config is up to the user; I don't see any problem with that, other than the fact that you run into users who choose to do the incorrect things on their systems. |
The suggestion is not that it be made impossible to use the system environment, people who insist on doing this can continue to do so. Rather, that it more clearly and firmly be discouraged. The problem is that many of the people who avoid using a virtual environment don't really understand what they're doing, then things go wrong, then they come here... it's a big waste of everyone's time. It would be better for those people to be guided towards a pattern that's more likely to work reliably in the first place. (#6397 was the immediate prompt for opening this, but I'm confident there are lots of other examples) |
I think you are among the users who might benefit from the documentation ask here -- there is no reason to avoid virtual environments in a container, and it usually causes more harm than good to do so. Check out #6397 (comment) for a recipe for 'seamless' use of a virtual environment in a container -- you get all the ergonomic benefits of not having to use a virtual environment path prefix, but you properly isolate your components so that you are not mixing dependency trees with unknown results. Regarding your stance of The support burden of users who had a project that happened to work with |
I wonder if splitting the option into Honestly, I'd even add a warning if |
The documentation on the official installer seems to indicate that it will be installed in a separate environment and therefore it would be safe to not use a virtualenv inside a Docker container:
I can install poetry inside docker with these lines: RUN curl -sSL https://install.python-poetry.org | python3 - --version 1.2.0
ENV PATH "/home/vscode/.poetry/bin:$PATH"
RUN /home/vscode/.local/bin/poetry config virtualenvs.create false When I then run Package Version
---------- -------
pip 22.2.2
setuptools 58.1.0
wheel 0.37.1 This seems like it has been effectively isolated from the system level python. However, once I run Is the documentation wrong that the official installer is not actually isolated from system level python? If not, what is the correct interpretation of what it's saying and why did installation succeed with poetry<1.2? If the documentation is wrong, then it does seem like stronger guardrails would be helpful. |
I wrote up a whole response but it looks like Github ate it -- sorry @sullivancolin, this one is likely less in depth, but hopefully it addresses your questions. The official installer, or any officially supported installation method will create a separate virtual environment to install Poetry into, separate from the system (or container, in this case -- we still call it system) level environment. You can correctly see that no Poetry-related packages are installed into your system environment. However, |
This is tracked in #1945 |
I think it would be useful if there was a way to tell poetry to never create a venv, but never use the system python either: to refuse to run if a venv is not set. |
This is a lot better with PEP 668 (https://peps.python.org/pep-0668/); it prevents the 'footgun' configurations where installing Poetry can conflict with e.g. DNF or APT. While it's still possible to have some footgun-like experiences with In other words, that is de-facto happening and users will benefit as they move to newer distros/Python versions; though we should probably verify that our installer also respects the PEP 668 markers. |
Every time someone comes here with something going wrong after they set
poetry config virtualenvs.create false
the answer is "oh, you didn't want to do that". It's a footgun.Can anything be done?
Personally I don't want poetry to manage my virtual environments at all, though I do want it to refuse to go ahead if I've forgotten to create the environment myself. But probably it's hard to get to there from here; and certainly not everyone has the same workflow.
The text was updated successfully, but these errors were encountered: