Skip to content

Commit

Permalink
feat: 0.11+ default to metadata 2.2 (#986)
Browse files Browse the repository at this point in the history
This has big performance benefits, and should be well supported now.

Signed-off-by: Henry Schreiner <[email protected]>
  • Loading branch information
henryiii authored Feb 7, 2025
1 parent 122ed79 commit c3348bf
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 16 deletions.
6 changes: 6 additions & 0 deletions src/scikit_build_core/build/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,10 @@ def get_standard_metadata(
"Packaging 24.2+ required for license normalization. Please update (Python 3.8+ required)"
)

# For scikit-build-core >= 0.11, we set METADATA 2.2 as minimum
if (
settings.minimum_version is None or settings.minimum_version >= Version("0.11")
) and metadata.auto_metadata_version == "2.1":
metadata.metadata_version = "2.2"

return metadata
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ if (NOT DEFINED _${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR)
message (FATAL_ERROR "FindPython: INTERNAL ERROR")
endif()
if (_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR EQUAL "3")
set(_${_PYTHON_PREFIX}_VERSIONS 3.12 3.11 3.10 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0)
set(_${_PYTHON_PREFIX}_VERSIONS 3.14 3.13 3.12 3.11 3.10 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0)
elseif (_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR EQUAL "2")
set(_${_PYTHON_PREFIX}_VERSIONS 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0)
else()
Expand Down
8 changes: 4 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,10 @@ def package_simple_pyproject_ext(
) -> PackageInfo:
package = PackageInfo(
"simple_pyproject_ext",
"72cd37019e113cbabebdceb79bc867f8e1a4fc7323b6a272e6a77d6ea384d3e8",
"be15157c8659f258b73eb474616473d60945c4d45693796b55234ec83893263a",
"d97cd496aa6c46df2caf5064a7765588c831b8db9d7b46a536026ed951ce724a",
"b1182a2aa7a2b81365b3ad7ae1839b20d983ef10b6c3de16b681c23f536ca1b7",
"58a92cd71f7750633296b0a44363e661ed83a908985158b83c187043ace6de4a",
"83c81c1b9ce2e065ac30d129d48628e01a37248f15035a8427a045a7d8e40c43",
"d04620a35f173ce8c94dbfdc48543e7b9f33474d6ee51221eec78b49f38b8766",
"d8b64bff613747b421f7c705bd9ce41b95164772a5b96789b27df79d83836148",
)
process_package(package, tmp_path, monkeypatch)
return package
Expand Down
2 changes: 1 addition & 1 deletion tests/test_prepare_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_prepare_metadata_for_build(fp, editable):
assert (
textwrap.dedent(
"""\
Metadata-Version: 2.1
Metadata-Version: 2.2
Name: simplest
Version: 0.0.1"""
)
Expand Down
10 changes: 5 additions & 5 deletions tests/test_pyproject_pep517.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def test_pep517_sdist():
expected_metadata = (
inspect.cleandoc(
"""
Metadata-Version: 2.1
Metadata-Version: 2.2
Name: CMake.Example
Version: 0.0.1
Requires-Python: >=3.7
Expand Down Expand Up @@ -226,7 +226,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 "Metadata-Version: 2.2" in metadata
assert "Name: CMake.Example" in metadata
assert "Version: 0.0.1" in metadata
assert "Requires-Python: >=3.7" in metadata
Expand Down Expand Up @@ -279,7 +279,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 "Metadata-Version: 2.2" in metadata
assert "Name: CMake.Example" in metadata
assert "Version: 0.0.1" in metadata
assert "Requires-Python: >=3.7" in metadata
Expand Down Expand Up @@ -331,7 +331,7 @@ def test_pep517_wheel_time_hash(monkeypatch):
def test_prepare_metdata_for_build_wheel():
metadata = build.util.project_wheel_metadata(str(Path.cwd()), isolated=False)
answer = {
"Metadata-Version": "2.1",
"Metadata-Version": "2.2",
"Name": "CMake.Example",
"Version": "0.0.1",
"Requires-Python": ">=3.7",
Expand All @@ -353,7 +353,7 @@ def test_prepare_metdata_for_build_wheel_by_hand(tmp_path):
print("Metadata dir:", (mddir / out).resolve())
metadata = PathDistribution(mddir / out).metadata
answer = {
"Metadata-Version": "2.1",
"Metadata-Version": "2.2",
"Name": "CMake.Example",
"Version": "0.0.1",
"Requires-Python": ">=3.7",
Expand Down
4 changes: 2 additions & 2 deletions tests/test_pyproject_pep518.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def compute_uncompressed_hash(inp: Path):
def test_pep518_sdist(isolated, package_simple_pyproject_ext):
correct_metadata = textwrap.dedent(
"""\
Metadata-Version: 2.1
Metadata-Version: 2.2
Name: CMake.Example
Version: 0.0.1
Requires-Python: >=3.7
Expand Down Expand Up @@ -74,7 +74,7 @@ def test_pep518_sdist_with_cmake_config(isolated, cleanup_overwrite):

correct_metadata = textwrap.dedent(
"""\
Metadata-Version: 2.1
Metadata-Version: 2.2
Name: sdist_config
Version: 0.1.0
Expand Down
2 changes: 1 addition & 1 deletion tests/test_pyproject_pep660.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def test_pep660_wheel(editable_mode: str):
assert "_simplest_editable.py" not in file_names
assert "_simplest_editable.pth" in file_names

assert "Metadata-Version: 2.1" in metadata
assert "Metadata-Version: 2.2" in metadata
assert "Name: simplest" in metadata
assert "Version: 0.0.1" in metadata

Expand Down
5 changes: 3 additions & 2 deletions tests/test_wheelfile_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ def test_wheel_writer_simple(tmp_path, monkeypatch):
"name": "something",
"version": "1.2.3",
},
}
},
metadata_version="2.3",
)
out_dir = tmp_path / "out"

Expand All @@ -46,7 +47,7 @@ def test_wheel_writer_simple(tmp_path, monkeypatch):

dist_info = wheel.dist_info_contents()
assert dist_info == {
"METADATA": b"Metadata-Version: 2.1\nName: something\nVersion: 1.2.3\n\n",
"METADATA": b"Metadata-Version: 2.3\nName: something\nVersion: 1.2.3\n\n",
"WHEEL": b"Wheel-Version: 1.0\nGenerator: scikit-build-core 1.2.3\nRoot-Is-Purelib: false\nTag: py3-none-any\n\n",
}

Expand Down

0 comments on commit c3348bf

Please sign in to comment.