From 74e3299cd38524a008a5cbc44a06f24686298762 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Tue, 1 Aug 2023 14:48:05 -0400 Subject: [PATCH] fix: patch pyproject-metadata name Signed-off-by: Henry Schreiner --- src/scikit_build_core/settings/metadata.py | 5 ++++- tests/test_pyproject_pep517.py | 8 ++++---- tests/test_pyproject_pep518.py | 8 ++++---- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/scikit_build_core/settings/metadata.py b/src/scikit_build_core/settings/metadata.py index f0462ca76..3abde119f 100644 --- a/src/scikit_build_core/settings/metadata.py +++ b/src/scikit_build_core/settings/metadata.py @@ -44,4 +44,7 @@ def get_standard_metadata( for field in fields: pyproject_dict["project"]["dynamic"].remove(field) - return StandardMetadata.from_pyproject(pyproject_dict) + metadata = StandardMetadata.from_pyproject(pyproject_dict) + # pyproject-metadata normalizes the name - see https://github.com/FFY00/python-pyproject-metadata/pull/65 + metadata.name = pyproject_dict["project"]["name"] + return metadata diff --git a/tests/test_pyproject_pep517.py b/tests/test_pyproject_pep517.py index 96c04a14e..9feda9ab1 100644 --- a/tests/test_pyproject_pep517.py +++ b/tests/test_pyproject_pep517.py @@ -23,7 +23,7 @@ """ METADATA = """\ Metadata-Version: 2.1 -Name: cmake-example +Name: cmake_example Version: 0.0.1 Requires-Python: >=3.7 Provides-Extra: test @@ -173,7 +173,7 @@ def test_pep517_wheel(virtualenv): print(entry_points == ENTRYPOINTS) assert 'Requires-Dist: pytest>=6.0; extra == "test"' in metadata assert "Metadata-Version: 2.1" in metadata - assert "Name: cmake-example" in metadata + assert "Name: cmake_example" in metadata assert "Version: 0.0.1" in metadata assert "Requires-Python: >=3.7" in metadata assert "Provides-Extra: test" in metadata @@ -221,7 +221,7 @@ def test_pep517_wheel_source_dir(virtualenv): print(entry_points == ENTRYPOINTS) assert 'Requires-Dist: pytest>=6.0; extra == "test"' in metadata assert "Metadata-Version: 2.1" in metadata - assert "Name: cmake-example" in metadata + assert "Name: cmake_example" in metadata assert "Version: 0.0.1" in metadata assert "Requires-Python: >=3.7" in metadata assert "Provides-Extra: test" in metadata @@ -268,7 +268,7 @@ def test_prepare_metdata_for_build_wheel(): metadata = build.util.project_wheel_metadata(str(Path.cwd()), isolated=False) answer = { "Metadata-Version": "2.1", - "Name": "cmake-example", + "Name": "cmake_example", "Version": "0.0.1", "Requires-Python": ">=3.7", "Provides-Extra": "test", diff --git a/tests/test_pyproject_pep518.py b/tests/test_pyproject_pep518.py index a46a98c82..40047a1f0 100644 --- a/tests/test_pyproject_pep518.py +++ b/tests/test_pyproject_pep518.py @@ -16,7 +16,7 @@ def test_pep518_sdist(package_simple_pyproject_ext): correct_metadata = textwrap.dedent( """\ Metadata-Version: 2.1 - Name: cmake-example + Name: cmake_example Version: 0.0.1 Requires-Python: >=3.7 Provides-Extra: test @@ -26,7 +26,7 @@ def test_pep518_sdist(package_simple_pyproject_ext): subprocess.run([sys.executable, "-m", "build", "--sdist"], check=True) (sdist,) = Path("dist").iterdir() - assert sdist.name == "cmake-example-0.0.1.tar.gz" + assert sdist.name == "cmake_example-0.0.1.tar.gz" if not sys.platform.startswith(("win", "cygwin")): hash = hashlib.sha256(sdist.read_bytes()).hexdigest() @@ -35,7 +35,7 @@ def test_pep518_sdist(package_simple_pyproject_ext): with tarfile.open(sdist) as f: file_names = set(f.getnames()) assert file_names == { - f"cmake-example-0.0.1/{x}" + f"cmake_example-0.0.1/{x}" for x in ( "CMakeLists.txt", "pyproject.toml", @@ -44,7 +44,7 @@ def test_pep518_sdist(package_simple_pyproject_ext): "LICENSE", ) } - pkg_info = f.extractfile("cmake-example-0.0.1/PKG-INFO") + pkg_info = f.extractfile("cmake_example-0.0.1/PKG-INFO") assert pkg_info pkg_info_contents = pkg_info.read().decode() assert correct_metadata == pkg_info_contents