-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathinstall.py
125 lines (105 loc) · 5.16 KB
/
install.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/usr/bin/env python3
import subprocess
import sys
import os
import pkg_resources
import re
def get_installed_version(package_name):
try:
return pkg_resources.get_distribution(package_name).version
except pkg_resources.DistributionNotFound:
return None
def is_compatible_versions(transformers_version, autoawq_version):
# Define compatibility rules
if transformers_version and autoawq_version:
# Check for specific compatible combinations
transformers_major, transformers_minor = map(int, transformers_version.split('.')[:2])
autoawq_major, autoawq_minor = map(int, autoawq_version.split('.')[:2])
# Requires transformers 4.49.0 or above with autoawq 0.2.8
if autoawq_major == 0 and autoawq_minor >= 8 and transformers_major == 4 and transformers_minor >= 49:
return True
return False
def install_dependencies():
print("Installing dependencies for ComfyUI-IF_VideoPrompts...")
# Check existing package versions
transformers_version = get_installed_version("transformers")
autoawq_version = get_installed_version("autoawq")
print(f"Current versions: transformers={transformers_version}, autoawq={autoawq_version}")
# Check if versions are compatible
if transformers_version and autoawq_version:
if is_compatible_versions(transformers_version, autoawq_version):
print("You have compatible versions of transformers and autoawq installed.")
print("Would you like to proceed with the installation anyway? (y/n)")
response = input().strip().lower()
if response != 'y':
print("Installation aborted.")
return
else:
print("⚠️ Incompatible versions detected. Will update packages.")
# First uninstall potentially conflicting packages
print("Uninstalling existing autoawq to prevent conflicts...")
try:
subprocess.check_call([
sys.executable, "-m", "pip", "uninstall", "-y", "autoawq"
])
except:
print("No existing autoawq to uninstall or uninstall failed - continuing...")
# Install the latest transformers separately
print("Installing transformers 4.49.0...")
subprocess.check_call([
sys.executable, "-m", "pip", "install", "transformers==4.49.0", "--upgrade"
])
# Install autoawq with compatible version
print("Installing autoawq 0.2.8 with --no-deps to prevent transformers downgrade...")
subprocess.check_call([
sys.executable, "-m", "pip", "install", "autoawq==0.2.8", "--no-deps"
])
# Install other dependencies from requirements
requirements_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "requirements.txt")
# Parse requirements, skipping transformers and autoawq which we've handled
with open(requirements_path, "r") as f:
requirements = f.read()
# Extract valid requirement lines
requirements_list = []
for line in requirements.split("\n"):
line = line.strip()
if line and not line.startswith("#") and not line.startswith("--"):
# Skip transformers and autoawq lines as we've handled them
if not any(pkg in line for pkg in ["transformers", "autoawq"]):
requirements_list.append(line)
# Install other dependencies
for req in requirements_list:
try:
print(f"Installing {req}...")
subprocess.check_call([
sys.executable, "-m", "pip", "install", req
])
except subprocess.CalledProcessError as e:
print(f"Warning: Failed to install {req}: {e}")
# Install qwen_vl_utils
try:
print("Downloading qwen_vl_utils.py...")
import urllib.request
url = "https://raw.githubusercontent.com/QwenLM/Qwen-VL/main/qwen_vl_utils.py"
urllib.request.urlretrieve(
url,
os.path.join(os.path.dirname(os.path.abspath(__file__)), "qwen_vl_utils.py")
)
print("Successfully downloaded qwen_vl_utils.py")
except Exception as e:
print(f"Warning: Failed to download qwen_vl_utils.py: {e}")
# Verify final versions
print("\nVerifying installed package versions:")
new_transformers_version = get_installed_version("transformers")
new_autoawq_version = get_installed_version("autoawq")
print(f"transformers: {new_transformers_version}")
print(f"autoawq: {new_autoawq_version}")
if is_compatible_versions(new_transformers_version, new_autoawq_version):
print("✅ Installation successful! You have compatible versions installed.")
else:
print("⚠️ Warning: The installed versions may not be fully compatible.")
print("You need transformers 4.49.0 or higher and autoawq 0.2.8.")
print("\nNote: If you're using ComfyUI in a virtual environment, make sure to run this script in the same environment.")
print("You may need to restart ComfyUI for changes to take effect.")
if __name__ == "__main__":
install_dependencies()