Description
Description
When a requirements list contains both mypackage<some_constraint>
and my_package[my_extra]
, the two seem to be treated separately, without applying the constraint to my_package[my_extra]
. In the end, pip
does manage to find a correct set of packages but this may involve unnecessary backtracking that (I think) could be easily avoided.
Consider the package inmanta-core
. It has an extra named pytest-inmanta-extensions
, which is strongly tied to it by version. It constraints the pytest-inmanta-extensions
package to be the same version as inmanta-core
itself (see here).
I tried the following: pip download "inmanta-core==6.0.0" "inmanta-core[pytest-inmanta-extensions]"
, expecting it to trivially find the appropriate versions. Alas, it seems to pick the trivial candidate for inmanta-core
, but then pick a different (incorrect) candidate for inmanta-core[pytest-inmanta-extesions]
. This later results in backtracking on the latter until it stumbles on the correct version. In this case it has to backtrack over some ten versions, trying it with dev versions (e.g. with --pre
and our internal index) is way worse.
Since the package with and without extra have the same base, I would think constraints can be shared safely.
I think the cause may be related to #11913 (comment), but I haven't dug deep enough in the pip internals to know for sure.
Expected behavior
See description
pip version
23.0.1 and main (81f6a9f)
Python version
3.9.15
OS
Linux
How to Reproduce
pip download "inmanta-core==6.0.0" "inmanta-core[pytest-inmanta-extensions]"
Output
Collecting inmanta-core==6.0.0
File was already downloaded /home/sander/.virtualenvs/tmp-6fecb770122ef28/inmanta-core-6.0.0.tar.gz
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Collecting inmanta-core[pytest-inmanta-extensions]
Using cached inmanta_core-8.2.0-py3-none-any.whl (619 kB)
...
<unrelated output>
...
Collecting inmanta-core[pytest-inmanta-extensions]
Using cached inmanta_core-8.1.0-py3-none-any.whl (619 kB)
Using cached inmanta_core-8.0.0-py3-none-any.whl (591 kB)
Using cached inmanta_core-7.1.0-py3-none-any.whl (592 kB)
Using cached inmanta_core-7.0.0-py3-none-any.whl (571 kB)
Using cached inmanta_core-6.4.1-py3-none-any.whl (594 kB)
Using cached inmanta_core-6.4.0-py3-none-any.whl (593 kB)
Using cached inmanta_core-6.3.0-py3-none-any.whl (592 kB)
Using cached inmanta_core-6.2.0-py3-none-any.whl (571 kB)
Using cached inmanta_core-6.1.0-py3-none-any.whl (543 kB)
Using cached inmanta_core-6.0.2-py3-none-any.whl (515 kB)
Using cached inmanta_core-6.0.1-py3-none-any.whl (515 kB)
Collecting pytest-inmanta-extensions~=6.0.0.0.dev
File was already downloaded /home/sander/.virtualenvs/tmp-6fecb770122ef28/pytest-inmanta-extensions-6.0.0.tar.gz
Preparing metadata (setup.py) ... done
Code of Conduct
- I agree to follow the PSF Code of Conduct.