-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Do not allow --target, --user, --root and --prefix together #7829
Comments
Also see #7777, which implemented the |
Current |
Flagging that there is a lot of nuance around the use / default values of I likely won't have the time or mental space to review this PR or participate in this discussion for a few weeks. |
@pradyunsg: Since it seems that you're in middle of something else at the moment, may I remind you that you already approved raising error on target and user$ pip install --target /tmp --user appdirs
ERROR: Can not combine '--user' and '--target' target and rootSomething is seriously wrong here since (not $ pip install --target /tmp/foo --root /tmp/bar appdirs
Collecting appdirs
Using cached appdirs-1.4.3-py2.py3-none-any.whl (12 kB)
Installing collected packages: appdirs
Successfully installed appdirs-1.4.3
$ ls /tmp/foo
$ tree /tmp/bar
/tmp/bar
└── tmp
└── pip-target-_apxmir1
└── lib
└── python
├── appdirs-1.4.3.dist-info
│ ├── DESCRIPTION.rst
│ ├── INSTALLER
│ ├── METADATA
│ ├── metadata.json
│ ├── RECORD
│ ├── top_level.txt
│ └── WHEEL
├── appdirs.py
└── __pycache__
└── appdirs.cpython-37.pyc target and prefixNot really helpful error: $ pip install --target /tmp --prefix /tmp appdirs
Collecting appdirs
Using cached appdirs-1.4.3-py2.py3-none-any.whl (12 kB)
Installing collected packages: appdirs
ERROR: Exception:
Traceback (most recent call last):
File "/home/cnx/.local/lib/python3.7/site-packages/pip/_internal/cli/base_command.py", line 199, in _main
status = self.run(options, args)
File "/home/cnx/.local/lib/python3.7/site-packages/pip/_internal/cli/req_command.py", line 185, in wrapper
return func(self, options, args)
File "/home/cnx/.local/lib/python3.7/site-packages/pip/_internal/commands/install.py", line 407, in run
use_user_site=options.use_user_site,
File "/home/cnx/.local/lib/python3.7/site-packages/pip/_internal/req/__init__.py", line 71, in install_given_reqs
**kwargs
File "/home/cnx/.local/lib/python3.7/site-packages/pip/_internal/req/req_install.py", line 795, in install
prefix=prefix,
File "/home/cnx/.local/lib/python3.7/site-packages/pip/_internal/locations.py", line 186, in get_scheme
dist_name, user, home, root, isolated, prefix
File "/home/cnx/.local/lib/python3.7/site-packages/pip/_internal/locations.py", line 118, in distutils_scheme
assert not (home and prefix), "home={} prefix={}".format(home, prefix)
AssertionError: home=/tmp/pip-target-wie7l92e prefix=/tmp user and rootInstall to $ pip install --user --root /tmp appdirs
Collecting appdirs
Using cached appdirs-1.4.3-py2.py3-none-any.whl (12 kB)
Installing collected packages: appdirs
Successfully installed appdirs-1.4.3
$ tree -a /tmp/home
/tmp/home
└── cnx
└── .local
└── lib
└── python3.7
└── site-packages
├── appdirs-1.4.3.dist-info
│ ├── DESCRIPTION.rst
│ ├── INSTALLER
│ ├── METADATA
│ ├── metadata.json
│ ├── RECORD
│ ├── top_level.txt
│ └── WHEEL
├── appdirs.py
└── __pycache__
└── appdirs.cpython-37.pyc user and prefix$ pip install --user --prefix /tmp appdirs
ERROR: Can not combine '--user' and '--prefix' as they imply different installation locations root and prefixInstall to $ pip install --root /tmp/foo --prefix /tmp/baz appdirs
Collecting appdirs
Using cached appdirs-1.4.3-py2.py3-none-any.whl (12 kB)
Installing collected packages: appdirs
Successfully installed appdirs-1.4.3
$ tree /tmp/foo/tmp/baz
/tmp/foo/tmp/baz
└── lib
└── python3.7
└── site-packages
├── appdirs-1.4.3.dist-info
│ ├── DESCRIPTION.rst
│ ├── INSTALLER
│ ├── METADATA
│ ├── metadata.json
│ ├── RECORD
│ ├── top_level.txt
│ └── WHEEL
├── appdirs.py
└── __pycache__
└── appdirs.cpython-37.pyc |
I'm not sure if it's time but this basically propose a dirty patch for the same issue as discussed in GH-4575. |
@pradyunsg and other @pypa/pip-committers, may we talk about this now? |
There are subtleties here, as @pradyunsg said. I appreciate that current behaviour is weird and likely broken in many cases, but see this xkcd comic 🙂 Specific things that should be considered:
That's quite a lot of research to do. With the new resolver work in full swing, and a release coming soon, I doubt many of the @pypa/pip-committers will have a lot of time to look at this issue in the near future. But if you were able to investigate some of the points above, and summarise your findings as you did with the current behaviour, that would help a lot when the discussion does get restarted. Sorry if this sounds like stalling on the issue - the work you've put in here is genuinely appreciated, and I'd love to get this tidied up. Just not right now 😉 |
I've been procrastinating on it for quite a while, and figured that incremental addition might be better since I don't have to rely on memory for the findings (I don't have the habit of noting things down, should start doing it some day 😉). From the log above, there are only three cases where is not already an error, all of which involving Anyway, to update the situation relating to this:
I'm on Debian testing and it seems that downstream 20.0.2 is using the falling back to user-site logic instead of hardcoding like before.
I can confirm that after a quick GitHub source search. I don't understand why would any sane human ever mix So I believe, the discussion here is whether to support |
It smells like |
--target
,--user
,--root
and--prefix
are mutually exclusive and simply don't make sense when used together. Instead of failing for irrelevant errors, the error should explicitly describe why it is not excepted. This is currently implemented in GH-7828. I move the discussion here since the PR to avoid distracting the code review process.The text was updated successfully, but these errors were encountered: