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

Non-local directory chosen when conflicting installs are given #8131

Closed
PythonCoderAS opened this issue Apr 25, 2020 · 11 comments
Closed

Non-local directory chosen when conflicting installs are given #8131

PythonCoderAS opened this issue Apr 25, 2020 · 11 comments

Comments

@PythonCoderAS
Copy link

Environment

  • pip version: 20.1b1
  • Python version: 3.7.7
  • OS: MacOS 10.14.6

Description

If I have version 7 of a package on my local system, and then run an install such as pip install --upgrade . example<7, example < 7 gets installed, disregarding the local copy.

Expected behavior

A warning to be printed to the user

How to Reproduce

  1. Clone a package
  2. `pip install . [package]<[currentversion]

Output
I used the package praw.

Processing /Users/Example/PycharmProjects/praw
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
    Preparing wheel metadata: started
    Preparing wheel metadata: finished with status 'done'
Requirement already up-to-date: praw<7 in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (6.5.1)
Requirement already satisfied, skipping upgrade: update-checker>=0.16 in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from praw==7.0.1.dev0) (0.16)
Requirement already satisfied, skipping upgrade: websocket-client>=0.54.0 in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from praw==7.0.1.dev0) (0.57.0)
Requirement already satisfied, skipping upgrade: prawcore<2.0,>=1.3.0 in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from praw==7.0.1.dev0) (1.3.0)
Requirement already satisfied, skipping upgrade: sphinx<3.0; extra == "dev" in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from praw==7.0.1.dev0) (2.4.4)
Requirement already satisfied, skipping upgrade: pytest>=2.7.3; extra == "dev" in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from praw==7.0.1.dev0) (5.4.1)
Requirement already satisfied, skipping upgrade: black; extra == "dev" in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from praw==7.0.1.dev0) (19.10b0)
Requirement already satisfied, skipping upgrade: pre-commit; extra == "dev" in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from praw==7.0.1.dev0) (2.3.0)
Requirement already satisfied, skipping upgrade: betamax<0.9,>=0.8; extra == "dev" in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from praw==7.0.1.dev0) (0.8.1)
Requirement already satisfied, skipping upgrade: flake8; extra == "dev" in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from praw==7.0.1.dev0) (3.7.9)
Requirement already satisfied, skipping upgrade: sphinx-rtd-theme; extra == "dev" in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from praw==7.0.1.dev0) (0.4.3)
Requirement already satisfied, skipping upgrade: betamax-matchers<0.5,>=0.3.0; extra == "dev" in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from praw==7.0.1.dev0) (0.4.0)
Requirement already satisfied, skipping upgrade: pydocstyle; extra == "dev" in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from praw==7.0.1.dev0) (5.0.2)
Requirement already satisfied, skipping upgrade: requests>=2.3.0 in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from update-checker>=0.16->praw==7.0.1.dev0) (2.23.0)
Requirement already satisfied, skipping upgrade: six in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from websocket-client>=0.54.0->praw==7.0.1.dev0) (1.14.0)
Requirement already satisfied, skipping upgrade: packaging in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from sphinx<3.0; extra == "dev"->praw==7.0.1.dev0) (20.3)
Requirement already satisfied, skipping upgrade: sphinxcontrib-devhelp in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from sphinx<3.0; extra == "dev"->praw==7.0.1.dev0) (1.0.2)
Requirement already satisfied, skipping upgrade: babel!=2.0,>=1.3 in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from sphinx<3.0; extra == "dev"->praw==7.0.1.dev0) (2.8.0)
Requirement already satisfied, skipping upgrade: alabaster<0.8,>=0.7 in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from sphinx<3.0; extra == "dev"->praw==7.0.1.dev0) (0.7.12)
Requirement already satisfied, skipping upgrade: sphinxcontrib-applehelp in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from sphinx<3.0; extra == "dev"->praw==7.0.1.dev0) (1.0.2)
Requirement already satisfied, skipping upgrade: sphinxcontrib-serializinghtml in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from sphinx<3.0; extra == "dev"->praw==7.0.1.dev0) (1.1.4)
Requirement already satisfied, skipping upgrade: Pygments>=2.0 in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from sphinx<3.0; extra == "dev"->praw==7.0.1.dev0) (2.6.1)
Requirement already satisfied, skipping upgrade: snowballstemmer>=1.1 in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from sphinx<3.0; extra == "dev"->praw==7.0.1.dev0) (2.0.0)
Requirement already satisfied, skipping upgrade: sphinxcontrib-htmlhelp in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from sphinx<3.0; extra == "dev"->praw==7.0.1.dev0) (1.0.3)
Requirement already satisfied, skipping upgrade: imagesize in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from sphinx<3.0; extra == "dev"->praw==7.0.1.dev0) (1.2.0)
Requirement already satisfied, skipping upgrade: sphinxcontrib-qthelp in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from sphinx<3.0; extra == "dev"->praw==7.0.1.dev0) (1.0.3)
Requirement already satisfied, skipping upgrade: sphinxcontrib-jsmath in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from sphinx<3.0; extra == "dev"->praw==7.0.1.dev0) (1.0.1)
Requirement already satisfied, skipping upgrade: setuptools in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from sphinx<3.0; extra == "dev"->praw==7.0.1.dev0) (46.1.3)
Requirement already satisfied, skipping upgrade: Jinja2>=2.3 in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from sphinx<3.0; extra == "dev"->praw==7.0.1.dev0) (2.11.2)
Requirement already satisfied, skipping upgrade: docutils>=0.12 in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from sphinx<3.0; extra == "dev"->praw==7.0.1.dev0) (0.16)
Requirement already satisfied, skipping upgrade: wcwidth in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from pytest>=2.7.3; extra == "dev"->praw==7.0.1.dev0) (0.1.9)
Requirement already satisfied, skipping upgrade: importlib-metadata>=0.12; python_version < "3.8" in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from pytest>=2.7.3; extra == "dev"->praw==7.0.1.dev0) (1.6.0)
Requirement already satisfied, skipping upgrade: more-itertools>=4.0.0 in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from pytest>=2.7.3; extra == "dev"->praw==7.0.1.dev0) (8.2.0)
Requirement already satisfied, skipping upgrade: py>=1.5.0 in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from pytest>=2.7.3; extra == "dev"->praw==7.0.1.dev0) (1.8.1)
Requirement already satisfied, skipping upgrade: attrs>=17.4.0 in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from pytest>=2.7.3; extra == "dev"->praw==7.0.1.dev0) (19.3.0)
Requirement already satisfied, skipping upgrade: pluggy<1.0,>=0.12 in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from pytest>=2.7.3; extra == "dev"->praw==7.0.1.dev0) (0.13.1)
Requirement already satisfied, skipping upgrade: click>=6.5 in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from black; extra == "dev"->praw==7.0.1.dev0) (7.1.1)
Requirement already satisfied, skipping upgrade: regex in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from black; extra == "dev"->praw==7.0.1.dev0) (2020.4.4)
Requirement already satisfied, skipping upgrade: appdirs in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from black; extra == "dev"->praw==7.0.1.dev0) (1.4.3)
Requirement already satisfied, skipping upgrade: toml>=0.9.4 in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from black; extra == "dev"->praw==7.0.1.dev0) (0.10.0)
Requirement already satisfied, skipping upgrade: typed-ast>=1.4.0 in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from black; extra == "dev"->praw==7.0.1.dev0) (1.4.1)
Requirement already satisfied, skipping upgrade: pathspec<1,>=0.6 in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from black; extra == "dev"->praw==7.0.1.dev0) (0.8.0)
Requirement already satisfied, skipping upgrade: cfgv>=2.0.0 in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from pre-commit; extra == "dev"->praw==7.0.1.dev0) (3.1.0)
Requirement already satisfied, skipping upgrade: nodeenv>=0.11.1 in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from pre-commit; extra == "dev"->praw==7.0.1.dev0) (1.3.5)
Requirement already satisfied, skipping upgrade: pyyaml>=5.1 in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from pre-commit; extra == "dev"->praw==7.0.1.dev0) (5.3.1)
Requirement already satisfied, skipping upgrade: identify>=1.0.0 in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from pre-commit; extra == "dev"->praw==7.0.1.dev0) (1.4.15)
Requirement already satisfied, skipping upgrade: virtualenv>=15.2 in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from pre-commit; extra == "dev"->praw==7.0.1.dev0) (20.0.18)
Requirement already satisfied, skipping upgrade: entrypoints<0.4.0,>=0.3.0 in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from flake8; extra == "dev"->praw==7.0.1.dev0) (0.3)
Requirement already satisfied, skipping upgrade: mccabe<0.7.0,>=0.6.0 in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from flake8; extra == "dev"->praw==7.0.1.dev0) (0.6.1)
Requirement already satisfied, skipping upgrade: pycodestyle<2.6.0,>=2.5.0 in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from flake8; extra == "dev"->praw==7.0.1.dev0) (2.5.0)
Requirement already satisfied, skipping upgrade: pyflakes<2.2.0,>=2.1.0 in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from flake8; extra == "dev"->praw==7.0.1.dev0) (2.1.1)
Requirement already satisfied, skipping upgrade: requests-toolbelt>=0.4.0 in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from betamax-matchers<0.5,>=0.3.0; extra == "dev"->praw==7.0.1.dev0) (0.9.1)
Requirement already satisfied, skipping upgrade: certifi>=2017.4.17 in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from requests>=2.3.0->update-checker>=0.16->praw==7.0.1.dev0) (2020.4.5.1)
Requirement already satisfied, skipping upgrade: idna<3,>=2.5 in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from requests>=2.3.0->update-checker>=0.16->praw==7.0.1.dev0) (2.9)
Requirement already satisfied, skipping upgrade: chardet<4,>=3.0.2 in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from requests>=2.3.0->update-checker>=0.16->praw==7.0.1.dev0) (3.0.4)
Requirement already satisfied, skipping upgrade: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from requests>=2.3.0->update-checker>=0.16->praw==7.0.1.dev0) (1.25.9)
Requirement already satisfied, skipping upgrade: pyparsing>=2.0.2 in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from packaging->sphinx<3.0; extra == "dev"->praw==7.0.1.dev0) (2.4.7)
Requirement already satisfied, skipping upgrade: pytz>=2015.7 in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from babel!=2.0,>=1.3->sphinx<3.0; extra == "dev"->praw==7.0.1.dev0) (2019.3)
Requirement already satisfied, skipping upgrade: MarkupSafe>=0.23 in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from Jinja2>=2.3->sphinx<3.0; extra == "dev"->praw==7.0.1.dev0) (1.1.1)
Requirement already satisfied, skipping upgrade: zipp>=0.5 in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from importlib-metadata>=0.12; python_version < "3.8"->pytest>=2.7.3; extra == "dev"->praw==7.0.1.dev0) (3.1.0)
Requirement already satisfied, skipping upgrade: filelock<4,>=3.0.0 in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from virtualenv>=15.2->pre-commit; extra == "dev"->praw==7.0.1.dev0) (3.0.12)
Requirement already satisfied, skipping upgrade: distlib<1,>=0.3.0 in /Users/Example/.virtualenvs/praw/venv/lib/python3.7/site-packages (from virtualenv>=15.2->pre-commit; extra == "dev"->praw==7.0.1.dev0) (0.3.0)
@triage-new-issues triage-new-issues bot added the S: needs triage Issues/PRs that need to be triaged label Apr 25, 2020
@uranusjr
Copy link
Member

uranusjr commented Apr 25, 2020

I have difficulties following. Why does installing the package is a problem? What warning message do you expect to be printed? Your description is lacking a lot of context, but there’s nothing pip is doing wrong in this post as far as I see.

@pfmoore
Copy link
Member

pfmoore commented Apr 25, 2020

This is related to #8117 (which is still somewhat unclear, TBH, it's a work in progress). You have requested that "example<7" be installed. Currently you have example version 7 on the system, which does not satisfy that requirement, so pip uninstalls that and replaces it with a version that does satisfy that requirement. The --upgrade flag isn't relevant here, pip would behave the same without it. And there's no bug - you asked for example<7 and you get it.

The only effect of --upgrade is that without --upgrade, pip tries to prefer the version currently installed, whereas with --upgrade pip prefers the latest version available. But that's only a preference - satisfying the stated requirements remains the priority.

Also, I'm assuming that including . here isn't relevant - you don't say what the project in the current directory is, but I'm presuming it's unrelated to example...

(To be clear, I'm sympathetic with the view that this is not very intuitive. But it's long-established pip behaviour, and it's not entirely clear to me that any other behaviour wouldn't have equally non-intuitive cases.)

@McSinyx
Copy link
Contributor

McSinyx commented Apr 25, 2020

@pfmoore, IIUC, the . is exactly the same package (i.e. pip install example/ example<7), and @PythonCoderAS wants a warning if pip prefer a non-local candidate. I am not sure about the actual use case of this (when does this actually happen in practice?). As @uranusjr said, more context would be helpful.

@pfmoore
Copy link
Member

pfmoore commented Apr 25, 2020

Indeed, if . is also implementing example, that would be useful context that we're missing (I'd like to know what version it is, as well).

@PythonCoderAS
Copy link
Author

PythonCoderAS commented Apr 25, 2020

@McSinyx @pfmoore @uranusjr The . is implememnting example==7.0.1dev0

@pfmoore
Copy link
Member

pfmoore commented Apr 25, 2020

Ah, OK. So that doesn't satisfy "example<7".

I'm not 100% sure how the current resolver will process this, but it's likely that the example<7 requirement is why you're not getting the current directory (plus the fact that it's a pre-release version).

What behaviour do you get with the new resolver (--unstable-feature=resolver)? I'd expect an error as your requirements are inconsistent (we can't satisfy both . and example<7.

@PythonCoderAS
Copy link
Author

I get an error.

Processing /Users/Example/PycharmProjects/praw
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
ERROR: Could not find a version that satisfies the requirement ExplicitRequirement(LinkCandidate('file:///Users/Example/PycharmProjects/praw'))
ERROR: Could not find a version that satisfies the requirement praw<7
ERROR: No matching distribution found for praw, praw

@pfmoore
Copy link
Member

pfmoore commented Apr 25, 2020

OK, cool. Looks like the new resolver handles this fine. Although the error is pretty unhelpful - I can tell it's saying "I tried to check /Users/Example/PycharmProjects/praw and it doesn't produce a version that satisfies the constraint praw<7" but I'd be hard pressed to say that it was obvious 🙁

Thanks very much for testing.

We'll need to ensure that we improve the error message for this case. @pradyunsg @uranusjr this would make a good test case for the error handling.

@uranusjr uranusjr added this to To do in New Resolver Implementation via automation Apr 25, 2020
@brainwane brainwane moved this from Post-release work to To do before prod release in New Resolver Implementation Jun 11, 2020
@pfmoore
Copy link
Member

pfmoore commented Jun 18, 2020

Hi @PythonCoderAS. We have now implemented an improved error message in the new resolver for this case. With a stripped-down version of your example, I now get the following error:

>.venv/scripts/python -m pip install --unstable-feature=resolver . "example<7"
Processing c:\work\projects\pip\.scratch\8131
ERROR: Cannot install example 7.0.1.dev1 (from C:\Work\Projects\pip\.scratch\8131) and example<7 because these package versions have conflicting dependencies.

The conflict is caused by:
    The user requested example 7.0.1.dev1 (from C:\Work\Projects\pip\.scratch\8131)
    The user requested example<7

To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict

ERROR: ResolutionImpossible For help visit: https://pip.pypa.io/en/stable/user_guide/#dependency-conflicts-resolution-impossible

Is that message a clear enough explanation of what went wrong here for you?

@PythonCoderAS
Copy link
Author

@pfmoore Yeah the error message is much clearer. Although you should bring the "For help visit ..." onto a new line.

@pfmoore
Copy link
Member

pfmoore commented Jun 18, 2020

@PythonCoderAS Thanks for the feedback! On that basis, I'll close this issue.

@ei8fdb See the comment above about putting the "For help..." text on a new line. Can you review and consider how we can take that into account, please? (We might want something more than just "ResolutionImpossible" on the "ERROR:" line).

@pfmoore pfmoore closed this as completed Jun 18, 2020
New Resolver Implementation automation moved this from To do before prod release to Done Jun 18, 2020
@pradyunsg pradyunsg removed the S: needs triage Issues/PRs that need to be triaged label Feb 12, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
No open projects
Development

No branches or pull requests

5 participants