-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Clarifying virtualenv 20's -p behavior #1777
Comments
Did you read the detailed documentation under https://virtualenv.pypa.io/en/latest/user_guide.html#python-discovery? |
I'd say the first case is expected. The pypy and pypy3 parts though are likely a bug, and we'll need more information on it to pin it down. -p now rhoughly wants to be what |
I did see that page yeah, just before I filed this, but it still wasn't entirely clear to me (it certainly made me think some of this is intentional, even though I'm still not sure it's obvious to me this is significantly better than the old behavior but I certainly trust you to have thought more carefully than I have about it) But e.g. in that section I saw:
Which told me at least some part of this should be searching Also -- does that mean that the current recommended way to get the old behavior is to do the PATH searching external to |
Does this have any additional useful information to diagnose the second piece:
|
(If not I am likely going to step through things in a debugger maybe tomorrow or something) |
In virtualenv>=20, the behavior of -p is different. Specifically, -p takes something resembling more like a specification than the name of a binary. It's possible that this project should follow suit, but for the moment, even my own venvs configuration is broken :) so for now just reimplement the old behavior. See https://virtualenv.pypa.io/en/latest/user_guide.html#python-discovery for full details. And pypa/virtualenv#1777 for possible further clarification.
This could be improved. But basically it's not guaranteed to be searched on the
To make it easier to see separated into three sections and removed the lock acquire/release operation not relevant for this:
Follow-up items, created
As @mattip said above now we don't accept blindly found pythons... only if it satisfies the necessary invariants to then create a virtual environment from it. In this case, though we'll log a rejection message I think in the log. |
A ha! I see, thanks for the explanation. Sounds good thanks! Will follow the 2 follow-up tickets. |
Issue
Hi hi.
I apologize in advance, still digging through some of the issues on the tracker so this may be known, or even intentional, but
virtualenv>=20
's-p
behavior is confusing me quite a bit.Specifically, in pre-rewrite virtualenv,
-p
was somewhat simplish to me, it basically searchedPATH
for most of my uses of it.Post 20 though, it now seems to work significantly differently, so I wanted to confirm whether its new behavior is entirely expected/intentional. Specifically, here are some significant differences in what it does:
Setup both old and new virtualenv
On
virtualenv<20
, running-p python
searchesPATH
for an executable namedpython
and uses that to create a virtualenv (for me, this will find apypy
interpreter):which corresponds to:
where
/Users/julian/.local/bin/python --version
is that PyPy interpreter.But on >=20, it instead finds a CPython3.7 (the one virtualenv happens to be installed to in this case):
I see that's documented (the docs say using
python
will essentially find "any python"), but that still seems surprising, so I'm including it (seems likely it's intended in this case?).More importantly though, things that are on the
PATH
, are still not found. For instance, on virtualenv<20, runningwill find a
pypy
binary on myPATH
. But on virtualenv>=20 I instead get:even though there indeed is such a binary present:
Even more surprisingly is that if I ask for a PyPy3,
>=20
still seems to be searching for a PyPy2 (and still not consideringPATH
):with me having:
which worked on
<20
:So yeah -- are any / all of the above intended behavior? I can imagine reasons to change
-p
to not bePATH
-searching and instead have more of a language for finding a suitable interpreter without connection to what it's called, but at least a few of the above seem quite invasive, so figured I'd confirm. If it's intended I can obviously adjust my own workflow to search PATH first and give the absolute path to virtualenv.TIA!
Environment
OS: macOS, Python / PyPy installed via Homebrew
``pip list`` of the host python where ``virtualenv`` is installed
The text was updated successfully, but these errors were encountered: