Skip to content

Commit e74b501

Browse files
committed
Implement the test for being able to pass dist-info dir
1 parent 3106af0 commit e74b501

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

setuptools/build_meta.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,9 +417,12 @@ def build_wheel(
417417
config_settings: _ConfigSettings = None,
418418
metadata_directory: StrPath | None = None,
419419
):
420+
cmd = ['bdist_wheel']
421+
if metadata_directory:
422+
cmd.extend(['--dist-info-dir', metadata_directory])
420423
with suppress_known_deprecation():
421424
return self._build_with_temp_dir(
422-
['bdist_wheel'],
425+
cmd,
423426
'.whl',
424427
wheel_directory,
425428
config_settings,

setuptools/tests/test_bdist_wheel.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,3 +619,25 @@ def _fake_import(name: str, *args, **kwargs):
619619
monkeypatch.delitem(sys.modules, "setuptools.command.bdist_wheel")
620620

621621
import setuptools.command.bdist_wheel # noqa: F401
622+
623+
624+
def test_dist_info_provided(dummy_dist, monkeypatch, tmp_path):
625+
monkeypatch.chdir(dummy_dist)
626+
distinfo = tmp_path / "dummy_dist.dist-info"
627+
628+
distinfo.mkdir()
629+
(distinfo / "METADATA").write_text("name: helloworld", encoding="utf-8")
630+
631+
# We don't control the metadata. According to PEP-517, "The hook MAY also
632+
# create other files inside this directory, and a build frontend MUST
633+
# preserve".
634+
(distinfo / "FOO").write_text("bar", encoding="utf-8")
635+
636+
bdist_wheel_cmd(bdist_dir=str(tmp_path), universal=True, dist_info_dir=str(distinfo)).run()
637+
expected = {
638+
"dummy_dist-1.0.dist-info/FOO",
639+
"dummy_dist-1.0.dist-info/RECORD",
640+
}
641+
with ZipFile("dist/dummy_dist-1.0-py2.py3-none-any.whl") as wf:
642+
# Check that all expected files are there.
643+
assert set(wf.namelist()).intersection(expected) == expected

0 commit comments

Comments
 (0)