-
-
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
sysconfig
data inconsistencies caused by the disabling the site
initialization on virtual environments
#126789
Comments
Things are a bit messy, as the virtual environment mechanism is technically part of the Anyway, to match this model, if $ python -S
Python 3.14.0a1+ experimental free-threading build (heads/main:de0d5c6e2e1, Oct 23 2024, 15:37:46) [GCC 14.2.1 20240910] on linux
>>> import sysconfig
>>> sysconfig.get_paths()
{'stdlib': '/usr/local/lib/python3.14t', 'platstdlib': '/usr/local/lib/python3.14t', 'purelib': '/usr/local/lib/python3.14t/site-packages', 'platlib': '/usr/local/lib/python3.14t/site-packages', 'include': '/usr/local/include/python3.14td', 'platinclude': '/usr/local/include/python3.14td', 'scripts': '/usr/local/bin', 'data': '/usr/local'}
>>> import site
>>> site.main()
>>> sysconfig.get_paths()
{'stdlib': '/usr/local/lib/python3.14t', 'platstdlib': '/home/anubis/.virtualenvs/test-sysconfig-paths/lib/python3.14t', 'purelib': '/home/anubis/.virtualenvs/test-sysconfig-paths/lib/python3.14t/site-packages', 'platlib': '/home/anubis/.virtualenvs/test-sysconfig-paths/lib/python3.14t/site-packages', 'include': '/usr/local/include/python3.14td', 'platinclude': '/usr/local/include/python3.14td', 'scripts': '/home/anubis/.virtualenvs/test-sysconfig-paths/bin', 'data': '/home/anubis/.virtualenvs/test-sysconfig-paths'} |
Correction: |
Signed-off-by: Filipe Laíns <[email protected]>
sysconfig.get_paths()
inconsistencies caused by the disabling the site
initialization on virtual environmentssysconfig
data inconsistencies caused by the disabling the site
initialization on virtual environments
While fixing the main bug, I have noticed that the IMO this is worth to fix, but we probably shouldn't backport it as it is a significant behavior change, and there's a possibility it would break existing user code. |
Just some more background on this, |
Bug report
Bug description:
Currently, running the Python interpreter with
-S
(disabling thesite
module initialization) causes several inconsistenciessysconfig.get_paths()
depends on whethersysconfig
was imported before or after thesite
initializationCurrently,
sysconfig
calculates the paths at import time and caches them. This results in it resulting incorrect paths if thesite
initialization happens aftersysconfig
was imported.Expected output when the
site
module has been initialized:And just to make sure this is not dependent on the interpreter being run with
-S
, and rather on thesysconfig
import time.CPython versions tested on:
3.9, 3.10, 3.11, 3.12, 3.13, 3.14
Operating systems tested on:
Linux
Linked PRs
The text was updated successfully, but these errors were encountered: