Open y5c4l3 opened 3 days ago
A fuller comparison for reference:
>>> import poc
... import sys
... for attr in ['executable', 'path', 'prefix', 'base_prefix', 'exec_prefix', 'base_exec_prefix']: print(f'sys.{attr}:', getattr(sys, attr))
...
Py_GetProgramName: python
Py_GetProgramFullPath: /home/y5/micromamba/envs/py3.13/bin/python
Py_GetPath: /home/y5/micromamba/envs/py3.13/lib/python313.zip:/home/y5/micromamba/envs/py3.13/lib/python3.13:/home/y5/micromamba/envs/py3.13/lib/python3.13/lib-dynload
Py_GetPrefix: /home/y5/micromamba/envs/py3.13
Py_GetExecPrefix: /home/y5/micromamba/envs/py3.13
sys.executable: /home/y5/micromamba/envs/py3.13/bin/python
sys.path: ['', '/home/y5/micromamba/envs/py3.13/lib/python313.zip', '/home/y5/micromamba/envs/py3.13/lib/python3.13', '/home/y5/micromamba/envs/py3.13/lib/python3.13/lib-dynload', '/home/y5/micromamba/envs/py3.13/lib/python3.13/site-packages']
sys.prefix: /home/y5/micromamba/envs/py3.13
sys.base_prefix: /home/y5/micromamba/envs/py3.13
sys.exec_prefix: /home/y5/micromamba/envs/py3.13
sys.base_exec_prefix: /home/y5/micromamba/envs/py3.13
# inside venv
>>> import poc
... import sys
... for attr in ['executable', 'path', 'prefix', 'base_prefix', 'exec_prefix', 'base_exec_prefix']: print(f'sys.{attr}:', getattr(sys, attr))
...
Py_GetProgramName: python
Py_GetProgramFullPath: /tmp/foo/bin/python
Py_GetPath: /home/y5/micromamba/envs/py3.13/lib/python313.zip:/home/y5/micromamba/envs/py3.13/lib/python3.13:/home/y5/micromamba/envs/py3.13/lib/python3.13/lib-dynload
Py_GetPrefix: /home/y5/micromamba/envs/py3.13
Py_GetExecPrefix: /home/y5/micromamba/envs/py3.13
sys.executable: /tmp/foo/bin/python
sys.path: ['', '/home/y5/micromamba/envs/py3.13/lib/python313.zip', '/home/y5/micromamba/envs/py3.13/lib/python3.13', '/home/y5/micromamba/envs/py3.13/lib/python3.13/lib-dynload', '/tmp/foo/lib/python3.13/site-packages']
sys.prefix: /tmp/foo
sys.base_prefix: /home/y5/micromamba/envs/py3.13
sys.exec_prefix: /tmp/foo
sys.base_exec_prefix: /home/y5/micromamba/envs/py3.13
Documentation
Documentation suggests
sys.prefix
as an alternative toPy_GetPrefix
in the deprecation note hereand it seems correct:
But strictly speaking,
sys.base_prefix
is the real counterpart rather thansys.prefix
when it involves venv:Source: #125235
Linked PRs