-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
Warning about the use of site-specific path when the site
initialization has been disabled
#126793
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
Comments
I'm not sure I agree with the assertion that |
I would agree with that if the What makes things messy is that on top of the customizations you mentioned, the In practice, this means that I think we should think conceptually of |
This sounds reasonable to me, however...
Not entirely (a lot is handled in getpath, IIRC independent of the
Here's where it gets complicated. There's strictly nothing wrong with Perhaps this works:
I'm sure there are new edge cases introduced by a definition like that (if it works at all, I haven't thought it all the way through yet), but perhaps those are easier to fix/handle? |
(I realized I went a bit off track when writing the reply below, but I am keeping it since it's useful) Right, I am aware that Here's my understanding of what happens:
So, there may be a possibility for If there's anything else that I am missing, let me know.
I think what we are running into here is the fact that virtual environments probably shouldn't be implemented by the My proposal to move forward:
|
FWIW, the mere presence of a |
This is no longer relevant, as GH-126985 made virtual environments no longer dependent on the |
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.An example of this is
ensurepip
, which will still proceed and install pip to the site directories, despite thesite
module being disabled.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
andplatlib
, 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
The text was updated successfully, but these errors were encountered: