-
-
Notifications
You must be signed in to change notification settings - Fork 614
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
Respect platform's wheels for dependencies (Fixes #558) #571
Respect platform's wheels for dependencies (Fixes #558) #571
Conversation
5f8a3f5
to
0745ac4
Compare
Requesting review from @suutari-ai and @jdufresne |
piptools/repositories/base.py
Outdated
@contextmanager | ||
def allow_all_wheels(self): | ||
""" | ||
Monkey patches pip.Wheel to allow wheels from all platoforms and Python versions. |
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.
Typo platoforms -> platforms (multiple docstrings)
piptools/repositories/pypi.py
Outdated
Wheel.support_index_min = _wheel_support_index_min | ||
self._available_candidates_cache = {} | ||
|
||
yield |
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 would wrap this in a try
/finally
in case an exception is raised and then caught somewhere else in the stack.
try:
yield
finally:
Wheel.supported = original_wheel_supported
Wheel.support_index_min = original_support_index_min
self._available_candidates_cache = original_cache
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.
Well I learned something today, I though the exiting part would always be called, even with an exception, without the try
. Just tried it out and you're right, will fix this, thanks.
0745ac4
to
81cf817
Compare
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.
LGTM. Thanks for investigating and fixing this!
Thanks @vphilippon. Good work! Nevertheless, don't get me wrong, but I think this is still quite hacky, and I don't see the point. Why don't you just revert the commit 4900c7c which is causing this? Why would I ever want hashes of non-compatible wheels to my requirements.txt? If you're trying to generate a As I said in PR #460, my opinion is that requirements.txt should be locking a single set of the requirements which is tested to work. The point of locking the versions is to get reproducible environment and if the platform or Python version is different, then it's no more reproducible: Those packages might act very differently on another platform and, as seen here, even the required packages might be different. The whole point why I want locked requirements is confidence and having platform independent If I want to install a project for another platform (which is untested), then I should be using the |
Because I wasn't member of @jazzband yet. I joined now. Didn't know it's that easy to join. |
A lot of this is described in the commit message and issue #520. But I'll summarize. I work on a project that has a diverse group of environments:
My Project is Python 3 only. For security purpose, I want to generate package hashes for some additional verification that the download is correct. In 1.9.0, when generating requirements.txt on one machine it might fail when running on another machine. It failed because the hashes generated were not compatible with the running OS & Python
I saw 1 as the best tradeoff at the time (and still do).
Maybe it is just "luck" of my dependencies, but I'm not seeing an issue regarding transitive packags in my project.
I understand. But with hashes specific to binary platforms, this means the requirements.txt is only useful for identical environments to which it was generated. This seems limiting to me. |
@suutari-ai Thanks for the review and detailed explanation of your concern. As @jdufresne mentionned, while a compiled
In the case where a Currently, I see no harm in having If it had been impossible (or way too hard) to keep the feature without breaking the dependencies resolving, I would have suggested to revert of course. @suutari-ai I think a case justifying the feature to be kept has been provided. If you have a case or example that would prove this feature to be harmful to the users, outweighing the gain, please provide it (this is exactly why I requested your review, I definitely wanted a second opinion on this). |
I think this is very fair. If an argument or evidence can be provided to show that this will be too difficult to maintain or is breaking previously working environments. Then I agree, reverting the feature is justified. |
You're missing couple options:
IMHO this would make sense, since having only the hashes of the main platform in the txt file should help ensuring that CI is testing the same stuff as is installed to production. But anyway. I'm not against merging this. Even though it's not something that I want, it's still a feature that someone finds useful. And merging this should make pip-compile work better and would only make it easier to add an option to disable the 'generate hashes for all platforms'. |
For me the 'generate hashes for all platforms' feature is more harmful than useful, because I don't want hashes of another platform to my txt files. It's also encouraging users to reuse the same requirements.txt on different platforms, which IMHO is not a good idea.
But the feature is there already. Fixing it is wise. 👍 |
This seems like a mess to manage, honestly.
A problem with this is the requirements in Easily pinned dependencies was the killer feature to adopt pip-tools in the first place.
Hmm, this is interesting to me. @suutari-ai I think you make a convincing argument. I may be persuaded that generating all hashes was a bad idea for a |
Yeah, this certainly needs some tooling and a new feature so that it would be possible to generate a txt for another platform.
Different platforms will also cause behavior differences. Only way to get exactly same behavior is to remove that factor too. Also, if it's not working with a certain version of a requirement, you should either (a) make it work with it by changing your code or (b) limit out the non-working versions in
Maybe it should be optional at least? (Which would be another PR, of course.) For Prequ, I just reverted it (suutari#12), since my plan there is to implement the 'generate a txt for another platform' feature, but it seems that pip-tools is going to another direction. That's OK too, since I'll probably just use my own tool anyway. 😄 If the feature is not reverted, then this fix should be merged at least. |
@suutari-ai @jdufresne Thanks you both for your input on this. |
Keep pip.Wheel monkey patch only in the get_hashes context.
Fixes #558
Contributor checklist