Skip to content
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

feat(py_wheel): Add support for specifying Description-Content-Type and Summary in METADATA #1274

Merged
merged 8 commits into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions docs/packaging.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions examples/wheel/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ py_wheel(
console_scripts = {
"customized_wheel": "examples.wheel.main:main",
},
description_content_type = "text/markdown",
description_file = "README.md",
# Package data. We're building "example_customized-0.0.1-py3-none-any.whl"
distribution = "example_customized",
Expand Down
3 changes: 2 additions & 1 deletion examples/wheel/wheel_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def test_customized_wheel(self):
record_contents,
# The entries are guaranteed to be sorted.
b"""\
example_customized-0.0.1.dist-info/METADATA,sha256=YUnzQ9gTMXspIBURe90Ct3aL_CCn8fwC3SiZe6MMTs8,372
example_customized-0.0.1.dist-info/METADATA,sha256=aljrVBPlCkyemnrkcTr6DJRaNOqCd2CFrryZF67Nh8Y,412
example_customized-0.0.1.dist-info/NOTICE,sha256=Xpdw-FXET1IRgZ_wTkx1YQfo1-alET0FVf6V1LXO4js,76
example_customized-0.0.1.dist-info/README,sha256=WmOFwZ3Jga1bHG3JiGRsUheb4UbLffUxyTdHczS27-o,40
example_customized-0.0.1.dist-info/RECORD,,
Expand Down Expand Up @@ -129,6 +129,7 @@ def test_customized_wheel(self):
Author-email: example@example.com
Home-page: www.example.com
License: Apache 2.0
Description-Content-Type: text/markdown
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Intended Audience :: Developers
Requires-Dist: pytest
Expand Down
5 changes: 5 additions & 0 deletions python/private/py_wheel.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ _other_attrs = {
"classifiers": attr.string_list(
doc = "A list of strings describing the categories for the package. For valid classifiers see https://pypi.org/classifiers",
),
"description_content_type": attr.string(
doc = "The type of contents in description_file. See https://packaging.python.org/en/latest/specifications/core-metadata/#description-content-type",
),
"description_file": attr.label(
doc = "A file containing text describing the package.",
allow_single_file = True,
Expand Down Expand Up @@ -275,6 +278,8 @@ 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.description_content_type:
sfc-gh-zpeng marked this conversation as resolved.
Show resolved Hide resolved
metadata_contents.append("Description-Content-Type: %s" % ctx.attr.description_content_type)

for c in ctx.attr.classifiers:
metadata_contents.append("Classifier: %s" % c)
Expand Down
3 changes: 3 additions & 0 deletions tools/wheelmaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,9 @@ def parse_args() -> argparse.Namespace:
wheel_group.add_argument(
"--description_file", help="Path to the file with package description"
)
wheel_group.add_argument(
"--description_content_type", help="Content type of the package description"
)
wheel_group.add_argument(
"--entry_points_file",
help="Path to a correctly-formatted entry_points.txt file",
Expand Down