-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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: Use requirement line to populate LinkCandidate._ireq #8005
New resolver: Use requirement line to populate LinkCandidate._ireq #8005
Conversation
@uranusjr happy to help, but I must admit I have no clue what you are talking about. |
@sbidoul Command to run the test:
You’d see the last line in the freeze file doesn’t match expectation (there are other mismatches, but they are not relevant here). The expectation is
You can read the Travis run here as well: https://travis-ci.org/github/pypa/pip/jobs/672815957#L514 In other words, the test expects the requirement to be frozen with a version, but the new resolver freezes it as a direct URL. Does this sound like a change implemented by PEP 610? My assumption to the cause is that the new resolver is building the InstallRequirement incorrectly; it should not supply a URL to the constructor. Does that sound right? |
@uranusjr I understand better. Thanks for the explanation on how to run the tests with the new resolver. Yes, if you get an URL out of pip freeze, it comes from pip/src/pip/_internal/req/req_install.py Lines 790 to 796 in c5da021
So yes, I don't quite understand yet why the new resolver needs this indirection layer such as |
Thanks for the insight! So the crux to the fix would be to come up with something else to construct InstallRequirement from, but still make it point to a link. And my current try is clearly not working. I’ll try to think of a way. |
f2479ea
to
4ef269c
Compare
Suepecting at least some errors are caused by #8000. |
I just merged #8000, so maybe rebase to check? |
4ef269c
to
6c14386
Compare
🏎️ |
Things are passing |
if ireq.link is None: | ||
ireq.link = link | ||
# TODO: Handle wheel cache resolution. | ||
return ireq |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@uranusjr here is a track to explore. Is it correct that what you want to do here is create a new InstallRequirement that is identical to parent
except for link
? In that case it is important that the new ireq preserves parent's original_link
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We did originally have code that cloned the InstallRequirement
by creating a new object and copying all(>?) of the state across. It was ugly, but I believe it also had some problems. @uranusjr can you remember what went wrong with that approach? I'm wondering if we should see whether switching back to that approach works any better than what we currently do...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The old approach makes the PEP 610 implementation think the cloned InstallRequirement
is a direct one, because we would generate the Candidate
’s InstallRequirement
with a directly URL, i.e. candidates requested by a==1.0.0
and a @ file://.../a-1.0.0-...whl
are undistinguishable in the previous approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, that was the problem. I had a suspicion it would be something simple. I need a cup of tea to kick-start my brain :-)
This ensures a candidate built from a "found" link (from e.g. index) is categorized as specifier-based, not URL-based. This is important to avoid a specifier-based candidate to be 'pip freeze'-ed in the direct URL form due to PEP 610 (direct-url.json).
6c14386
to
e03614f
Compare
I was looking into a freeze test error (
test_freeze_with_requirement_option_multiple
), and realised how we built the candidate’s InstallRequirement is broken after merging PEP 610. This is because we were populating the InstallRequirement with the link’s URL asline
, which makes PEP 610 records the URL indirect_url.json
, and in turn causespip freeze
to use that URL in the output.The solution here is to use the
parent.req
as the line instead. This tells the PEP 610 implementation to not treat this as a direct URL, unlessparent.req
is itself a direct URL.cc @sbidoul it’d be nice if you could verify whether I’m understanding the PEP 610 implementation correctly.