-
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 use of current conda env #1724
Comments
I want to add to this - I would go so far as to revert this behavior to the poetry 0.12 behavior by default, where it creates a new virtualenv for the poetry project (it will be a derivative of the existing conda virtualenv that is already active, it should not pollute that conda env). To provide flexibility for folks who want it either way, add a config option to control how this behaves. I have used conda to manage python versions and do so by creating a conda virtualenv for each python version on my system. I then activate a conda env with a given python version and then use poetry for a given project that needs a specific python version; then poetry 0.12 creates and manages a new virtualenv. The conda-envs are treated like base environments for spawning new virtualenvs. The new poetry 1.x behavior now pollutes the base conda-envs that manage python versions - arghhh. What's the alternative way to use poetry 1.x without polluting an existing conda base-env? At present, it seems like Side note - I no longer trust |
For other conda folks landing here who do not want poetry 1.x to pollute a conda-venv () {
# create and activate a conda environment with
# the name of the current directory (often this
# is a project name). Default to python=3.6
local py_ver="${1:-3.6}"
wd=$(basename $(pwd))
conda deactivate
conda create -y -n "$wd" python="${py_ver}"
conda activate "$wd"
} For updates: https://github.com/dazza-codes/conda_container/blob/master/conda_venv.sh I use it like this: git clone [email protected]:sdispater/poetry.git
cd poetry
conda-venv
poetry install It's not awesome by any means, but it helps. |
I strongly support @dazza-codes's suggestion to provide an option for poetry to not polute an active conda environment. I generally activate a My current workflow is to create small conda environments with the various interpreters that I want, and symlink these somewhere accessible like for py_ver in 2.7 3.6 3.7 3.8 3.9; do
conda_env="py${py_ver}"
conda create --strict-channel-priority -c defaults -y -n "${conda_env}" python="${py_ver}"
conda activate "${conda_env}"
ln -fs "$(type -p python${py_ver})" ~/.local/bin/
conda deactivate
done Then I can use poetry with $ cd project
$ poetry env info
Virtualenv
Python: 3.8.8
Implementation: CPython
Path: /data/apps/conda/envs/work # I don't want this corrupted!
...
$ poetry env use python3.8
$ poetry env info
Virtualenv
Python: 3.8.8
Implementation: CPython
Path: /Users/mforbes/Library/Caches/pypoetry/virtualenvs/persist-ZlvMTnqX-py3.8
... |
Just to add another voice here, I have migrated my dev team over to using poetry within conda by default. We're a data-science/r&d team, so every project we build is usually accompanied with it's own Why do we do this?
So I suppose I view conda as a sufficiently general superset of what poetry is trying to achieve, so that poetry could happily work within conda when needed. Our use-case might be out-there, but having poetry automatically utilize the active conda environment has been a huge time-saver since the feature's introduction. Conda is a way more general environment manager, and is a widely adopted service in a ton of data science. Poetry is an elegant way to manage package creation, so having it work nicely inside conda makes sense from my perspective. |
It's also unclear how this should interact with the In any case, better documentation around when virtual environments will (and will not) be created would be very helpful. |
I created a personal python package where I practice replacing bash scripts and improve my use of In order to use a conda env as a poetry python interpreter I ensure the following local config settings are set for Furthermore, before I execute Anyhow, please feel free to step through the code (apologies in advance for the lack of documentation and refactoring) and see if it fits your use-case! Cheers! Edit:
|
PDM can create a virtualenv in project directory, as I mentioned in: #4055 (comment) |
Duplicates #4055. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Issue
Thank you all for your excellent work! And congratulations on cutting out a stable release! 🍾
My misunderstanding
Prior to reading the 1.0.0 release notes, my (wrong) mental model was that poetry always creates a new virtualenv for the project under consideration.
Now I've learned that it reuses the current virtualenv, if one is active, and that it now does the same for a current conda environment.
Current state
It is wonderful to see conda envs become a first-class citizen of poetry (#1432).
However, conspicuously, the PR's checkbox for "Updated documentation for changed code" remains unchecked 😁
And so, looking around in https://python-poetry.org/docs/, I fail to find mention of this behaviour. I guess I would put documentation in (at least) section "Managing environments". I would, however, also like to see it mentioned elsewhere.
Finally, when I am in an active conda environment and run
poetry install
, I see no indication that the current environment is being used/updated/modified. There is instead a lack of indication that a virtualenv is being created.Desired state
This is a wishlist, for the consideration of the designers:
poetry shell
, which helpfully says "Virtual environment already activated: "poetry debug info
Thank you for your efforts!
The text was updated successfully, but these errors were encountered: