pypa/pip

New resolver: Try == specifiers first to catch simple incompatibilities faster

Closed this issue · 1 comments

Idea I have while working on #9011 (comment)

This input:

tensorboard==2.2.2
torch==1.7.0
tqdm>=4.54

nltk==3.5.0
transformers==3.5.0
tokenizers==0.9.4
jsonlines>=1.2
sacrebleu>=1.4

pytest>=6.1
pytest-cov>=2.10
codecov>=2.1
flake8>=3.8
black==20.8b1

Leads to this eventual error:

The conflict is caused by:
    The user requested tokenizers==0.9.4
    transformers 3.5.0 depends on tokenizers==0.9.3

But the resolver needs a very long time to reach it, because… the packages started with to and tr are checked last, after the resolver successfully worked out all the other complex open specifier combinations 🤦

I think we can make things a bit better by checking for == (and ===) specifiers and do those packages first. This is similar to how we previously “optimised” the process by using len(candidates) (the less candidates a package has, the more likely it causes conflicts, so we check them first to catch simple cases early), but without needing to actually fetch the list of candidates eagerly.

I like it. Let's do this. :)