-
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
Support URL constraints in the new resolver #9673
Conversation
I tried to replicate those Windows failures, and I could not get sensible output out of tox. I feel like I need so much help with that that I don't even know what to ask for help with. |
You can’t use |
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.
I’ve only partially read the PR and need to think about the logic a bit more, but this looks very promising!
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.
This is awesome! I have some thoughts on the implementation, but the overall logic looks good to me.
Oh I forgot to mention, maybe we can introduce a |
I did my best to address the other concerns, but I haven't looked closely enough at the |
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.
I think this is ready!
@mwchase thanks a lot for this work! I've not had time to review but I made a first test. It works well but there is one issue I noticed: it does not generate Assuming
I've not had the chance to look in details yet. I guess at some point self.original_link must be set to be the constraint URL?. |
I haven't figured out how to fix that, but I did get a test written, so I pushed it just so this wouldn't look better than it is. |
So But a direct URL candidate created from a constraint does not have an We actually already have an Yet another solution would be to create a “fake” |
I tried a few different ways. I didn't figure out the way to make "fake" Using the constraint broke a bunch of the hash tests I added, and somehow didn't get the new test to pass. So, I don't think ignoring the actual requirements for template purposes will work. This sounds somewhat related to the note near the beginning of the factory's Would the right way to make a "fake" |
It may make more sense to use the lower level functions in What are the test failures you got if you use the ireq from the constraint as template? I think this approach makes most sense in abstract (although may be tedious in practice since we need to keep an ireq reference all the way down the code path), and we may be able to fix those errors instead if possible. |
I believe it somehow didn't actually create the |
That’d make sense, since the hashes are collected from InstallRequirements. So if we’re using the constraint’s ireq, we’ll need to manually populate the hashes back. |
I'm currently trying out a few things at once. One is to write my own helper to generate a template for the method. This seems to work, but as I was thinking about it, I noticed a hole in my test coverage, and I'm currently working on patching that. If writing my own function for "like this As far as the hole in the coverage, it should be the case that if a package has an editable requirement and a constraint URL, it should get an editable install. I think that was working, but I don't think I had a test, so I added one. |
It’d also make sense to put it somewhere in the resolver submodule since it is only used there. But I don’t think it really matters that much, let’s just put it somewhere and discuss after things work.
IIRC having both a URL and an editable (with the same URL, of course) in the requirements would currently fail the resolver, because installing an editable and non-editable are not technically interchangeable currently. Like the link equivalency issue, we should check what the resolver’s current logic is for requirements, and try to do the same thing with constraints for now, and revisit the whole logic afterwards (and change it for both if we decide to change it). |
I was basing my reasoning on #8253 (comment):
Which I interpreted as "unlike requirements, constraints should have no bearing on whether the install is editable", which implies that constraints should accept either situation for requirements. In any case, I'll get the code cleaned up and pushed in the next day or so. |
Works perfectly in all my tests with pip-deepfreeze. I'm not familiar enough with the new resolver logic to do a full review, but from a functional standpoint 👍, thank you! |
Giving the CI a kick |
If there are no objections I'm going to merge so it goes in 21.1 |
One thing, though, @mwchase could you squash your commits ? The history here is not very relevant, and that would help in the unlikely case we'd need to revert after release for any reason. |
ec8a034
to
4c69ab2
Compare
Thank you @mwchase ! |
@mwchase thank you for implementing this. Looking at your activity on issues like 8439 I get the impression that you are trying to enable a specific use case that you have. I suspect that I have a similar use case and I am curious to hear more about yours and how you have gone about to enabling it - I expect I could learn a thing or two. To shift the burden of communication slightly to my side, I will describe my use case, how I have solved it and what problems I am still facing. I maintain multiple, interdependent, private python packages in a single git repo. One reason for having multiple packages is that they deployed into different environments. Simplified the run time dependency graph looks something like below.
For the above example I would have a requirements file like below. This does not work on recent releases of pip.
A git filter is used to replace The requirements file is compiled to a constraints file using As for the problems that I am facing:
I apologize if this thread is the wrong forum but I could find no way to message you directly nor a better thread to ask in. |
Let's see. From what you've described, I think my use case is similar to yours, but simpler. (No editable installs, no expectation of running on another platform (yet).) So, right now the work and workarounds I have are sufficient for me. Now, here's what I remember about the state of things; this could be off because I was mostly focused on stuff relevant to my use cases.
Anyway, thinking over all of that, I think that, unless I'm missing something, your best bet may be to write some kind of a wrapper around Sorry for any inaccuracies, and that I couldn't be more help. |
Just getting your opinion has been helpful. Thanks for taking time to read and reply. |
So we can get this change: pypa/pip#9673 Released in Pip 21
This is an attempt to implement the behavior of URL constraints proposed in #8253 (comment). I got as far as "the tests look valid, and they pass". There are a number of choices I made where I feel like something else would be preferable, but I'm not sure what would be the best alternative.