Description
Just carrying over my idea in #1056 (comment), for proper dedicated discussion.
AFAIK, there are 3 possible schemes for packages:
- "system" - for system/global packages (
--system
)- "user" - for packages installed in user space (
--user
)- "local" - for virtualenv packages (
--local
)pip enforces a "working" scheme on every run. Outside a virtualenv, the default working scheme would be "system" (It should really be "user", that's another issue #1668). Inside a virtualenv, the default working scheme should be "local". Passing
--system
or--user
or--local
overrides the working scheme.Only packages in the same scheme as the working scheme can be modified. By modifying, I mean installing or uninstalling a package. Trying to modify a package in a different scheme is not allowed and pip would print a message and error out.
So, modifying a package in system scheme with a "user" working scheme is not allowed. Nor is modifing a package in user scheme with a "system" working scheme. Niether are the other permutations with "local".
I think this results in a pretty simple behaviour model.
As @ncoghlan pointed out, this would need some logic to understand that user installs shadow system ones. Also, I would slightly change this to spell it like --scheme {global,user,venv}
because I like how this signifies exclusiveness of the behaviours better than plain flags do and is consistent with some internal configuration stuff.
Additionally, while doing this:
- preparatory work of Default to --user #1668 can also be done, meaning that defaulting to user would just be flipping the default (something like what we did for
--upgrade-strategy
). - addresses pip install -U does not remember whether a package was installed with --user #1056 by requiring the user to specify the scheme that they are working with.