Pip: New resolver: Constraints should “auto-select” extra

Created on 9 May 2020  Â·  8Comments  Â·  Source: pypa/pip

From test_install_with_extras_from_constraints. Say package foo has extra [extra] that pulls in bar (no default dependencies). A constraint like this:

# constraints.txt
foo[extra]

should let the following command

pip install -c constraints.txt foo

install both foo and bar. We are not doing this right now.

constraint new resolver

Most helpful comment

Clarifying based on a comment made by @dstufft here. This seems incorrect - constraints should not cause anything to be installed.

We should look at the test to understand better what it's trying to achieve, and consider that the test may actually be wrong.

All 8 comments

Clarifying based on a comment made by @dstufft here. This seems incorrect - constraints should not cause anything to be installed.

We should look at the test to understand better what it's trying to achieve, and consider that the test may actually be wrong.

I would be surprised by the behavior described here.

I agree -- I think we should not do this. I can see why the current resolver is doing this (it's got logic to "promote" constraints to requirements, and I'm pretty sure that person wasn't thinking of extras when they wrote that) and... I view this as a bug and not a feature. :)

No idea why we're testing this, and digging through the blame for the test commit to see if there's any original discussion here might be useful. I'm not gonna do that, since I have a lot on my plate already -- and there's too many plates too! :)

A quick blame brought me to #3189.

Closing as a "won't do".

If we don't want to do that, a warning stating that:

the extra extra from line foo[extra] from constraints.txt is ignored

would be nice.

I believe the current implementation is to hard error with “InstallationError: constraint can’t have extras” or something similar.

I believe the current implementation is to hard error with “InstallationError: constraint can’t have extras” or something similar.

https://github.com/pypa/pip/blob/1ebeab51460f7431a490576e52223fe4b3b22d53/src/pip/_internal/resolution/resolvelib/resolver.py#L44

We have this now; that's why I closed this. Sorry for the lack of clarity! ^>^

Was this page helpful?
0 / 5 - 0 ratings