-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
How to find the correct value for home
in pyvenv.cfg
using documented APIs?
#114476
Comments
home
in pyvenv.cfg
using document APIs?home
in pyvenv.cfg
using documented APIs?
Turning that question around, what are you needing to do that you can't do by simply using the (To be clear, what I'm saying is that we could enhance |
We're using a native reimplementation of virtualenv creation that are faster than the |
Cool. I don't think there's a documented API that does what |
I think to make If you know you're running in the base interpreter, You could also consider implementing your venv with a different approach, such as |
We unfortunately often have the case that we are already in a venv and then e.g. want to create a temporary build venv or because the user gave as a venv python.
I've been looking at the virtualenv package which seems to rely on Would it be possible to expose enough information to make this not a hack? I'm talking about standardizing an API to get the value of |
If you just want the value of home, then why not find and read pyvenv.cfg directly? Alternatively, if you can dive into getpath and sort out why |
Sorry if i didn't phrase that clearly, but the intent is to have a general purpose (bare) venv creator that you can pass any python interpreter as base, be it a global one or a venv one. We cache a query to some interpreter metadata the first time we see an interpreter and can then create venvs quickly. We could create a venv once when we see a new interpreter and read the value of I'd be happy not to change anything existing - after all |
If you're passing the Python executable path as base, you should be able to easily look for an existing pyvenv.cfg and then just copy it directly into any new venvs you want to create with the same base. At least This is assuming you want a "compatible" venv, which would only be so that pip knows where to install stuff. If you don't care about pip, then it'll be way better to set Footnotes
|
I'd like to create virtual environments and to do so, i need to fill in the value of
home
inpyvenv.cfg
. All implementations I found use the undocumented, privatesys._base_executable
. Is there a platform-independent, ideally cross-interpreter way to determine the value of the python home for a new virtualenv using documented APIs?cpython's
venv
modules (pypy contains the same module):cpython/Lib/venv/__init__.py
Line 134 in e14930f
virtualenv
: https://github.com/pypa/virtualenv/blob/d9fdf48d69f0d0ca56140cf0381edbb5d6fe09f5/src/virtualenv/discovery/py_info.py#L136-L156On linux/mac, using the parent of the resolved
sys.executable
seems to be sufficient, but specifically on windows it isn't clear what to use.The text was updated successfully, but these errors were encountered: