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
Interface to select preferred "user" or "home" sysconfig scheme for an environment #87478
Comments
While trying to migrate pip’s internal usages of distutils to sysconfig,1 I noticed there isn’t a way for pip to select a scheme for sysconfig.get_paths() for PyPy, for example, adds additional schemes "pypy" and "pypy_nt", and it’s not clear whether pip should use then for I would propose two changes to sysconfig:
I would be happy to work on a PR and iterate on the design if this sounds like a reasonable idea. For CPython, the implementation would be something like (to match distutils’s behaviour): def get_preferred_schemes():
if os.name == "nt":
return {
"prefix": "nt",
"home": "posix_home",
"user": "nt_user",
}
return {
"prefix": "posix_prefix",
"home": "posix_home",
"user": "posix_user",
} |
Adding Christian to the nosy list since IIRC you said something related to this a while ago. |
I wonder if the distro maintainers might be able to use this to reduce the patching they do for their schema? |
Do you need all three items or would "get_preferred_scheme(name: str) -> str" be sufficient? |
That would work as well (raising KeyError or ValueError if |
This seems like a good change to me. Making sure that the implementation is easily patchable sounds like a good plan, though I don't have any specific suggestions on what would be best. |
How do we move the discussion forward? I would really want this to be included in 3.10. Assuming distutils is going to be removed in 3.12, pip would be left with an extremely short window if this has to wait for another year. |
see also pypa/pip#9617 |
The Debian/Ubuntu packages have a local patch for distutils/setuptools introducing an --install-layout option. Maybe have the same for pip? The intention with renaming/moving site-packages to /usr/lib/python3/dist-packages is to avoid users damaging their system installation, like sudo python3 setup.py install overriding packages installed with the distro package manager. Just making this schema known, and making it the default would again allow pip acting on packages managed by the distro package manager. Otoh, there are use cases, where you want to use the Python provided by the Linux distro and run into issues with the custom dist-packages.
So the problem to solve is
|
Gentle ping again :) I’ve also created a PR for this.
Pip already has a similar mechanism. The default layout is
These need to be done in pip, so we’ll have a separate discussion on them elsewhere.
This is what this issue tries to address. A distribution can overwrite When in a virtual environment, it can return the same scheme as the upstream. Outside of a virtual environment, it can do whatever the platform sees fit, and pip (or whatever calls sysconfig) will install things into wherever it’s told to by the two functions. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: