Open charliermarsh opened 4 months ago
@gaborbernat - A related question: how does virtualenv
"know" to create site-packages for PyPy at .venv/lib/pypy3.10/site-packages
instead of .venv/lib/python3.10/site-packages
? Is that encoded in virtualenv
somewhere? Or is it read from the interpreter? Was trying to find it.
That's done here https://github.com/pypa/virtualenv/blob/main/src/virtualenv/create/via_global_ref/builtin/pypy/pypy3.py#L31 and https://github.com/pypa/virtualenv/blob/main/src/virtualenv/create/via_global_ref/builtin/pypy/common.py#L41. It knows to do that just for PyPy because of https://github.com/pypa/virtualenv/blob/main/src/virtualenv/create/via_global_ref/builtin/pypy/common.py#L13. The purelib/platlib paths are using the sysconfig information, which is inquired as part of https://github.com/pypa/virtualenv/blob/main/src/virtualenv/discovery/py_info.py#L80-L103.
Note that .venv/lib/pypy3.10/site-packages
is often refered to as purelib, and in CPython by default this aligns up with platlib, but CPython allows distributions to move this to their desired path. So ultimately, the question is: When you say .venv/lib/pypy3.10/site-packages
are you refering to platlib or purelib?
Ah yeah, I'm referring to purelib
. (Though I haven't really done the work yet to understand what happens when you, e.g., pip uninstall
and purelib
and platlib
are not the same thing.)
If sysconfig
is returning the purelib
and platlib
paths for the invoked interpreter, where / how do those get translated to paths for the virtualenv? E.g.:
>>> sysconfig.get_paths(scheme="venv")
{'stdlib': '/Users/crmarsh/.local/share/rtx/installs/python/3.12.0/lib/python3.12', 'platstdlib': '/Users/crmarsh/.local/share/rtx/installs/python/3.12.0/lib/python3.12', 'purelib': '/Users/crmarsh/.local/share/rtx/installs/python/3.12.0/lib/python3.12/site-packages', 'platlib': '/Users/crmarsh/.local/share/rtx/installs/python/3.12.0/lib/python3.12/site-packages', 'include': '/Users/crmarsh/.local/share/rtx/installs/python/3.12.0/include/python3.12', 'platinclude': '/Users/crmarsh/.local/share/rtx/installs/python/3.12.0/include/python3.12', 'scripts': '/Users/crmarsh/.local/share/rtx/installs/python/3.12.0/bin', 'data': '/Users/crmarsh/.local/share/rtx/installs/python/3.12.0'}
That depends. You can get the schema and inject your config vars of sys.prefix to calculate where it should go.
Thank you!
Filed some info in https://github.com/astral-sh/uv/issues/2095. (No obligation to chime in there.)
@edgarrmondragon - when you’re in a PyPy virtualenv, do you typically invoke Python as “pypy” or “python”? I’m trying to make some decisions around this with respect to #2316.
@edgarrmondragon - when you’re in a PyPy virtualenv, do you typically invoke Python as “pypy” or “python”? I’m trying to make some decisions around this with respect to #2316.
Actually, always as python
or python3.x
We don't officially support PyPy right now, this is more a note for the future, but we need to include a variety of
pypy
binaries / symlinks: