Skip to content
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

Cannot use multiple environment per project with virtualenvs.in-project=True #2404

Closed
3 tasks done
melMass opened this issue May 11, 2020 · 7 comments
Closed
3 tasks done
Labels
kind/question User questions (candidates for conversion to discussion)

Comments

@melMass
Copy link

melMass commented May 11, 2020

  • I am on the latest Poetry version.

  • I have searched the issues of this repo and believe that this is not a duplicate.

  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).

  • Mojave 10.4.6:

  • Poetry version 1.0.5:

Issue

Hi,

I'm switching from Pipenv to Poetry, and for now, it's been all for the better!

One aspect of poetry that I like a lot it multiple environments per project As shown in the doc here

The first setting I set in Poetry was virtualenvs.in-project which create a .venv in the project root.

Now let's say I want to be able to run tests on both python 2 and python 3, one cannot just switch the environment but the environment gets overwritten.

Is there a way to use both features at the same time? If so how?

Thanks a lot

@melMass melMass added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels May 11, 2020
@finswimmer finswimmer added kind/question User questions (candidates for conversion to discussion) and removed kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels May 12, 2020
@finswimmer
Copy link
Member

Hello @melMass,

if you have an in-project virtual environment this will always take precedence over any other location. So if you plan to use multiple envs you have to set in-project to false. This can be done also on a per project base using the --local parameter.

fin swimmer

@melMass
Copy link
Author

melMass commented May 12, 2020

Hello @finswimmer,

Thanks for the confirmation, is there a reason for this?
Can't we create a .venv2.7.15 & .venv3.7.xx and use poetry use to switch between them?

The general idea is that I don't write anything to the system disk (well as little as possible).
I don't like the concept of having a general place for all envs but if there is no plan for any of this I will find a way using custom path and your --local trick for the projects that use multiple python!

@finswimmer
Copy link
Member

Hello again,

I just made a short test, but it looks like poetry config virtualenvs.path ./ would achieve what you are asking for.

@melMass
Copy link
Author

melMass commented May 13, 2020

Perfect !!

This is exactly what I was after.
I will look into it but is there a way to customize the name of the folder :) ?

For reference here is my setup using pyenv:

cd project
poetry config --local virtualenvs.path ./
poetry config --local virtualenvs.in-project false
RM -rf .venv # (remove the old one manually)

pyenv global 3.7.4 2.7.15 # enable both python2 and python3

pip2 install virtualenv
poetry use 2.7.15
poetry install

poetry use 3.7.4
poetry install

@finswimmer
Copy link
Member

Fine :)

You cannot modify the name of the virtual environment folder itself. poetry expect a specific format to be able to find the correct venv for the project and python version. With virtualenvs.path you just define the place where it should search.

fin swimmer

@melMass
Copy link
Author

melMass commented May 14, 2020

Thanks for the support!
Yes I realized the names weren’t random but linked to the project which is fine also.

Coming from pipenv poetry has been a bless!!

Copy link

github-actions bot commented Mar 3, 2024

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/question User questions (candidates for conversion to discussion)
Projects
None yet
Development

No branches or pull requests

2 participants