Backtracking when package has conflicting runtime dependencies
See original GitHub issueDescription
The oldest-supported-numpy
package version 0.13 has conflicting requirements in its setup.cfg:
https://github.com/scipy/oldest-supported-numpy/blob/v0.13/setup.cfg#L43-L50
Those two lines conflict on s390x and Python 3.8:
numpy==1.17.5; python_version=='3.8' and platform_machine=='s390x' and platform_python_implementation != 'PyPy'
numpy==1.17.3; python_version=='3.8' and (platform_machine!='arm64' or platform_system!='Darwin') and platform_machine!='aarch64' and platform_python_implementation != 'PyPy'
When copying those directly in a requirements file, you get the expected error:
$ python -c "import platform; print(platform.machine())"
s390x
$ cat requirements-build.txt
numpy==1.17.5; python_version=='3.8' and platform_machine=='s390x' and platform_python_implementation != 'PyPy'
numpy==1.17.3; python_version=='3.8' and (platform_machine!='arm64' or platform_system!='Darwin') and platform_machine!='aarch64' and platform_python_implementation != 'PyPy'
$ pip install -r requirements-build.txt
Collecting numpy==1.17.5
Using cached numpy-1.17.5.zip (6.4 MB)
Preparing metadata (setup.py) ... done
ERROR: Cannot install numpy==1.17.3 and numpy==1.17.5 because these package versions have conflicting dependencies.
The conflict is caused by:
The user requested numpy==1.17.5
The user requested numpy==1.17.3
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/latest/user_guide/#fixing-conflicting-dependencies
However, when installing said package, pip silently downgrades the package to the previous version without conflicting requirements:
$ pip install oldest-supported-numpy
Collecting oldest-supported-numpy
Using cached oldest_supported_numpy-0.13-py3-none-any.whl (3.8 kB)
Collecting numpy==1.17.5
Using cached numpy-1.17.5.zip (6.4 MB)
Preparing metadata (setup.py) ... done
Collecting oldest-supported-numpy
Using cached oldest_supported_numpy-0.12-py3-none-any.whl (3.8 kB)
Collecting numpy==1.17.3
Using cached numpy-1.17.3.zip (6.4 MB)
Preparing metadata (setup.py) ... done
Building wheels for collected packages: numpy
[etc.]
It should at least display a warning about the unexpected downgrade (or perhaps better, error out).
Expected behavior
No response
pip version
21.3.1
Python version
3.8.10
OS
Ubuntu 20.04.3
How to Reproduce
See description above.
Output
No response
Code of Conduct
- I agree to follow the PSF Code of Conduct.
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (11 by maintainers)
Top Results From Across the Web
Resolving new pip backtracking runtime issue - Stack Overflow
The behavior seen is described as backtracking in the release notes. I understand why it is there. It specifies that I can use...
Read more >Dependency Resolution - pip documentation v22.3.1
pip is capable of determining and installing the dependencies of packages. ... result in pip backtracking on a different package due to some...
Read more >View topic - Slot conflicts instead of upgrading - Gentoo Forums
The problem with a circular dependency is to identify the dependency chain most of the time, as a package.mask will not make that...
Read more >Conflict-Driven Clause Learning SAT Solvers
Backtracking corresponds to undoing branching steps until an unflipped branch is reached. When both values have been assigned to the selected variable at...
Read more >History | Poetry - Python dependency management and ...
Fix an issue where a package from the wrong source was installed for a multiple-constraints dependency with different sources (#6747).
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Just for the record, in my case a simple warning would have been satisfactory. The problem was being unable to easily diagnose the issue, since pip was doing something totally unexpected without saying anything about it (and since multiple packages were involved, finding the root cause wasn’t trivial).
OK, for a given set of supported environments. That’s a very good approach, but something only the individual project can do, which I agree is the correct solution here. My comment was more about the backend doing the validation at build time, not the project itself.