move downloading to python + new extension

This commit is contained in:
salt
2024-03-13 12:42:09 -07:00
parent 4394d5bf12
commit fe1444cc1d
3 changed files with 173 additions and 9 deletions
+33
View File
@@ -1,6 +1,9 @@
import subprocess
import json
import os
from pathlib import Path
import requests
# set cwd to script location
os.chdir(os.path.dirname(os.path.realpath(__file__)))
@@ -51,6 +54,35 @@ def run_comfyui_setup():
run_command(f"{venv_python} initialize_comfy_extensions.py")
def install_dependencies(json_file_path='dependencies.json'):
# Load the dependency JSON
with open(json_file_path, 'r') as file:
dependencies = json.load(file)
for dep in dependencies:
# Extract location and URL
location = dep['location']
url = dep['url']
# Convert the location to a Path object and create parent directories if they don't exist
path = Path(location)
path.parent.mkdir(parents=True, exist_ok=True)
if path.is_file():
print(f"{path} is already installed")
continue
# Download the file
response = requests.get(url)
if response.status_code == 200:
# Write the content to the file in the specified location
with open(path, 'wb') as file:
file.write(response.content)
print(f"Installed {path}")
else:
print(f"Failed to download {url}")
def main():
with open(json_file_path, 'r') as file:
repos = json.load(file)
@@ -60,6 +92,7 @@ def main():
setup_repo(repo_info)
setup_venv_and_install_requirements()
install_dependencies()
run_comfyui_setup()