Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f3fb481

Browse filesBrowse files
keithaignas
andcommitted
fix: parsing metadata with inline licenses (bazel-contrib#2806)
The wheel `METADATA` parsing implemented in 1.4 missed the fact that whitespace is significant and sometimes License is included inline in the `METADATA` file itself. This change ensures that we stop parsing the `METADATA` file only on first completely empty line. Fixes bazel-contrib#2796 --------- Co-authored-by: Ignas Anikevicius <240938+aignas@users.noreply.github.com> (cherry picked from commit 1d69ad6)
1 parent 7dd901c commit f3fb481
Copy full SHA for f3fb481

File tree

Expand file treeCollapse file tree

2 files changed

+32
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+32
-1
lines changed

‎python/private/pypi/whl_metadata.bzl

Copy file name to clipboardExpand all lines: python/private/pypi/whl_metadata.bzl
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def parse_whl_metadata(contents):
5252
"version": "",
5353
}
5454
for line in contents.strip().split("\n"):
55-
if not line.strip():
55+
if not line:
5656
# Stop parsing on first empty line, which marks the end of the
5757
# headers containing the metadata.
5858
break

‎tests/pypi/whl_metadata/whl_metadata_tests.bzl

Copy file name to clipboardExpand all lines: tests/pypi/whl_metadata/whl_metadata_tests.bzl
+31Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,37 @@ Requires-Dist: this will be ignored
140140

141141
_tests.append(_test_parse_metadata_all)
142142

143+
def _test_parse_metadata_multiline_license(env):
144+
got = _parse_whl_metadata(
145+
env,
146+
# NOTE: The trailing whitespace here is meaningful as an empty line
147+
# denotes the end of the header.
148+
contents = """\
149+
Name: foo
150+
Version: 0.0.1
151+
License: some License
152+
153+
some line
154+
155+
another line
156+
157+
Requires-Dist: bar; extra == "all"
158+
Provides-Extra: all
159+
160+
Requires-Dist: this will be ignored
161+
""",
162+
)
163+
got.name().equals("foo")
164+
got.version().equals("0.0.1")
165+
got.requires_dist().contains_exactly([
166+
"bar; extra == \"all\"",
167+
])
168+
got.provides_extra().contains_exactly([
169+
"all",
170+
])
171+
172+
_tests.append(_test_parse_metadata_multiline_license)
173+
143174
def whl_metadata_test_suite(name): # buildifier: disable=function-docstring
144175
test_suite(
145176
name = name,

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.