Skip to content
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

Deprecation of Py_GetPrefix-family APIs should document the sys.base_* counterparts #125313

Closed
y5c4l3 opened this issue Oct 11, 2024 · 2 comments
Closed
Labels
docs Documentation in the Doc dir

Comments

@y5c4l3
Copy link
Contributor

y5c4l3 commented Oct 11, 2024

Documentation

Documentation suggests sys.prefix as an alternative to Py_GetPrefix in the deprecation note here

Deprecated since version 3.13, will be removed in version 3.15: Get sys.prefix instead.

and it seems correct:

>>> import poc # CPython module that prints `Py_GetPrefix` on init
Prefix: /home/y5/micromamba/envs/py3.13
>>> import sys; print(sys.prefix); print(sys.base_prefix)
/home/y5/micromamba/envs/py3.13
/home/y5/micromamba/envs/py3.13

But strictly speaking, sys.base_prefix is the real counterpart rather than sys.prefix when it involves venv:

# inside venv
>>> import poc
Prefix: /home/y5/micromamba/envs/py3.13
>>> import sys; print(sys.prefix); print(sys.base_prefix)
/tmp/foo
/home/y5/micromamba/envs/py3.13

Source: #125235

Linked PRs

@y5c4l3
Copy link
Contributor Author

y5c4l3 commented Oct 11, 2024

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

vstinner pushed a commit that referenced this issue Oct 21, 2024
…ion notes (#125317)

Prefer `sys.base_*` paths in `Py_Get(Exec)Prefix` deprecation notes.

Signed-off-by: y5c4l3 <y5c4l3@proton.me>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Oct 21, 2024
…precation notes (pythonGH-125317)

Prefer `sys.base_*` paths in `Py_Get(Exec)Prefix` deprecation notes.

(cherry picked from commit 7d88140)

Co-authored-by: Y5 <124019959+y5c4l3@users.noreply.github.com>
Signed-off-by: y5c4l3 <y5c4l3@proton.me>
@vstinner
Copy link
Member

Fixed by change 7d88140.

vstinner pushed a commit that referenced this issue Oct 21, 2024
…eprecation notes (GH-125317) (#125776)

gh-125313: Prefer `sys.base_*` paths in `Py_Get(Exec)Prefix` deprecation notes (GH-125317)

Prefer `sys.base_*` paths in `Py_Get(Exec)Prefix` deprecation notes.

(cherry picked from commit 7d88140)

Signed-off-by: y5c4l3 <y5c4l3@proton.me>
Co-authored-by: Y5 <124019959+y5c4l3@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir
Projects
None yet
Development

No branches or pull requests

2 participants