-
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
metadata-only resolve with pip download --dry-run --report
!
#10748
Conversation
401ba1d
to
6360d8d
Compare
I think this needs:
|
This should use PEP 658 unless there are explicit reasons otherwise. |
We can also utilise that in a follow up, which adds support for PEP 658 across the board (i.e. allowing regular installations to also benefit from that). I don't think that PEP's use should be a blocking concern for this PR -- but it's definitely a really good idea to also utilise that. |
@uranusjr: absolutely will do! I assumed there was prior work on how to frame this change and am ready to conform to it. Looking that up right now. Thank you @pradyunsg for help on framing that. |
Ok, remembering the content of that PEP and checking out https://www.python.org/dev/peps/pep-0658/#specification -- @uranusjr I'm thinking that it might be appropriate to:
Separately, I've realized I shouldn't be keying the output of @pradyunsg does that sound like a reasonable approach? I plan to stick with this work until done, so I can promise to do that in a followup as well if appropriate. |
@uranusjr: made a ton of progress on PEP 658 support and I think it's feasible to include in this PR! There are a few hacks I made in the most recent commit, so I just converted this to a draft PR. I don't believe too many changes should be necessary to remove the hacks, and I think in fact that we will actually end up converting some of the existing |
72d8357
to
8c755e8
Compare
Ok, I've marked this PR as ready for review again. I think the bits that:
are pretty readable and don't modify the surrounding code too much. You'll note I moved some functions from The two issues I'd like some advice on relate to testing:
Thanks for any input! I will try to address the two issues I mentioned above presently. |
Can the types of situation where this PR would be useful be summarised in a general way, without reference to specific examples? As someone who's never needed anything like this, I'm a bit unclear when (and how) someone would find this useful. What I'd like to be clear about is how we evaluate the benefit of a change like this, which has a visible cost in terms of (code and maintenance) complexity. I'm also concerned about the user interface here. Having a |
With this change, users can use pip's powerful new resolver to extract metadata from a package resolution, such as what dependencies each package requires. This is currently not possible in pip or any other tool I am aware of. Getting more specific, this result can then be processed by external tools to:
#53 has a discussion in greater depth on this proposed feature.
This totally makes sense. I think shoving this into So I think if I move this into a new What are your thoughts on that approach? |
That sounds like something to put into #53's resolve command; which would be what I'd prefer. |
The new command would need:
|
This was just done in c78bb3d!
I will look into doing the above (as well as covering other goals of #53's resolve command that I may have missed) presently! |
3765b8d
to
c78bb3d
Compare
Thanks, @cosmicexplorer that was exactly the explanation I needed. I agree this would be good, and I like @pradyunsg's suggestion that this should go under Personally, I wish that functionality like this could be separated out into more modular tools, because I don't see this as being a core piece of pip functionality, rather it's a piece of functionality that needs to be in pip just to re-use chunks of pip's machinery. But that's a whole other discussion, and not for now. |
Thanks for your feedback @groodt ! I certainly hope this does not come across as any kind of competition. Now if I get to continue this work (which I'm happy to, as I sincerely believe this is going to be very valuable for the community), I'll definitely reuse part of the very valuable work done here (with proper credits of course). There might also be use cases of @cosmicexplorer or others that the slightly different format I propose may not address, and I'm eager to get feedback about that too. |
7cb145a
to
18bf0f8
Compare
18bf0f8
to
dc36f0e
Compare
- create LinkWithSource to retain attrs from InstallRequirement - add tests for report output for top-level requirements - add tests for more of the report JSON format - add passing tests for JSON report output including PEP 658! - add docstrings to several classes and functions, including tests! - move the --report implementation into resolvelib - use an abstract base class instead of a Union for InfoType - use frozen dataclasses for InfoType subclasses
these two objects are intended to be fungible, but play different roles, since LinkHash actually parses its input and ArchiveInfo does not. ArchiveInfo's JSON (de)?serialization does not employ hash name or value validation, while LinkHash does not offer a JSON serialization.
dc36f0e
to
c068eb5
Compare
Thanks so much to @ofek for pinging me on twitter about this!! I absolutely have the time to get this mergeable in the next few weeks. I just fixed the merge conflicts and tests are passing again locally, so I will now review the thoughtful proposals from others in this thread. |
I'll look to do this. I believe that some of the reason for my decision to add functionality to
This seems absolutely correct, and I was going to immediately agree to it, before realizing that there is another possible split we could do in this work which relies on #10771 (where we would split out
I really appreciate your thoughtful comment. I now agree with both of you, and have acknowledged this in #10771 (comment). The below section came from thinking about how to reformulate this PR to augment the much smaller and nicer implementation in #10771, instead of being in conflict. Comparison of Approaches to
|
So to be clear on next steps after that lengthy comment, I'm planning to:
|
Thanks for your detailed feedback @cosmicexplorer. It looks like we have a path forward ! Regarding PEP 658 I totally agree it can and should be implemented independently. In my mind it is an optimization of the metadata preparation step when the index provides |
It turns out that this refactoring was already done for the purpose of |
@cosmicexplorer What's the next piece here, with #11111 resolved? IIUC, we need to now make |
I was talking to @jjhelmus about a way to make --dry-run faster...apparently he discovered that |
@jjhelmus @hrfuller I would love to see that patch! That's definitely what I wanted to accomplish here.
@pradyunsg Sorry for writing such a sprawling comment above! Yes, I think that would be the way to finish up this workstream. I suspect we may find a speedup if we can implement some form of pipelining, where we pull down wheel metadata or execute I think a conclusive win would be to avoid downloading wheels as well with |
As @hrfuller mentioned I have been exploring metadata only resolves. What I found was that with the changes from #11111 metadata only resolves are possible but at the end of the resolve the With the changes in #11512, this information is provided by the .metadata files directly and no wheels need to be downloaded. Thanks for your work on this @cosmicexplorer . I was really excited when I discovered that this was possible. |
I this we can close this, as it is covered by |
Hello! This is the beginning of an attempt to follow up on the gratuitous speedup promised in #7819. While I still need to spend more time on parallelizing downloads in another branch, I'd like to propose this change first as it's totally orthogonal to downloading files!
Problem
With this change, users can use pip's powerful new resolver to extract metadata from a package resolution, such as what dependencies each package requires. This is currently not possible in pip or any other tool I am aware of.
Getting more specific, this result can then be processed by external tools to:
#53 has a discussion in greater depth on this proposed feature.
Solution
Add a
pip download --report
flag which can produce a JSON output file to examine the relationships between dependencies duringpip download
. This PR also implementsPEP 658
support, allowingpip download --report
to test PEP 658 compliance.