Skip to content

Commit 948af39

Browse files
authored
Merge pull request #834 from iangelak/350-extra_data_plugin-default
fix: Add default for 'extra_data_plugin' override
2 parents b169f2a + f3845a9 commit 948af39

File tree

1 file changed

+17
-20
lines changed

1 file changed

+17
-20
lines changed

src/fromager/wheels.py

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@ def default_add_extra_metadata_to_wheels(
142142
sdist_root_dir: pathlib.Path,
143143
dist_info_dir: pathlib.Path,
144144
) -> dict[str, typing.Any]:
145-
raise NotImplementedError
145+
"""Default implementation returns empty dict - no extra metadata."""
146+
return {}
146147

147148

148149
@metrics.timeit(description="add extra metadata to wheels")
@@ -161,11 +162,6 @@ def add_extra_metadata_to_wheels(
161162
)
162163
dist_filename = f"{dist_name}-{dist_version}"
163164

164-
extra_data_plugin = overrides.find_override_method(
165-
req.name, "add_extra_metadata_to_wheels"
166-
)
167-
data_to_add = {}
168-
169165
with tempfile.TemporaryDirectory() as dir_name:
170166
wheel_root_dir = pathlib.Path(dir_name) / dist_filename
171167
wheel_root_dir.mkdir()
@@ -187,21 +183,22 @@ def add_extra_metadata_to_wheels(
187183
if not dist_info_dir.is_dir():
188184
raise ValueError(f"{wheel_file} does not contain {dist_info_dir.name}")
189185

190-
if extra_data_plugin:
191-
data_to_add = overrides.invoke(
192-
extra_data_plugin,
193-
ctx=ctx,
194-
req=req,
195-
version=version,
196-
extra_environ=extra_environ,
197-
sdist_root_dir=sdist_root_dir,
198-
dist_info_dir=dist_info_dir,
186+
data_to_add = overrides.find_and_invoke(
187+
req.name,
188+
"add_extra_metadata_to_wheels",
189+
default_add_extra_metadata_to_wheels,
190+
ctx=ctx,
191+
req=req,
192+
version=version,
193+
extra_environ=extra_environ,
194+
sdist_root_dir=sdist_root_dir,
195+
dist_info_dir=dist_info_dir,
196+
)
197+
if not isinstance(data_to_add, dict):
198+
logger.warning(
199+
"unexpected return type from plugin add_extra_metadata_to_wheels. Expected dictionary. Will ignore"
199200
)
200-
if not isinstance(data_to_add, dict):
201-
logger.warning(
202-
"unexpected return type from plugin add_extra_metadata_to_wheels. Expected dictionary. Will ignore"
203-
)
204-
data_to_add = {}
201+
data_to_add = {}
205202

206203
if pbi.has_config:
207204
settings = pbi.serialize(mode="json", exclude_defaults=False)

0 commit comments

Comments
 (0)