diff --git a/src/fromager/commands/list_overrides.py b/src/fromager/commands/list_overrides.py index 4d3a9ff2..b86a5058 100644 --- a/src/fromager/commands/list_overrides.py +++ b/src/fromager/commands/list_overrides.py @@ -74,12 +74,12 @@ def list_overrides( variant_info[str(v)] = "" continue - is_prebuilt = v_info.pre_built - if v_info.source is not None: - # A variant `source:` block replaces the legacy settings, - # so its resolver decides whether wheels are prebuilt - # (e.g. provider: pypi-prebuilt). - is_prebuilt = v_info.source.resolves_prebuilt_wheel + variant_source = v_info.source if v_info.source is not None else ps.source + is_prebuilt = ( + variant_source.resolves_prebuilt_wheel + if variant_source is not None + else v_info.pre_built + ) variant_info[str(v)] = "pre-built" if is_prebuilt else "yes" diff --git a/tests/test_list_overrides.py b/tests/test_list_overrides.py index 48bd3ffa..8f6c4dee 100644 --- a/tests/test_list_overrides.py +++ b/tests/test_list_overrides.py @@ -361,3 +361,39 @@ def test_list_overrides_details_source_variant( # min_release_age comes from the variant's source resolver assert test_source_pkg["min_release_age"] == "3" assert test_source_pkg["rocm"] == "pre-built" + + +def test_list_overrides_variant_inherits_package_source( + testdata_path: pathlib.Path, cli_runner: CliRunner, tmp_path: pathlib.Path +) -> None: + """An unconfigured variant uses the package's prebuilt source provider.""" + settings_dir = tmp_path / "settings" + settings_dir.mkdir() + (settings_dir / "inherited_source.yaml").write_text( + "source:\n" + " provider: pypi-prebuilt\n" + "variants:\n" + " cpu:\n" + " env:\n" + ' FOO: "1"\n' + ) + settings_file = testdata_path / "context" / "overrides" / "settings.yaml" + + result = cli_runner.invoke( + fromager, + [ + "--settings-file", + str(settings_file), + "--settings-dir", + str(settings_dir), + "list-overrides", + "--details", + "--format", + "json", + ], + ) + + assert result.exit_code == 0, result.output + data = json.loads(_extract_json_from_output(result.stdout)) + package = next(row for row in data if row["package"] == "inherited-source") + assert package["cpu"] == "pre-built"