Skip to content
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

Support for alternative installation schemes #120

Open
greyltc opened this issue Apr 24, 2022 · 12 comments
Open

Support for alternative installation schemes #120

greyltc opened this issue Apr 24, 2022 · 12 comments
Labels
component: core Related to core installation logic type: feature A self-contained enhancement or new feature

Comments

@greyltc
Copy link

greyltc commented Apr 24, 2022

From using this in Linux, it seems like the installation scheme used here is always "posix_prefix." I think it would be helpful to have the option to use "posix_user" too!

@FFY00
Copy link
Member

FFY00 commented Apr 24, 2022

This also plays into vendor layout customizations, they could add their layouts to Python and then select them with this option.

@pradyunsg pradyunsg changed the title [feature request] option to specify installation scheme Support for alternative installation schemes Apr 24, 2022
@pradyunsg
Copy link
Member

pradyunsg commented Apr 24, 2022

This should already be possible via the API, which takes a mapping containing the installation scheme’s resolved paths: https://installer.readthedocs.io/en/latest/api/destinations/#installer.destinations.SchemeDictionaryDestination

Could you be a bit more specific about what you are trying to do, and what you’re requesting here?

@pradyunsg pradyunsg added the type: feature A self-contained enhancement or new feature label Apr 24, 2022
@uranusjr
Copy link
Member

I’m just guessing but maybe the goal is to install packages to the user site with the CLI. Currently python -m installer --destdir ~/.local does not do the “right thing”.

@FFY00
Copy link
Member

FFY00 commented Apr 25, 2022

Yes, that is not the goal of destdir. I think this would look something like python -m installer --scheme posix_user.

@uranusjr
Copy link
Member

I’m more inclined to think installer’s CLI shouldn’t get into alternative schemes at all, and should probably remove --destdir altogether. But if y’all do want to do this, it’d be best to rethink how context var override should work (what --destdir currently do but only partially).

Right now only base can be overridden (via --destdir), but if you support changing the scheme, people will eventually want at least userbase and platbase, and eventually you’d get into the same situation of pip where people want to use the CLI for all sorts of things like populating an environment on Windows running Python 3.10 to use on a Repsberry Pi with Python 3.6.

@eli-schwartz
Copy link
Contributor

Base is never overridden by --destdir as they do conceptually different things.

e.g.

'purelib': '{base}/lib/python{py_version_short}/site-packages'

Specifically, base for a system installation is /usr, so that fills out as

/usr/lib/python3.10/site-packages

destdir=./foo prepends to that, so you end up with

./foo/usr/lib/python3.10/site-packages

And then you pack up the ./foo directory into a system image and install it as an overlay onto / so that the final product gets files in /usr/lib/python3.10/site-packages

Currently python -m installer --destdir ~/.local does not do the “right thing”.

This is a hard command-line API violation, based on the incorrect notion that destdir is intended to override {base}. It doesn't do the right thing, because as an API violation it produces garbled output.

if you support changing the scheme, people will eventually want at least userbase and platbase, and eventually you’d get into the same situation of pip where people want to use the CLI for all sorts of things like populating an environment on Windows running Python 3.10 to use on a Repsberry Pi with Python 3.6.

This is just a standard slippery slope. I fully believe in the ability of this project's maintainers to make rules and stick with them, and people already wanted to do all those things you fear, but their suggestions were rejected.

Accepting mostly-unrelated features should not necessitate backing down on previous stances taken. And the use case of this ticket is pretty clearly defined. It allows the CLI to ask sysconfig for one of a radio list of installation layouts. The two example cases given are:

  • implementing the equivalent of pip install --user,
  • implementing "install to wherever sysconfig says that debian packages put their python modules, instead of where users put them"

A radio list of schemes known to sysconfig is a pretty significant difference from "next thing you know, people will be asking to support arbitrary format-string definition of the install environment".

@pradyunsg
Copy link
Member

I’d like to request folks to hold off going this direction in the discussion, based off of a guess.

I specifically asked for details, to better understand why OP wants this. Let’s wait for OP (or someone else who wants this functionality) to elaborate why they want it.

@greyltc
Copy link
Author

greyltc commented Apr 30, 2022

I've been trying to learn a bit more about python's packaging internals and I found myself reading
https://docs.python.org/3/library/sysconfig.html?highlight=installation%20scheme#installation-paths
which describes the several different instillation schemes python supports on equal terms. I was just trying to use installer as an educational tool to test these different schemes in different environments and platforms and I found I had no obvious way of asking installer to use a specific scheme. I didn't see an obvious reason why the scheme shouldn't be something I could select (such as via --scheme nt_user or --scheme osx_framework_user for example) and so I made this feature request.

@uranusjr
Copy link
Member

uranusjr commented May 3, 2022

The obvious way is to use the Python API I guess (which is the primary intention to the project). I’m not saying a CLI flag as you proposed isn’t useful though!

@FFY00
Copy link
Member

FFY00 commented May 4, 2022

Other use-case for this is allowing vendor to install to their custom schemes, something that our proposal to standardize vendor patching (https://gist.github.com/jaraco/b48e1acd05ecd3e54ddf0f04f91065c3) relies on. I think this is a very significant use-case, and is simple enough to support.

@pradyunsg
Copy link
Member

If someone wants to file a PR implementing such a flag, please feel welcome to do so!

@pradyunsg
Copy link
Member

Cross referencing #145, which takes this a step further -- let's bring over all the logic that pip has currently, for locating files, and move it into this library.

@pradyunsg pradyunsg added the component: core Related to core installation logic label Dec 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: core Related to core installation logic type: feature A self-contained enhancement or new feature
Projects
None yet
Development

No branches or pull requests

5 participants