-
-
Notifications
You must be signed in to change notification settings - Fork 713
feat: add PEP 639 license metadata support #4070
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -251,6 +251,14 @@ be moved under that directory. | |
| doc = "A string specifying the license of the package.", | ||
| default = "", | ||
| ), | ||
| "license_expression": attr.string( | ||
| doc = "An SPDX license expression for the package.", | ||
| default = "", | ||
| ), | ||
| "license_files": attr.label_keyed_string_dict( | ||
| doc = "License files to include under the .dist-info/licenses/ directory.", | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the value for this dict? the path under licenses to put the files under? The behavior needs to be documented. How are files mapped under the licenses directory? Files could come from elsewhere in the repo This attribute mostly redundant with the extra_distinfo_files attribute. The only differnce is where in dist-info files go (this puts them under licenses) Given all this, I think we should just remove this field. |
||
| allow_files = True, | ||
| ), | ||
| "project_urls": attr.string_dict( | ||
| doc = ("A string dict specifying additional browsable URLs for the project and corresponding labels, " + | ||
| "where label is the key and url is the value. " + | ||
|
|
@@ -419,7 +427,17 @@ def _py_wheel_impl(ctx): | |
| # Note: Description file and version are not embedded into metadata.txt yet, | ||
| # it will be done later by wheelmaker script. | ||
| metadata_file = ctx.actions.declare_file(ctx.attr.name + ".metadata.txt") | ||
| metadata_contents = ["Metadata-Version: 2.1"] | ||
| if ctx.attr.license and ctx.attr.license_expression: | ||
| fail( | ||
| "`license` and `license_expression` are mutually exclusive. " | ||
| + "Please use only one of them." | ||
| ) | ||
|
|
||
| metadata_version = "2.4" if ( | ||
| ctx.attr.license_expression or ctx.attr.license_files | ||
| ) else "2.1" | ||
|
|
||
| metadata_contents = ["Metadata-Version: %s" % metadata_version] | ||
| metadata_contents.append("Name: %s" % ctx.attr.distribution) | ||
|
|
||
| if ctx.attr.author: | ||
|
|
@@ -430,6 +448,12 @@ def _py_wheel_impl(ctx): | |
| metadata_contents.append("Home-page: %s" % ctx.attr.homepage) | ||
| if ctx.attr.license: | ||
| metadata_contents.append("License: %s" % ctx.attr.license) | ||
| if ctx.attr.license_expression: | ||
| metadata_contents.append( | ||
| "License-Expression: %s" % ctx.attr.license_expression | ||
| ) | ||
| for _, license_file in sorted(ctx.attr.license_files.items()): | ||
| metadata_contents.append("License-File: %s" % license_file) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is every license file supposed to be listed as a License-File header? I'm guessing a PEP specifies this? Which one? Because extra_distinfo_files could add license files, I'm thinking the population of License-File should move to the execution phase.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. This is specified by PEP 639. In the The |
||
| if ctx.attr.description_content_type: | ||
| metadata_contents.append("Description-Content-Type: %s" % ctx.attr.description_content_type) | ||
| elif ctx.attr.description_file: | ||
|
|
||
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 license file paths are used, but the files themselves aren't being included in the output