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.py — resolve_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
Context
After the
sourcefield is activated on models andpbi.source_resolverproperty is available (Phase 1), the resolution pipeline needs to dispatch to the new system when a package hassource:config.Parent epic: #1254 (Phase 2)
What needs to happen
Add a dispatch check in
sources.resolve_source():Similarly update
sources.get_source_provider()if it has callers beyondresolve_source().Key points
resolver_provider()already handles cooldown internally (passes_cooldownto provider constructor) — no need to callresolve_package_cooldown()again on the new pathget_resolver_provider) are NOT called on the new path — packages using hooks should useprovider: hook-sdistorprovider: hook-prebuiltin their configFiles
src/fromager/sources.py—resolve_source(),get_source_provider()Tests
source: {provider: pypi-sdist}→ new resolution path usedsource:→ legacy resolution path used (existing behavior)source: {provider: hook-sdist}→ hook resolver usedDepends on
Related