-
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
Unexplainable ContextualVersionConflict #6275
Comments
Does this also occur with pip 19.0.2 and updated setuptools / wheel? |
@pradyunsg Yup, it occurs with that as well: https://travis-ci.com/1313e/PRISM/jobs/178462602 |
Never mind, I see from the Travis CI that this occurred with pip 18.1 |
@cjerdonek What do you mean? |
What happened is that I couldn't tell from your original report without digging into the Travis CI details whether your issue was limited to pip 19.0 and up. But digging in I saw the first report was about 18.1. (It's always a good idea to include the affected pip versions in the issue report text itself.) |
Alright, yeah, forgot about that. |
I did some digging, and this seems to happen only when you
This is the minimal reproducible case I came up with: # setup.py
from setuptools import setup
setup(
name='pip-conflict-travis',
install_requires=['six>=1.0.0,<1.11.0'],
) # Failing .travis.yml
language: python
python: '2.7'
install:
- python -m pip install six==1.11.0
- python -m pip install -e .
script:
- As mentioned previously, this is only reproducible on Travis. The problem also does not exist if you create your own virtual environment; the following works: # Working .travis.yml
language: python
python: '2.7'
install:
- virtualenv --python=$(which python2.7) venv
- ./venv/bin/pip install six==1.11.0
- ./venv/bin/pip install -e .
script:
- So I am inclined to think this is a configuration on Travis’s part, and there’s not much pip can do at the moment. |
Forgot to mention—The same failure can be observed on Travis with Ubuntu Trusty and pip 9.0.1 (the default runtime), so it is highly unlikely to be related to any recent packaging changes. |
@uranusjr Interesting. Also, before, I did not have this problem.
I agree, but it might be an indication that there is a long-living problem somewhere. |
Some suggestions:
|
pip does not fail to parse the requirement. The failure means “the "best" so far conflicts with a dependency” (quoting the comment where the exception is raised; I have no idea what that means). I plan to continue digging and see if I can find what causes this. |
You're using an Ubuntu distribution, I believe, and the system provided pip? If so, then could it be that the Ubuntu/Debian's patches to pip to are the issue here (in particular, I'd be concerned about their override to make |
@pfmoore It is definitely not the pip provided by apt’s python-pip, and Travis doc says it’s a virtualenv. I don’t know whether and how it’s different from a virtualenv created manually though. |
Update: I realised that six==1.11.0 was installed by default (like numpy) in Travis’s virtualenv, so I switched to use scripttest instead. The results are the same.
Environment before installing scripttest:
After installing scripttest (and before
Interestingly, there are two |
What happens if you try to reproduce the issue locally (or in a fresh virtualenv) starting with those same packages installed? |
@cjerdonek Can’t reproduce locally, installation ends successfully. This gave me an idea, however—I tried to reproduce this with a fresh virtualenv on Travis, and voila! It fails. Next step: Try to build an environment more similar to Travis’s 🤔 |
I think I’ve found the problem. This happens when you try to build an egg-info with a conflicting requirement in the environment. # setup.py
from setuptools import setup
setup(
name='conflict-test',
install_requires=['scripttest!=1.3'],
) # IMPORTANT: Trigger egg-info rebuild.
rm -rf ./conflict_test.egg-info
# Build a fresh environment.
rm -rf ./venv
python3.6 -m venv venv
PYTHON="$PWD/venv/bin/python"
# Install an incompatible requirement.
$PYTHON -m pip install scripttest==1.3
# FAILURE!
$PYTHON -m pip install -e . When running pip/src/pip/_internal/req/req_install.py Lines 376 to 416 in cba6083
From what I understand, the large try-except block here follows this logic:
The problem is how 3. is implemented. The code assumes that if I am not sure how this should be fixed. Maybe @1313e A workaround is to run |
Great! And why was this limited to Travis? I'm assuming that was a red herring. Were you able to reproduce locally after all? |
Re: your proposed options, sometimes adding a flag to an existing function adds undesired complexity because of branching and making the call sites relying on that flag harder to find. Would it make sense to add a function to |
Yes I was! I wasn’t able to reproduce before because my test case was either too clean or not clean enough (a prebuilt egg-info resolves the problem). Travis has an environment right in the sweet spot, and local reproduction is easy once I know where that spot is :p |
@uranusjr Wow, that turned out to be a lot harder and more complex than I thought. |
What is the status on this? |
* Fix 'break' syscall Fixed the 'break' syscall by renaming the method to break_ so as not to collide with the keyword. * Bypass pypa/pip#6275
* add some development information, add redis so you can even run * add link to development doc to readme * add pre-commit polishing * Try a travis fix from: pypa/pip#6275
…fica#82) * add some development information, add redis so you can even run * add link to development doc to readme * add pre-commit polishing * Try a travis fix from: pypa/pip#6275
@uranusjr This is a fairly big deviation from the resolvelib work for you, but any idea what we could change in pip to make this less likely for end users? |
Does this not have to do with the dependency resolver issues discussed in #988? |
Yes, eventually the resolver work would make this whole block obsolete.
If we switch to |
OK great! Given that our broader chunks of work would end up fixing this, I'll stop spending time trying to understand why we're having this issue; and instead spend it on progressing on those tasks. :) |
Related to pypa/pip#6275
Not sure how I am going to describe this, as I cannot find any way to reproduce this on my own machine, but for some reason, on Travis CI for Python 2.7.15, pip fails to uninstall the already present
numpy
v1.16.0 and install the requestednumpy<1.16.0,>=1.12.0
.The build job can be viewed here: https://travis-ci.com/1313e/PRISM/jobs/178432270
I know that when running on Travis CI on Linux, it automatically comes with NumPy 1.16.0, which is incompatible with what I want to test for Python 2.7.
Therefore, when installing all requirements, it should uninstall that version and install a version that satisfies the condition (which is v1.15.4).
Until today, it did this perfectly fine and it still does on my machine(s).
However, for some odd reason, it does not do that anymore and simply throws an
ContextualVersionConflict
.The only thing I changed today is that I combined two requirements files into a single one.
One has a package requirement that simply requires NumPy (emcee), while the other has the version restrictions.
This does work perfectly fine on my machine(s), even in fresh environments, so I am a bit confused why this pops up all of a sudden.
I know this may seem a bit of a weird issue, as I cannot give any way or method to reproduce the error, but I hope somebody knows what the problem is here.
Edit: It seems that this problem affects both pip v18.1 and v19.0.2.
The text was updated successfully, but these errors were encountered: