-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Mutually exclusive --target, --user and --prefix #4557
Conversation
Thanks for this! ^.^ @techtonik You have a failing test, could you look into it? |
I can't read the test right away. Not clear for me what is it doing. Some methods were deprecated and I don't really have the time to study them. |
fix for test failure: diff --git a/tests/functional/test_install_reqs.py b/tests/functional/test_install_reqs.py
index 93592b2..1fedb20 100644
--- a/tests/functional/test_install_reqs.py
+++ b/tests/functional/test_install_reqs.py
@@ -262,6 +262,7 @@ def test_wheel_target_with_prefix_in_pydistutils_cfg(script, data,
virtualenv):
# Make sure wheel is available in the virtualenv
script.pip('install', 'wheel')
+ script.pip('download', 'setuptools', 'wheel', '-d', data.packages)
virtualenv.system_site_packages = True
homedir = script.environ["HOME"]
script.scratch_path.join("bin").mkdir() |
@techtonik This indeed does fix the test. Could you add this to your PR? In fact, you don't need to install wheel for this test. |
The tests have since changed, so See b709b1e#diff-0ef5cb8465369ba3cca1484fcfb75e7fL226 Could you update the PR @techtonik? |
def test_wheel_target_with_prefix_in_pydistutils_cfg( | ||
script, data, virtualenv, common_wheels): | ||
# pip needs `wheel` to build `requiresupper` wheel before installing | ||
# (or to install it?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to build it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Fixed the comment.
Hello! I am an automated bot and I have noticed that this pull request is not currently able to be merged. If you are able to either merge the |
news/4111.bugfix
Outdated
@@ -0,0 +1 @@ | |||
Fix ``pip install --target`` by making ``--target``, ``--user``, and ``--prefix`` mutually exclusive. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would phrase this as:
pip install `--target` is now mutually exclusive with `--user` and `--prefix`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Travis outage? |
The pypy job is flaky because of an upstream pytest bug. #4687 should help with that. No idea about the py34 job though. I've restarted both of them. |
Looks like it doesn't help. Still some problems on Travis with websockets, probably unrelated but still.. https://www.traviscistatus.com/ |
Hello! I am an automated bot and I have noticed that this pull request is not currently able to be merged. If you are able to either merge the |
Also override defaults set somewhere (e.g. .pydistutils.cfg) when command line switches are given.
Replace ``--no-use-wheel`` with ``--no-binary=:all:``
Replace --no-use-wheel with --no-binary=:all: and remove assertion of deprecation message.
Looks like `--target` doesn't use packages installed in parent environment, so there is no sense to install `wheel` in parent https://travis-ci.org/pypa/pip/jobs/268573000#L547
It is not installing wheel. Either `pip` need to build wheel, which is impossible without `wheel` package, or it can not install wheels without `wheel` https://travis-ci.org/pypa/pip/jobs/268577126#L547
"Can not perform a '--user' install. User site-packages are not visible in this virtualenv." https://travis-ci.org/pypa/pip/jobs/268627056#L609
I am out of mana. ( |
I think this is an important fix and would love to help push across the finish line. I believe this fixes the merge conflict: diff --cc src/pip/_internal/locations.py
index 5a20c92a,1043e57a..00000000
--- a/src/pip/_internal/locations.py
+++ b/src/pip/_internal/locations.py
@@@ -155,10 -155,12 +155,12 @@@ def distutils_scheme(dist_name, user=Fa
# NOTE: setting user or home has the side-effect of creating the home dir
# or user base for installations during finalize_options()
# ideally, we'd prefer a scheme class that has no side-effects.
- assert not (user and prefix), "user={0} prefix={1}".format(user, prefix)
- assert not (home and prefix), "home={0} prefix={1}".format(home, prefix)
- assert not (home and user), "home={0} user={1}".format(home, user)
+ assert not (user and prefix), "user={} prefix={}".format(user, prefix)
- i.user = user or i.user
- if user:
++ assert not (home and prefix), "home={} prefix={}".format(home, prefix)
++ assert not (home and user), "home={} user={}".format(home, user)
+ if user or home:
i.prefix = ""
+ i.user = user or i.user
i.prefix = prefix or i.prefix
i.home = home or i.home
i.root = root or i.root |
I think I did that right. @techtonik Could you take a look to see if the merge is indeed correct? |
I will try to rebase, but if anybody can explain the role |
@@ -10,6 +10,12 @@ | |||
from tests.lib.local_repos import local_checkout | |||
|
|||
|
|||
if os.name == 'posix': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a toxic destructive test - if ever any user with a preconfigured configfile runs it, they will face a lost configuration, and potentially hours or days of figuring why something they knew worked is suddenly broken
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just copied that from the test below to avoid code duplication in many places. I have no idea how this config file is supposed to be used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code in current master
does the same.
pip/tests/functional/test_install_reqs.py
Lines 232 to 236 in 404838a
if os.name == 'posix': | |
user_filename = ".pydistutils.cfg" | |
else: | |
user_filename = "pydistutils.cfg" | |
user_cfg = os.path.join(os.path.expanduser('~'), user_filename) |
So yes, it points to user HOME, but I thought that test framework should mock that, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RonnyPfannschmidt so any ideas how to change that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fine since we have an isolate
fixture to isolate the tests from the actual system, which is used when virtualenv
fixture is used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK, by the time we isolate, it's too late, since this is done during collection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah right. The execution during collection can be deferred using a function then, with the appropriate comment on why it's a function.
It's basically a configuration file to pass options to distutils (i.e. setup.py considers those values, which can be overidden by CLI options to setup.py that pip does not pass) -- https://docs.python.org/3/install/index.html#distutils-configuration-files |
In case anyone is curious how of note is the line:
which actually only applies to source distributions, doesn't apply to wheels (since this code was written before wheels existed) |
Sorry for the lack of a heads-up. I'm dropping this PR from the 18.1 milestone since there seem to be changes still needed here; albeit minor ones. |
Hello! I am an automated bot and I have noticed that this pull request is not currently able to be merged. If you are able to either merge the |
This PR is a really important one. Pip is currently broken for a very basic use-case (#4106), among others. I should think this would be a blocker, but instead, now two contributors have been burned out trying to fix it. Perhaps one of the project's maintainers would consider adopting this PR and push it over the line, enacting whatever changes are necessary to make it stable and satisfactory? |
@jaraco CI needs fixing - it appears to simply be a lint fix, so that shouldn't be hard. After that, it's more a matter of fixing review comments and getting someone to care enough. There seems to be some debate over the tests, which I don't really understand but I think needs addressing before this can be merged (or at least @pradyunsg and @RonnyPfannschmidt need to confirm that they are now happy with the test. As to moving this forward, I stated my own position above - I have no issues with this, but I'm not sufficiently convinced that this change is important to be willing to merge it without being sure that the various concerns others have raised have been addressed. @techtonik hasn't fixed the issue that was pointed out, he's asked for someone else to suggest a fix, but that hasn't happened. IMO, unless someone cares enough about this PR to (a) explain its importance better, and (b) follow up on review comments. then it'll probably remain unmerged. #4390 (which AIUI was the trigger for this) is simply saying we should fail more gracefully if #4106, to which you refer, seems to be about not being able to use Note - I'm entirely happy if @techtonik (or anyone else) says they haven't got the interest to push this forward. I'm not demanding anything here, quite the opposite, I'm saying that no-one feels the problem is important enough to be worth getting stressed about. (Or more accurately, no-one feels this solution is that important, and no-one has yet stepped up to contribute on the more fundamental issue). |
One thing this looks like it might fix is: |
@Bo98: There are several workarounds in that SO post, none of which are really robust as each requires mutating the user's file system in ways that aren't reliably available. For instance, writing to ./setup.cfg or ~/.distutils.cfg (aka ~/distutils.cfg on Windows) could overwrite existing values in those files. Plus, these workarounds are not properly coupled with the issue (they're user-global or project-local, whereas the cause is proximate to the Python environment). None of those is a proper fix. |
The rudimentary workaround mentioned above (and formerly suggested by the Homebrew maintainers) works but is not a good long term solution due to the fact that modifying a global configuration file is fraught with issues. For example, if |
Thanks for this PR and the discussion around it! I'm closing this PR since it's bitrotten. Please file a new PR if there's still interest in this. |
Rebased #4111.
(edit by @pradyunsg: fixes #4390)