Fix CLIP installation failures(issue#17201, #17284, #17287, Discussion #17283,#17275) (#17293)

This commit is contained in:
WhizZest 2026-02-28 08:52:10 +08:00 committed by GitHub
parent fd68e0c384
commit 76759a1853
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -422,8 +422,24 @@ def prepare_environment():
)
startup_timer.record("torch GPU test")
# Ensure build dependencies are installed before any package that might need them
def ensure_build_dependencies():
"""Ensure essential build tools are available"""
if not is_installed("wheel"):
run_pip("install wheel", "wheel")
# Check setuptools version compatibility
try:
setuptools_version = run(f'"{python}" -c "import setuptools; print(setuptools.__version__)"', None, None).strip()
if setuptools_version >= "70":
run_pip("install 'setuptools<70'", "setuptools")
except Exception:
# If setuptools check fails, install compatible version
run_pip("install 'setuptools<70'", "setuptools")
# Install build dependencies early
ensure_build_dependencies()
if not is_installed("clip"):
run_pip(f"install {clip_package}", "clip")
run_pip(f"install --no-build-isolation {clip_package}", "clip")
startup_timer.record("install clip")
if not is_installed("open_clip"):