-
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
Expose Poetry's virtualenv #198
Comments
It sounds reasonable, but I have concerns about Windows compatibility. Pipenv seems to discriminate Windows users and AFAIK |
I don't use Windows so I'll leave that part as an exercise to the reader. |
I'll be happy to contribute then :-) |
The output of the virtualenv path is already implemented but only when you use the Regarding the |
I'd like to give this a go, but I'll need some help (probably my first code contribution to any project). I believe you can't inject a script into the running shell from python, so we'll need to spawn a new shell. How should I approach this? |
FWIW, I'd be happy to test/fix/implement things on Windows. I really like poetry and am keen for this functionality. |
@cauebs look at run.py in commands to starts. |
Thanks for the tip, @jgirardet. I gave it a go, it seems to work and I opened #201. |
Here's a workaround to get it: |
I will also gently remind about a possibility to have a local |
@moigagoo @ethanhs I think #201 is close to being merged, but it only features provisional support for Windows (which hasn't even been tested yet). Would you take a look and let me know how I can improve it? It would probably be important to know how to properly which program to run, if not |
@cauebs Thanks! I think |
@moigagoo I use cmd as my main shell, so I would strongly disagree. |
@ethanhs Sorry, I didn't mean to offend. Anyway, spawning the shell the command was called in seems like the right choice. |
I could try implementing this, but I really don't have a way to test it. |
Having some problems getting this to work. Running I tried subbing in This is on mac with zsh. Just installed poetry today. |
I'm seeing the same issue as @cyniphile. I'm also using zsh. |
@cyniphile @Mokubyow I was also seeing your issue with In my case this issue was caused by configuration differences in Relevant bits: rcs are run for every shell instantiation, but profiles are only run by the login shell. If you move your unconditional path modifications (like adding I don't know how much of this issue can be resolved on Poetry's part, but I resolved it to my satisfaction by moving several path edits into |
thanks, @seansfkelley that was my issue. I was actually loading In other news, it would be nice for poetry shell to activate the virtual environment so I can get the nice parentheses showing the env in my command line. I only know I'm in a virtualenv shell from running |
@cyniphile We don't change the prompt at the moment because it would require specific implementations for different shells. If someone opens a PR with an initial implementation, I'm sure it would be very welcome :) |
@cauebs with the caveat that I'm not super knowledgable in this domain, I tend to disagree with the way Is it not viable to simply Thanks for your contribution here, not trying to be one of those ungrateful open source users. I would be happy to try to figure out and |
To be quite honest, I understand that it may seem simple, but as far as I know you can't alter the environment for a parent process. We could do what Pipenv does, which involves running the shell in a subprocess just as well, but then making it run the source command automatically (and that requires some very complex magic implemented by pexpect's ptyprocess). Now, I don't currently have the time to delve into this (https://github.com/pexpect/ptyprocess/blob/master/ptyprocess/ptyprocess.py#L178-L339), especially taking into account that all we would get is the prompt. So, in a way, you're perfectly right: we could do this by "simply" sourcing the activation scripts. However, it's not an easy task. Rest assured that if we eventually run into any problems with the current approach, I'll be the first one to give this alternative a go. And you didn't sound ungrateful at all. Open source relies on criticism and feedback just as much as it does on code contributions. It's always good to reevaluate our past decisions, so thanks for that :) |
I have already suggested a simple solution in some other issue, but I will repeat it. Why do I like it?
Are there any drawback in this solution that I do not see? |
(what does the
Not true; there are different
Also not true; POSIX only specifies |
Sorry, for not describing it well enough. So, you can use this path in any way you want on your platform. You can use Examples:
That was my point. I hope that it makes sense. Or it can output just the base path for the |
You are both missing my point. How do you suggest we run I'll reiterate:
I don't see how this would improve About the venv path, it's already available in the |
By the way, we are drifting off the topic proposed by this issue. I think it has already been resolved and could be closed. If you have any other specific suggestion or complaint, feel free to look the issues pertinent to it or open new ones ;) |
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. |
If the user doesn't have an active virtualenv, Poetry is already creating and using a default per-project virtualenv behind the scenes. There is no easy way to get to it after it's created.
If you'd be willing to accept a PR to this effect, I'd be happy to contribute the following:
poetry shell
command equivalent topipenv shell
poetry add/remove/install
output the path to the virtualenv that it's using if there is no active virtualenvI know that your current available alternative is
poetry run
. My problem with it is that it gets verbose fast.poetry run python -m X
instead of justX
in an activated virtualenv.The text was updated successfully, but these errors were encountered: