Skip to content

Add source_resolver dispatch to resolution pipeline #1292

Description

@smoparth

Context

After the source field is activated on models and pbi.source_resolver property is available (Phase 1), the resolution pipeline needs to dispatch to the new system when a package has source: config.

Parent epic: #1254 (Phase 2)

What needs to happen

Add a dispatch check in sources.resolve_source():

def resolve_source(*, ctx, req, sdist_server_url, req_type=None):
    pbi = ctx.package_build_info(req)

    if pbi.source_resolver is not None:
        # New path: source_resolver handles provider creation
        provider = pbi.source_resolver.resolver_provider(ctx, req, req_type)
        max_age_cutoff = resolver._compute_max_age_cutoff(ctx)
        results = resolver.find_all_matching_from_provider(
            provider, req, max_age_cutoff=max_age_cutoff
        )
        url, version = results[0]
        return str(url), version
    else:
        # Legacy path: unchanged
        # ... existing code using get_source_provider() ...

Similarly update sources.get_source_provider() if it has callers beyond resolve_source().

Key points

  • The new resolver_provider() already handles cooldown internally (passes _cooldown to provider constructor) — no need to call resolve_package_cooldown() again on the new path
  • Override hooks (get_resolver_provider) are NOT called on the new path — packages using hooks should use provider: hook-sdist or provider: hook-prebuilt in their config
  • The legacy path remains completely unchanged

Files

  • src/fromager/sources.pyresolve_source(), get_source_provider()

Tests

  • Package with source: {provider: pypi-sdist} → new resolution path used
  • Package without source: → legacy resolution path used (existing behavior)
  • Package with source: {provider: hook-sdist} → hook resolver used
  • Cooldown is applied correctly on new path (not double-applied)

Depends on

  • Phase 1: Activate source field + PBI property

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions