-
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
Detect Conda when looking for a virtual env #1432
Conversation
This is amazing and I'm looking forward to this PR! |
@sdispater I just took a look at this PR and it looks good to me -- can we get this in 1.0 or 1.1? |
@stephsamson I think we can add it for the @maksbotan Can you rebase your branch onto the |
@sdispater just to clarify, |
@maksbotan Yes, |
Currently Poetry will detect that it is running in a usual virtual env created with "python -m venv" and will not create an additional env. This commit extends this logic to Conda, which uses different environment variables to indicate running in a virtual env. Conda's "base" env is treated specially to avoid polluting global namespace.
f2c0d28
to
b1058fc
Compare
Well, I did it :) |
Thanks a lot! |
Currently Poetry will detect that it is running in a usual virtual env created with "python -m venv" and will not create an additional env. This commit extends this logic to Conda, which uses different environment variables to indicate running in a virtual env. Conda's "base" env is treated specially to avoid polluting global namespace.
Currently Poetry will detect that it is running in a usual virtual env created with "python -m venv" and will not create an additional env. This commit extends this logic to Conda, which uses different environment variables to indicate running in a virtual env. Conda's "base" env is treated specially to avoid polluting global namespace.
conda_env_name = os.environ.get("CONDA_DEFAULT_ENV") | ||
# It's probably not a good idea to pollute Conda's global "base" env, since | ||
# most users have it activated all the time. | ||
in_venv = env_prefix is not None and conda_env_name != "base" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maksbotan, @stephsamson it is useful to allow poetry install into "base" environment when we create Docker image because there no need to create multiple Conda environments inside the container.
Otherwise, the developer should be aware that Poetry will ignore "base" environment. It would be great to output a warning/notice message about this.
Just wondering: will poetry solve with taking the conda packages into account? I couldn't really find that in the documentation and I had a bit of a confusing situation. I recently did on a windows computer did
But in my code I got complaints that numpy was not properly installed. So I installed it with conda, where we had only a version before available...
And now I still get
Only after |
I don't think this is working, speaking from Windows. Same thing as above happesn for pytest and anything else I'm trying to use in a poetry / conda project. poetry show -v with dependencies commented out:
poetry show -v with dependencies defined, numpy = "^1.17"
conda list with grep to look for a dependency installed in conda env under test
|
Is there any way to disable this functionality? I only want to use conda for the python binary and system compiler etc, not for the environment. Now poetry just never creates an environment and instead installs its stuff in the conda env. |
Would also like to know how to disable this |
@austinmw as far as I remember this change, poetry would use Conda env if you specifically created one, distinct from Conda's By the way, I think this behavior might be broken in the latest releases. I believe I even reported the issue. |
Ah okay, I didn’t realize that this functionality doesn’t kick in for the base environment. That works for me then, thanks! |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Currently Poetry will detect that it is running in a usual virtual env
created with "python -m venv" and will not create an additional env.
This commit extends this logic to Conda, which uses different
environment variables to indicate running in a virtual env.
Conda's "base" env is treated specially to avoid polluting global
namespace.
Pull Request Check List
This is just a reminder about the most common mistakes. Please make sure that you tick all appropriate boxes. But please read our contribution guide at least once, it will save you unnecessary review cycles!
Note: If your Pull Request introduces a new feature or changes the current behavior, it should be based
on the
develop
branch. If it's a bug fix or only a documentation update, it should be based on themaster
branch.If you have any questions to any of the points above, just submit and ask! This checklist is here to help you, not to deter you from contributing!