Skip to content

Commit bc82d73

Browse files
committed
Implement the desired functionality
1 parent e74b501 commit bc82d73

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

setuptools/command/bdist_wheel.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,13 @@ class bdist_wheel(Command):
231231
None,
232232
"Python tag (cp32|cp33|cpNN) for abi3 wheel tag [default: false]",
233233
),
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+
),
234241
]
235242

236243
boolean_options = ["keep-temp", "skip-build", "relative", "universal"]
@@ -243,6 +250,7 @@ def initialize_options(self) -> None:
243250
self.format = "zip"
244251
self.keep_temp = False
245252
self.dist_dir: str | None = None
253+
self.dist_info_dir = None
246254
self.egginfo_dir: str | None = None
247255
self.root_is_pure: bool | None = None
248256
self.skip_build = False
@@ -261,8 +269,9 @@ def finalize_options(self) -> None:
261269
bdist_base = self.get_finalized_command("bdist").bdist_base
262270
self.bdist_dir = os.path.join(bdist_base, "wheel")
263271

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`
266275

267276
self.data_dir = self.wheel_dist_name + ".data"
268277
self.plat_name_supplied = bool(self.plat_name)
@@ -447,7 +456,15 @@ def run(self):
447456
f"{safer_version(self.distribution.get_version())}.dist-info"
448457
)
449458
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)
451468

452469
self.write_wheelfile(distinfo_dir)
453470

0 commit comments

Comments
 (0)