Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Closed
Description
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 initialization
Currently,sysconfig calculates the paths at import time and caches them. This results in it resulting incorrect paths if thesite initialization happens aftersysconfig was imported.
$python-SPython3.14.0a1+experimentalfree-threadingbuild (heads/main:de0d5c6e2e1,Oct232024,15:37:46) [GCC14.2.120240910]onlinux>>>importsysconfig>>>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'}>>>importsite>>>site.main()>>>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'}
Expected output when thesite module has been initialized:
$pythonPython3.14.0a1+experimentalfree-threadingbuild (heads/main:de0d5c6e2e1,Oct232024,15:37:46) [GCC14.2.120240910]onlinuxType"help","copyright","credits"or"license"formoreinformation.>>>importsysconfig>>>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'}
And just to make sure this is not dependent on the interpreter being run with-S, and rather on thesysconfig import time.
$python-SPython3.14.0a1+experimentalfree-threadingbuild (heads/main:de0d5c6e2e1,Oct232024,15:37:46) [GCC14.2.120240910]onlinux>>>importsite>>>site.main()>>>importsysconfig>>>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'}
CPython versions tested on:
3.9, 3.10, 3.11, 3.12, 3.13, 3.14
Operating systems tested on:
Linux
Linked PRs
- GH-126789: fix some sysconfig data on late site initializations #126812
- [3.13] GH-126789: fix some sysconfig data on late site initializations #126918
- [3.12] GH-126789: fix some sysconfig data on late site initializations #126919
- gh-126789: Correct sysconfig test exclusions for iOS and Android. #126941
- [3.13] gh-126789: Correct sysconfig test exclusions for iOS and Android. (GH-126941) #126950
- [3.12] gh-126789: Correct sysconfig test exclusions for iOS and Android. (GH-126941) #126959
- GH-126789: fix some sysconfig data on late site initializations #127729