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

Support a --venv flag similar to pipenv #401

Closed
1 task done
klardotsh opened this issue Aug 21, 2018 · 10 comments
Closed
1 task done

Support a --venv flag similar to pipenv #401

klardotsh opened this issue Aug 21, 2018 · 10 comments

Comments

@klardotsh
Copy link

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

Issue

pipenv supports a flag --venv flag that simply prints the path to the existing venv, or returns a non-0 status code if it doesn't exist. This allows solutions like dense-analysis/ale#1656 to auto-detect (without unwanted side effects) whether pipenv should be used to run, for example, a linter.

The closest thing I've found in poetry so far to this effect is debug:info, which will unfortunately auto-create the virtualenv if it doesn't exist, which would lead to false positives in scenarios like the ALE one.

I may be able to take a crack at this one personally, I don't imagine it'll be the hardest task in the world.

@jacebrowning
Copy link
Contributor

poetry show will fail if the virtual environment needs to be created and poetry show -v includes the path to the virtual environment if it exists.

@klardotsh
Copy link
Author

Unfortunately poetry show does not appear to fail correctly if the venv needs created, instead it creates it anyway:

(spoonman) rendering » poetry show -v
Creating virtualenv rendering-py3.7 in /home/j/.cache/pypoetry/virtualenvs
Using virtualenv: /home/j/.cache/pypoetry/virtualenvs/rendering-py3.7

@yunti
Copy link

yunti commented Sep 7, 2018

Agreed it would be better if poetry show -v didn't create a venv if it didn't find one as the command name leads the user to expect this is how it works.

@bersace
Copy link

bersace commented Sep 12, 2018

Hi,

Coupled with direnv, is use pipenv --venv (which is now very fast) to auto activate the venv on cd. It's like callink poetry shell on cd-ing into project directory. I find this very helpful when opening various terminals on the same project.

Having a way to query venv path quickly would be very nice.

Regards,

@ghost ghost mentioned this issue Oct 1, 2018
@zymergen-luke
Copy link

I have a similar use case where I'd like to activate the virtualenv programmatically (without resorting to nesting shells).

source ${pipenv --venv}/bin/activate

works well for me, but unfortunately there is no easy alternative for poetry.

@K900
Copy link
Contributor

K900 commented Nov 6, 2018

I'm up to write a patch to add this if there's a chance for it to be accepted. @sdispater?

@zymergen-luke
Copy link

@K900 I had some spare time this morning so I threw together a quick patch myself. Want to take a look and see if that's roughly what you have in mind?

@zymergen-luke
Copy link

This can be closed now since @sdispater added a new feature in #731

poetry env info --path

will return the path to the environment.

You can call the following to activate your environment consistently:

source ${poetry env info --path}/bin/activate

@garyo
Copy link

garyo commented Dec 14, 2018

Agreed, this is the way to go -- thanks, @sdispater !. And to follow up on @zymergen-luke , for you Windows folks out there writing shell functions, it's .../Scripts/activate rather than .../bin/activate.

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
None yet
Projects
None yet
Development

No branches or pull requests

8 participants