-
-
Notifications
You must be signed in to change notification settings - Fork 629
Description
When upgrading the (pinned) dependencies in requirements.in of a project with an existing requirements.txt, pip-compile fails with a resolver error. It claims that an indirect dependency (here: cachecontrol[filecache]<0.14.0,>=0.13.0
) cannot be resolved even though a version (0.13.1) matching the constraint is listed among the considered versions.
pip-compile successfully creates a requirements.txt from the same requirements.in file (with the same pinned project dependencies), if I first delete the existing requirements.txt. However, I came across this error when renovateBot failed to update requirements.txt – that's a scenario where I cannot delete requirements.txt first.
Environment Versions
- MacOS 13.5 (also reproduced under Ubuntu jammy)
- Python version: 3.11.2 (also observed under Python 3.10 and 3.9)
- pip version: 23.2.1
- pip-tools version: 7.3.0
Steps to replicate
(pip-tools-venv) piptools $ rm -f requirements.in requirements.txt
(pip-tools-venv) piptools $ echo "poetry==1.5.1\n" > requirements.in
(pip-tools-venv) piptools $ pip-compile --generate-hashes -q requirements.in
WARNING: --strip-extras is becoming the default in version 8.0.0. To silence this warning, either use --strip-extras to opt into the new default or use --no-strip-extras to retain the existing behavior.
(pip-tools-venv) piptools $ grep '^cachecontrol' requirements.txt
cachecontrol[filecache]==0.12.14 \
(pip-tools-venv) piptools $ echo "poetry==1.6.1\n" > requirements.in
(pip-tools-venv) piptools $ pip-compile --generate-hashes -q requirements.in
ERROR: Could not find a version that satisfies the requirement cachecontrol[filecache]<0.14.0,>=0.13.0 (from poetry) (from versions: 0.5, 0.6, 0.7.1, 0.7.2, 0.7.3, 0.8.0, 0.8.1, 0.8.2, 0.8.3, 0.9.0, 0.9.1, 0.9.2, 0.9.3, 0.9.4, 0.10.0, 0.10.1, 0.10.2, 0.10.3, 0.10.4, 0.10.6, 0.10.7, 0.11.0, 0.11.1, 0.11.2, 0.11.3, 0.11.4, 0.11.5, 0.11.6, 0.11.7, 0.12.0, 0.12.1, 0.12.2, 0.12.3, 0.12.4, 0.12.5, 0.12.6, 0.12.7, 0.12.8, 0.12.9, 0.12.10, 0.12.11, 0.12.12, 0.12.13, 0.12.14, 0.13.0, 0.13.1rc0, 0.13.1)
Traceback (most recent call last):
File "/Users/christoph.ludwig/tmp/piptools/pip-tools-venv/lib/python3.11/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 92, in resolve
result = self._result = resolver.resolve(
^^^^^^^^^^^^^^^^^
File "/Users/christoph.ludwig/tmp/piptools/pip-tools-venv/lib/python3.11/site-packages/pip/_vendor/resolvelib/resolvers.py", line 546, in resolve
state = resolution.resolve(requirements, max_rounds=max_rounds)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/christoph.ludwig/tmp/piptools/pip-tools-venv/lib/python3.11/site-packages/pip/_vendor/resolvelib/resolvers.py", line 439, in resolve
raise ResolutionImpossible(self.state.backtrack_causes)
pip._vendor.resolvelib.resolvers.ResolutionImpossible: [RequirementInformation(requirement=SpecifierRequirement('cachecontrol[filecache]<0.14.0,>=0.13.0'), parent=LinkCandidate('https://files.pythonhosted.org/packages/7d/25/f3bfda3c458d114005af99441d009936b85a34a730aeb9cf57fb2630d9f7/poetry-1.6.1-py3-none-any.whl (from https://pypi.org/simple/poetry/) (requires-python:>=3.8,<4.0)'))]
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/christoph.ludwig/tmp/piptools/pip-tools-venv/bin/pip-compile", line 8, in <module>
sys.exit(cli())
^^^^^
File "/Users/christoph.ludwig/tmp/piptools/pip-tools-venv/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/christoph.ludwig/tmp/piptools/pip-tools-venv/lib/python3.11/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "/Users/christoph.ludwig/tmp/piptools/pip-tools-venv/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/christoph.ludwig/tmp/piptools/pip-tools-venv/lib/python3.11/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/christoph.ludwig/tmp/piptools/pip-tools-venv/lib/python3.11/site-packages/click/decorators.py", line 33, in new_func
return f(get_current_context(), *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/christoph.ludwig/tmp/piptools/pip-tools-venv/lib/python3.11/site-packages/piptools/scripts/compile.py", line 659, in cli
results = resolver.resolve(max_rounds=max_rounds)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/christoph.ludwig/tmp/piptools/pip-tools-venv/lib/python3.11/site-packages/piptools/resolver.py", line 604, in resolve
is_resolved = self._do_resolve(
^^^^^^^^^^^^^^^^^
File "/Users/christoph.ludwig/tmp/piptools/pip-tools-venv/lib/python3.11/site-packages/piptools/resolver.py", line 636, in _do_resolve
resolver.resolve(
File "/Users/christoph.ludwig/tmp/piptools/pip-tools-venv/lib/python3.11/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 101, in resolve
raise error from e
pip._internal.exceptions.DistributionNotFound: No matching distribution found for cachecontrol[filecache]<0.14.0,>=0.13.0
(pip-tools-venv) piptools $ rm requirements.txt
(pip-tools-venv) piptools $ pip-compile --generate-hashes -q requirements.in
WARNING: --strip-extras is becoming the default in version 8.0.0. To silence this warning, either use --strip-extras to opt into the new default or use --no-strip-extras to retain the existing behavior.
(pip-tools-venv) piptools $ grep '^cachecontrol' requirements.txt
cachecontrol[filecache]==0.13.1 \
Expected result
requirements.txt is updated, no need to delete requirements.txt first
Actual result
The resolver error shown if requirements.txt exists already generated for an older version of the project dependency.