File tree Expand file tree Collapse file tree 3 files changed +51
-1
lines changed Expand file tree Collapse file tree 3 files changed +51
-1
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change @@ -303,6 +303,25 @@ def _test_whls(env):
303303 yanked = False ,
304304 ),
305305 ),
306+ (
307+ struct (
308+ attrs = [
309+ 'href="/whl/cpu/torch-2.6.0%2Bcpu-cp39-cp39-manylinux_2_28_aarch64.whl#sha256=deadbeef"' ,
310+ ],
311+ filename = "torch-2.6.0+cpu-cp39-cp39-manylinux_2_28_aarch64.whl" ,
312+ url = "https://example.org/" ,
313+ ),
314+ struct (
315+ filename = "torch-2.6.0+cpu-cp39-cp39-manylinux_2_28_aarch64.whl" ,
316+ metadata_sha256 = "" ,
317+ metadata_url = "" ,
318+ sha256 = "deadbeef" ,
319+ version = "2.6.0+cpu" ,
320+ # A URL with % could occur if directly written in requirements.
321+ url = "https://example.org/whl/cpu/torch-2.6.0%2Bcpu-cp39-cp39-manylinux_2_28_aarch64.whl" ,
322+ yanked = False ,
323+ ),
324+ ),
306325 ]
307326
308327 for (input , want ) in tests :
Original file line number Diff line number Diff 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+
143174def whl_metadata_test_suite (name ): # buildifier: disable=function-docstring
144175 test_suite (
145176 name = name ,
You can’t perform that action at this time.
0 commit comments