Skip to content

Commit

Permalink
fix: patch pyproject-metadata name
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
  • Loading branch information
henryiii committed Aug 1, 2023
1 parent d77ea0a commit 74e3299
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
5 changes: 4 additions & 1 deletion src/scikit_build_core/settings/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 4 additions & 4 deletions tests/test_pyproject_pep517.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand Down
8 changes: 4 additions & 4 deletions tests/test_pyproject_pep518.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand All @@ -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",
Expand All @@ -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
Expand Down

0 comments on commit 74e3299

Please sign in to comment.