-
-
Notifications
You must be signed in to change notification settings - Fork 577
fix(packaging): Format METADATA
correctly if given empty requires_file
#2771
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
Conversation
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.
Thanks, I am not sure I like using regex to solve this, but I see how doing that makes the change smaller and less invasive.
Do you know where the Requires-Dist
appears from in the first place? Maybe we should error if the requirements are empty/not-specified? I see that the metadata file is read from a file, so I assume this could be templated out somewhere else in our code.
Extra things that this PR will need:
- The packaging rule should have
:::versionchanged:::
when we agree on the behaviour change. - The CHANGELOG entry should be there mentioning the fix briefly.
examples/wheel/wheel_test.py
Outdated
if line.startswith("Requires-Dist:"): | ||
requires.append(line.strip()) | ||
|
||
print(requires) |
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.
Should this be removed?
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.
Yep, I just copied and pasted it from the other test. Should I remove the print statement there as well?
I don't really like it either. If you look at the commit history you will see I attempted to reconstruct the
It comes in via this file as far as I can tell: rules_python/python/private/py_wheel.bzl Line 396 in 2cb920c
Personally, I would prefer the empty file case to be handled seamlessly (like in this PR), than fail. I believe this is what Right now, we wrap
Adding now. |
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.
Thank you!
An empty
requires_file
used to be okay, but at some point regressed to leaving an empty line (due to themetadata.replace(...)
) in theMETADATA
file - rendering the wheel uninstallable.This PR initially attempted to solve that by introducing a new list that processed
METADATA
lines go into, rather than relying on repeated string replacement. But it seems like the repeated string replace actually did more than simply process one line at a time, so I reverted to a single substitution at the end.