|
5 | 5 | import importlib.util |
6 | 6 | import os |
7 | 7 | import sysconfig |
8 | | -from pathlib import Path |
9 | 8 | from typing import TYPE_CHECKING, Literal |
10 | 9 |
|
11 | 10 | from packaging.tags import sys_tags |
12 | 11 |
|
13 | 12 | from .._compat import tomllib |
14 | 13 | from .._logging import logger |
| 14 | +from ..format import pyproject_format |
15 | 15 | from ..program_search import ( |
16 | 16 | best_program, |
17 | 17 | get_cmake_programs, |
@@ -67,28 +67,6 @@ def _load_scikit_build_settings( |
67 | 67 | return SettingsReader.from_file("pyproject.toml", config_settings).settings |
68 | 68 |
|
69 | 69 |
|
70 | | -@dataclasses.dataclass() |
71 | | -class RootPathResolver: |
72 | | - """Handle ``{root:uri}`` like formatting similar to ``hatchling``.""" |
73 | | - |
74 | | - path: Path = dataclasses.field(default_factory=Path) |
75 | | - |
76 | | - def __post_init__(self) -> None: |
77 | | - self.path = self.path.resolve() |
78 | | - |
79 | | - def __format__(self, fmt: str) -> str: |
80 | | - command, _, rest = fmt.partition(":") |
81 | | - if command == "parent": |
82 | | - parent = RootPathResolver(self.path.parent) |
83 | | - return parent.__format__(rest) |
84 | | - if command == "uri" and rest == "": |
85 | | - return self.path.as_uri() |
86 | | - if command == "" and rest == "": |
87 | | - return str(self) |
88 | | - msg = f"Could not handle format: {fmt}" |
89 | | - raise ValueError(msg) |
90 | | - |
91 | | - |
92 | 70 | @dataclasses.dataclass(frozen=True) |
93 | 71 | class GetRequires: |
94 | 72 | settings: ScikitBuildSettings = dataclasses.field( |
@@ -164,7 +142,11 @@ def dynamic_metadata(self) -> Generator[str, None, None]: |
164 | 142 | return |
165 | 143 |
|
166 | 144 | for build_require in self.settings.build.requires: |
167 | | - yield build_require.format(root=RootPathResolver()) |
| 145 | + yield build_require.format( |
| 146 | + **pyproject_format( |
| 147 | + settings=self.settings, |
| 148 | + ) |
| 149 | + ) |
168 | 150 |
|
169 | 151 | for dynamic_metadata in self.settings.metadata.values(): |
170 | 152 | if "provider" in dynamic_metadata: |
|
0 commit comments