-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Resolver: Candidates need a name and version #7966
Comments
This might be a case of the resolver search order being incorrect -- attempting to choose the oldest versions first instead of newer versions. Can we check if that's not the case here? |
I checked that as part of my debugging session. I'm reasonably certain it's not that. Basically the resolvelib algorithm merges new requirements into the existing criteria. At that point it does:
(You probably already know this, and I'm over-simpifying from memory, but hopefully the above is useful for others checking out this issue). It's step (1) that's the problem - you can't do a "satisfies" check without name and version, and you're doing this for every current candidate. I checked this with tracing diagnostics in the resolver, although I didn't track everything down (I got swamped with output 🙁). I'm going to try the following approach tomorrow:
That would mean that we only need to prepare for getting dependencies, or for local directories, VCS URLs, or local files and URLs that have filenames that don't follow the normal sdist format. That seems like it's an acceptable level, but we'll have to confirm that with testing. I don't think we can do any better than that without modifying the resolvelib algorithm to allow for "unnamed" or "unversioned" candidates, and that would be a much more difficult route to take - not least because it adds a constraint on the resolver that other libraries are unlikely to support without modification. |
Extracting the name and version sounds right to me—in fact IIRC this is exactly what the legacy resolver does. The link parsing is already done by the package finder, and information should be available in the Due to ambiguity in an sdist’s filename, the parsed name could end up being incorrect in edge cases (e.g. |
Also, we can avoid that issue by using the fact that we know the project name in most cases (the finder has it from the simple index page it's scraping, and the new resolver has it from the requirement that +1 on keeping the idea of having a mechanism to trigger a backtrack, and for deferring it until later when we have a real example of where we need it. |
Environment
Description
Pip tries to prepare the setuptools 0.7.2 sdist, which is very old and uses Python 2 syntax. The prepare therefore fails.
Expected behavior
Don't prepare candidates unnecessarily, and in particular, don't prepare older candidates when newer ones are still options.
How to Reproduce
Start the given docker image.
Install the following
requirements.txt
file withpip install -r requirements.txt
Then run
pip install --unstable-feature=resolver 'plover_plugins_manager==0.5.14'
. The command fails trying to runsetup.py egg_info
on setuptools 0.7.2.Debugging the failure shows the following traceback:
In particular, the issue appears to be that the resolver needs to call
requirement.is_satisfied_by
on all the candidates returned fromfind_matches
, as part of the criterion merge process. This in turn needs the name and version, which triggers theprepare
call.Solution
I don't think we can reasonably handle candidates (from PyPI, at least) without a name and version, as we'll end up building everything. The best fix I can think of is to use our existing logic1 to determine the name and version for sdists (and wheels, but I think that already happens) based on the filename. We may then find that the metadata doesn't match the filename, but we can warn/abort at that point (we may have to abort, because the resolve process may be unrecoverably broken if the candidate's name or version changes "on the fly").
I can look at adding that logic - @pradyunsg @uranusjr does this seem like a reasonable approach to take?
1 At least I assume we have this logic somewhere!
The text was updated successfully, but these errors were encountered: