Bug report
Bug description:
Even when disabling the site initialization (passing -S), sysconfig.get_paths() still returns site-specific paths, as there's no way in the current API to express the unavailability of such paths. A lot of code does not take this use-case into account, and assumes these are paths that are currently in-use for the active environment.
$ python-SPython3.14.0a1+experimentalfree-threadingbuild (heads/main:de0d5c6e2e1, Oct232024, 15:37:46) [GCC14.2.120240910] onlinux>>>importsys>>>sys.path
['', '/usr/local/lib/python314t.zip', '/usr/local/lib/python3.14t', '/usr/local/lib/python3.14t/lib-dynload']
>>>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'}An example of this is ensurepip, which will still proceed and install pip to the site directories, despite the site module being disabled.
$ python-S-mensurepipLookinginlinks: /tmp/tmpqcwxcy4kRequirementalreadysatisfied: pipin/home/anubis/.virtualenvs/test-sysconfig-paths/lib/python3.14t/site-packages (24.3.1)
IMO, it should refuse to install when the site module is disabled, as there are no valid paths to install pip to under the current environment.
To make things worse, the result of sysconfig.get_paths(), currently, is inconsistent, and does not always return the same result (see #126789).
Newer APIs (#103481), should handle this scenario directly, by expressing directly the unavailability of purelib and platlib, for example.
CPython versions tested on:
3.9, 3.10, 3.11, 3.12, 3.13, 3.14, CPython main branch
Operating systems tested on:
Linux
Bug report
Bug description:
Even when disabling the
siteinitialization (passing-S),sysconfig.get_paths()still returns site-specific paths, as there's no way in the current API to express the unavailability of such paths. A lot of code does not take this use-case into account, and assumes these are paths that are currently in-use for the active environment.An example of this is
ensurepip, which will still proceed and install pip to the site directories, despite thesitemodule being disabled.IMO, it should refuse to install when the
sitemodule is disabled, as there are no valid paths to install pip to under the current environment.To make things worse, the result of
sysconfig.get_paths(), currently, is inconsistent, and does not always return the same result (see #126789).Newer APIs (#103481), should handle this scenario directly, by expressing directly the unavailability of
purelibandplatlib, for example.CPython versions tested on:
3.9, 3.10, 3.11, 3.12, 3.13, 3.14, CPython main branch
Operating systems tested on:
Linux