@@ -231,6 +231,13 @@ class bdist_wheel(Command):
231
231
None ,
232
232
"Python tag (cp32|cp33|cpNN) for abi3 wheel tag [default: false]" ,
233
233
),
234
+ (
235
+ "dist-info-dir=" ,
236
+ None ,
237
+ "directory where a pre-generated dist-info can be found (e.g. as a "
238
+ "result of calling the PEP517 'prepare_metadata_for_build_wheel' "
239
+ "method)" ,
240
+ ),
234
241
]
235
242
236
243
boolean_options = ["keep-temp" , "skip-build" , "relative" , "universal" ]
@@ -243,6 +250,7 @@ def initialize_options(self) -> None:
243
250
self .format = "zip"
244
251
self .keep_temp = False
245
252
self .dist_dir : str | None = None
253
+ self .dist_info_dir = None
246
254
self .egginfo_dir : str | None = None
247
255
self .root_is_pure : bool | None = None
248
256
self .skip_build = False
@@ -261,8 +269,9 @@ def finalize_options(self) -> None:
261
269
bdist_base = self .get_finalized_command ("bdist" ).bdist_base
262
270
self .bdist_dir = os .path .join (bdist_base , "wheel" )
263
271
264
- egg_info = cast (egg_info_cls , self .distribution .get_command_obj ("egg_info" ))
265
- egg_info .ensure_finalized () # needed for correct `wheel_dist_name`
272
+ if self .dist_info_dir is None :
273
+ egg_info = self .distribution .get_command_obj ("egg_info" )
274
+ egg_info .ensure_finalized () # needed for correct `wheel_dist_name`
266
275
267
276
self .data_dir = self .wheel_dist_name + ".data"
268
277
self .plat_name_supplied = bool (self .plat_name )
@@ -447,7 +456,15 @@ def run(self):
447
456
f"{ safer_version (self .distribution .get_version ())} .dist-info"
448
457
)
449
458
distinfo_dir = os .path .join (self .bdist_dir , distinfo_dirname )
450
- self .egg2dist (self .egginfo_dir , distinfo_dir )
459
+ if self .dist_info_dir :
460
+ # Use the given dist-info directly.
461
+ shutil .copytree (self .dist_info_dir , distinfo_dir )
462
+ # Egg info is still generated, so remove it now to avoid it getting
463
+ # copied into the wheel.
464
+ shutil .rmtree (self .egginfo_dir )
465
+ else :
466
+ # Convert the generated egg-info into dist-info.
467
+ self .egg2dist (self .egginfo_dir , distinfo_dir )
451
468
452
469
self .write_wheelfile (distinfo_dir )
453
470
0 commit comments