@@ -167,12 +167,12 @@ def add_wheelfile(self):
167
167
wheel_contents += "Tag: %s\n " % tag
168
168
self .add_string (self .distinfo_path ("WHEEL" ), wheel_contents )
169
169
170
- def add_metadata (self , metadata , description , version ):
170
+ def add_metadata (self , metadata , name , description , version ):
171
171
"""Write METADATA file to the distribution."""
172
172
# https://www.python.org/dev/peps/pep-0566/
173
173
# https://packaging.python.org/specifications/core-metadata/
174
- metadata += "Version: " + version
175
- metadata += "\n \n "
174
+ metadata = re . sub ( "^Name: .*$" , "Name: %s" % name , metadata , flags = re . MULTILINE )
175
+ metadata += "Version: %s \n \n " % version
176
176
# setuptools seems to insert UNKNOWN as description when none is
177
177
# provided.
178
178
metadata += description if description else "UNKNOWN"
@@ -207,18 +207,18 @@ def get_files_to_package(input_files):
207
207
return files
208
208
209
209
210
- def resolve_version_stamp (
211
- version : str , volatile_status_stamp : Path , stable_status_stamp : Path
210
+ def resolve_argument_stamp (
211
+ argument : str , volatile_status_stamp : Path , stable_status_stamp : Path
212
212
) -> str :
213
- """Resolve workspace status stamps format strings found in the version string
213
+ """Resolve workspace status stamps format strings found in the argument string
214
214
215
215
Args:
216
- version (str): The raw version represenation for the wheel (may include stamp variables)
216
+ argument (str): The raw argument represenation for the wheel (may include stamp variables)
217
217
volatile_status_stamp (Path): The path to a volatile workspace status file
218
218
stable_status_stamp (Path): The path to a stable workspace status file
219
219
220
220
Returns:
221
- str: A resolved version string
221
+ str: A resolved argument string
222
222
"""
223
223
lines = (
224
224
volatile_status_stamp .read_text ().splitlines ()
@@ -229,9 +229,9 @@ def resolve_version_stamp(
229
229
continue
230
230
key , value = line .split (" " , maxsplit = 1 )
231
231
stamp = "{" + key + "}"
232
- version = version .replace (stamp , value )
232
+ argument = argument .replace (stamp , value )
233
233
234
- return version
234
+ return argument
235
235
236
236
237
237
def parse_args () -> argparse .Namespace :
@@ -357,7 +357,16 @@ def main() -> None:
357
357
strip_prefixes = [p for p in arguments .strip_path_prefix ]
358
358
359
359
if arguments .volatile_status_file and arguments .stable_status_file :
360
- version = resolve_version_stamp (
360
+ name = resolve_argument_stamp (
361
+ arguments .name ,
362
+ arguments .volatile_status_file ,
363
+ arguments .stable_status_file ,
364
+ )
365
+ else :
366
+ name = arguments .name
367
+
368
+ if arguments .volatile_status_file and arguments .stable_status_file :
369
+ version = resolve_argument_stamp (
361
370
arguments .version ,
362
371
arguments .volatile_status_file ,
363
372
arguments .stable_status_file ,
@@ -366,7 +375,7 @@ def main() -> None:
366
375
version = arguments .version
367
376
368
377
with WheelMaker (
369
- name = arguments . name ,
378
+ name = name ,
370
379
version = version ,
371
380
build_tag = arguments .build_tag ,
372
381
python_tag = arguments .python_tag ,
@@ -398,7 +407,9 @@ def main() -> None:
398
407
with open (arguments .metadata_file , "rt" , encoding = "utf-8" ) as metadata_file :
399
408
metadata = metadata_file .read ()
400
409
401
- maker .add_metadata (metadata = metadata , description = description , version = version )
410
+ maker .add_metadata (
411
+ metadata = metadata , name = name , description = description , version = version
412
+ )
402
413
403
414
if arguments .entry_points_file :
404
415
maker .add_file (
0 commit comments