Skip to content

Commit d6b84ed

Browse files
authored
download latest ui files when missing (#116)
1 parent 342e302 commit d6b84ed

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

install.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def download_and_extract_ui_files(version: str):
5353
output_dir = os.path.join(os.getcwd(), "nodes", "web")
5454
pathlib.Path(output_dir).mkdir(parents=True, exist_ok=True)
5555
base_url = urllib.parse.urljoin("https://github.com/yondonfu/comfystream/releases/download/", f"v{version}/static.tar.gz")
56+
fallback_url = "https://github.com/yondonfu/comfystream/releases/latest/download/static.tar.gz"
5657

5758
# Create a temporary directory instead of a temporary file
5859
with tempfile.TemporaryDirectory() as temp_dir:
@@ -63,13 +64,25 @@ def download_and_extract_ui_files(version: str):
6364
logger.info(f"Downloading {base_url}")
6465
try:
6566
urllib.request.urlretrieve(base_url, download_path)
66-
67-
# Extract contents
67+
except urllib.error.HTTPError as e:
68+
if e.code == 404:
69+
logger.warning(f"{base_url} not found, trying {fallback_url}")
70+
try:
71+
urllib.request.urlretrieve(fallback_url, download_path)
72+
except Exception as e:
73+
logger.error(f"Error downloading latest ui package: {e}")
74+
raise
75+
else:
76+
logger.error(f"Error downloading package: {e}")
77+
raise
78+
79+
# Extract contents
80+
try:
6881
logger.info(f"Extracting files to {output_dir}")
6982
with tarfile.open(download_path, 'r:gz') as tar:
7083
tar.extractall(path=output_dir)
7184
except Exception as e:
72-
logger.error(f"Error downloading or extracting files: {e}")
85+
logger.error(f"Error extracting files: {e}")
7386
raise
7487

7588
if __name__ == "__main__":
@@ -100,14 +113,14 @@ def download_and_extract_ui_files(version: str):
100113

101114
if workspace is None:
102115
logger.warning("No ComfyUI workspace found. Please specify a valid workspace path to fully install")
103-
104-
logger.info("Downloading and extracting UI files...")
105-
version = get_project_version(os.getcwd())
106-
download_and_extract_ui_files(version)
107116

108117
if workspace is not None:
109118
logger.info("Ensuring __init__.py files exist in ComfyUI directories...")
110119
ensure_init_files(workspace)
111120
logger.info("Installing custom node requirements...")
112121
subprocess.check_call([sys.executable, "-m", "pip", "install", "-e", "."])
122+
123+
logger.info("Downloading and extracting UI files...")
124+
version = get_project_version(os.getcwd())
125+
download_and_extract_ui_files(version)
113126
logger.info("Installation completed successfully.")

0 commit comments

Comments
 (0)