Skip to content

Commit e1fbcbe

Browse files
Ben Rowlandhenryiii
Ben Rowland
authored andcommitted
feat: add config_settings as metadata plugin argument
1 parent 095d9bd commit e1fbcbe

File tree

6 files changed

+28
-12
lines changed

6 files changed

+28
-12
lines changed

src/scikit_build_core/build/wheel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def _build_wheel_impl(
7373

7474
settings_reader.validate_may_exit()
7575

76-
metadata = get_standard_metadata(pyproject, settings)
76+
metadata = get_standard_metadata(pyproject, settings, config_settings)
7777

7878
if metadata.version is None:
7979
msg = "project.version is not statically specified, must be present currently"

src/scikit_build_core/builder/wheel_tag.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def compute_best(
3737
pyvers = [interp]
3838

3939
if sys.platform.startswith("win") and archs:
40-
plats = (x.replace("-", "_") for x in archs)
40+
plats = [x.replace("-", "_") for x in archs]
4141
elif sys.platform.startswith("darwin"):
4242
pairs: Iterable[tuple[str | None, bool]]
4343
if expand_macos and archs == ["universal2"]:

src/scikit_build_core/metadata/fancy_pypi_readme.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ def __dir__() -> list[str]:
1010

1111

1212
def dynamic_metadata(
13-
pyproject_dict: dict[str, Any]
13+
pyproject_dict: dict[str, Any],
14+
_config_settings: dict[str, list[str] | str] | None = None,
1415
) -> dict[str, str | dict[str, str | None]]:
1516
from hatch_fancy_pypi_readme._builder import build_text
1617
from hatch_fancy_pypi_readme._config import load_and_validate_config

src/scikit_build_core/metadata/setuptools_scm.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ def __dir__() -> list[str]:
88

99

1010
def dynamic_metadata(
11-
pyproject_dict: dict[str, object] # noqa: ARG001
11+
pyproject_dict: dict[str, object], # noqa: ARG001
12+
_config_settings: dict[str, list[str] | str] | None = None,
1213
) -> dict[str, str | dict[str, str | None]]:
1314
# this is a classic implementation, waiting for the release of
1415
# vcs-versioning and an improved public interface

src/scikit_build_core/settings/metadata.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,19 @@ def __dir__() -> list[str]:
1414
return __all__
1515

1616

17-
def _load(mod_name: str, pyproject_dict: dict[str, Any]) -> dict[str, Any]:
18-
return importlib.import_module(mod_name).dynamic_metadata(pyproject_dict) # type: ignore[no-any-return]
17+
def _load(
18+
mod_name: str,
19+
pyproject_dict: dict[str, Any],
20+
config_settings: dict[str, list[str] | str] | None = None,
21+
) -> dict[str, Any]:
22+
return importlib.import_module(mod_name).dynamic_metadata(pyproject_dict, config_settings) # type: ignore[no-any-return]
1923

2024

2125
# If pyproject-metadata eventually supports updates, this can be simplified
2226
def get_standard_metadata(
23-
pyproject_dict: dict[str, Any], settings: ScikitBuildSettings
27+
pyproject_dict: dict[str, Any],
28+
settings: ScikitBuildSettings,
29+
config_settings: dict[str, list[str] | str] | None = None,
2430
) -> StandardMetadata:
2531
# Handle any dynamic metadata
2632
for field in settings.metadata:
@@ -29,7 +35,9 @@ def get_standard_metadata(
2935
raise KeyError(msg)
3036

3137
plugins = set(settings.metadata.values())
32-
cached_plugins = {key: _load(key, pyproject_dict) for key in plugins}
38+
cached_plugins = {
39+
key: _load(key, pyproject_dict, config_settings) for key in plugins
40+
}
3341

3442
for field, mod_name in settings.metadata.items():
3543
if field not in cached_plugins[mod_name]:

tests/test_dynamic_metadata.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@
2525
# it turns out to be easier to create EntryPoint objects pointing to real
2626
# functions than to mock them.
2727
def ep_version(
28-
_pyproject_dict: dict[str, Any]
28+
_pyproject_dict: dict[str, Any],
29+
_config_settings: dict[str, list[str] | str] | None = None,
2930
) -> dict[str, str | dict[str, str | None]]:
3031
return {"version": "0.0.2"}
3132

3233

3334
def ep_readme(
34-
_pyproject_dict: dict[str, Any]
35+
_pyproject_dict: dict[str, Any],
36+
_config_settings: dict[str, list[str] | str] | None = None,
3537
) -> dict[str, str | dict[str, str | None]]:
3638
return {
3739
"readme": {
@@ -42,12 +44,16 @@ def ep_readme(
4244

4345

4446
def ep_license(
45-
_pyproject_dict: dict[str, Any]
47+
_pyproject_dict: dict[str, Any],
48+
_config_settings: dict[str, list[str] | str] | None = None,
4649
) -> dict[str, str | dict[str, str | None]]:
4750
return {"license": {"text": "MIT License"}}
4851

4952

50-
def ep_dual(_pyproject_dict: dict[str, Any]) -> dict[str, str | dict[str, str | None]]:
53+
def ep_dual(
54+
_pyproject_dict: dict[str, Any],
55+
_config_settings: dict[str, list[str] | str] | None = None,
56+
) -> dict[str, str | dict[str, str | None]]:
5157
return {
5258
"version": "0.3",
5359
"license": {"text": "BSD License"},

0 commit comments

Comments
 (0)