@@ -411,31 +411,78 @@ def main() -> None:
411411 # 4. Build wheels for sdist-only downloads so the runtime never
412412 # compiles. Failures keep the sdist (the runtime image has a
413413 # toolchain) and are recorded in the report.
414+ #
415+ # A built wheel can declare dependencies that the sdist's static
416+ # metadata omitted (e.g. GPTQModel publishes an sdist whose
417+ # PKG-INFO lists no runtime requirements, while the wheel its
418+ # setup.py builds does). The locks above only saw the sdist
419+ # metadata, so fetch each built wheel's dependencies explicitly
420+ # and repeat until no new sdists arrive.
414421 # ------------------------------------------------------------------
415- for sdist in sorted (dest .iterdir ()):
416- if sdist .suffix not in (".gz" , ".zip" , ".bz2" ) and not sdist .name .endswith (
417- ".tar.gz"
418- ):
419- continue
420- proc = run (
421- [
422- sys .executable ,
423- "-m" ,
424- "pip" ,
425- "wheel" ,
426- "--quiet" ,
427- "--no-deps" ,
428- "--wheel-dir" ,
429- str (dest ),
430- str (sdist ),
431- ],
432- env = package_build_env ,
433- )
434- if proc .returncode == 0 :
435- sdist .unlink ()
436- else :
437- print (f"WARN: keeping sdist { sdist .name } " , flush = True )
438- sdist_left .append (sdist .name )
422+ failed_sdists : Set [str ] = set ()
423+ while True :
424+ built_wheels : List [Path ] = []
425+ for sdist in sorted (dest .iterdir ()):
426+ if sdist .suffix not in (".gz" , ".zip" , ".bz2" ) and not sdist .name .endswith (
427+ ".tar.gz"
428+ ):
429+ continue
430+ if sdist .name in failed_sdists :
431+ continue
432+ wheels_before = {p .name for p in dest .glob ("*.whl" )}
433+ proc = run (
434+ [
435+ sys .executable ,
436+ "-m" ,
437+ "pip" ,
438+ "wheel" ,
439+ "--quiet" ,
440+ "--no-deps" ,
441+ "--wheel-dir" ,
442+ str (dest ),
443+ str (sdist ),
444+ ],
445+ env = package_build_env ,
446+ )
447+ if proc .returncode == 0 :
448+ sdist .unlink ()
449+ built_wheels .extend (
450+ p for p in dest .glob ("*.whl" ) if p .name not in wheels_before
451+ )
452+ else :
453+ print (f"WARN: keeping sdist { sdist .name } " , flush = True )
454+ failed_sdists .add (sdist .name )
455+ if not built_wheels :
456+ break
457+ for wheel in built_wheels :
458+ proc = pip_download (
459+ [str (wheel )],
460+ dest ,
461+ index_url = args .index_url ,
462+ extra_index_urls = [args .pytorch_index ],
463+ constraints = master_constraints ,
464+ env = package_build_env ,
465+ )
466+ if proc .returncode != 0 :
467+ print (
468+ f"WARN: retrying dependencies of '{ wheel .name } ' "
469+ "without constraints" ,
470+ flush = True ,
471+ )
472+ proc = pip_download (
473+ [str (wheel )],
474+ dest ,
475+ index_url = args .index_url ,
476+ extra_index_urls = [args .pytorch_index ],
477+ env = package_build_env ,
478+ )
479+ if proc .returncode != 0 :
480+ sys .exit (
481+ f"FATAL: failed to fetch dependencies of built "
482+ f"wheel '{ wheel .name } '"
483+ )
484+ unconstrained_fallbacks .append (wheel .name )
485+ sdist_left .extend (sorted (failed_sdists ))
439486
440487 # ------------------------------------------------------------------
441488 # Report.
0 commit comments