import os import subprocess def colored(text, color): """ Функция для вывода цветного текста в консоль. """ colors = { 'red': '\033[91m', 'green': '\033[92m', 'yellow': '\033[93m', 'blue': '\033[94m', 'magenta': '\033[95m', 'cyan': '\033[96m', 'white': '\033[97m', } return colors.get(color, '') + text + '\033[0m' # Путь к папке ComfyUI (относительный путь) comfyui_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "ComfyUI")) # Путь к папке python_embeded (относительный путь) python_embeded_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "python_embeded")) # Создание полного пути к папке Scripts python_scripts_path = os.path.join(python_embeded_path, "Scripts") # Путь к папке с git (относительный путь) git_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "git")) git_bin_path = os.path.join(git_path, "bin") git_libexec_path = os.path.join(git_path, "libexec") # Обновление переменной PATH os.environ['PATH'] = f"{git_path};{git_bin_path};{git_libexec_path};{python_embeded_path};{python_scripts_path}" # os.environ['PATH'] = f"{git_path};{git_bin_path};{git_libexec_path};{os.environ['PATH']}" # Словарь с вариантами установки и их репозиториями install_options = { "Базовые узлы": [ "https://github.com/ltdrdata/ComfyUI-Manager.git", "https://github.com/crystian/ComfyUI-Crystools.git", "https://github.com/hayden-fr/ComfyUI-Model-Manager.git", # Добавьте сюда ссылки на другие репозитории ], "Расширенные узлы": [ "https://github.com/WASasquatch/was-node-suite-comfyui.git", "https://github.com/11cafe/comfyui-workspace-manager.git", "https://github.com/talesofai/comfyui-browser.git", "https://github.com/jags111/efficiency-nodes-comfyui.git", "https://github.com/rgthree/rgthree-comfy.git", "https://github.com/Kosinkadink/ComfyUI-Advanced-ControlNet.git", "https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite.git", "https://github.com/Fannovel16/comfyui_controlnet_aux.git", "https://github.com/Extraltodeus/ComfyUI-AutomaticCFG.git", "https://github.com/yolain/ComfyUI-Easy-Use.git", "https://github.com/ltdrdata/ComfyUI-Impact-Pack.git", "https://github.com/ltdrdata/ComfyUI-Inspire-Pack.git", "https://github.com/ZHO-ZHO-ZHO/ComfyUI-InstantID.git", "https://github.com/MinusZoneAI/ComfyUI-Kolors-MZ.git", "https://github.com/kijai/ComfyUI-KwaiKolorsWrapper.git", "https://github.com/kijai/ComfyUI-SUPIR.git", "https://github.com/kijai/ComfyUI-LivePortraitKJ.git", "https://github.com/kijai/ComfyUI-KJNodes.git", "https://github.com/ssitu/ComfyUI_UltimateSDUpscale.git", "https://github.com/pythongosssss/ComfyUI-WD14-Tagger.git", "https://github.com/GavChap/ComfyUI-SD3LatentSelectRes.git", "https://github.com/kadirnar/ComfyUI-YOLO.git", "https://github.com/AlekPet/ComfyUI_Custom_Nodes_AlekPet.git", "https://github.com/cubiq/ComfyUI_InstantID.git", "https://github.com/cubiq/ComfyUI_IPAdapter_plus.git", "https://github.com/cubiq/ComfyUI_essentials.git", "https://github.com/city96/ComfyUI_ExtraModels.git", "https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes.git", "https://github.com/pythongosssss/ComfyUI-Custom-Scripts.git", "https://github.com/shiimizu/ComfyUI-TiledDiffusion.git", "https://github.com/shiimizu/ComfyUI-PhotoMaker-Plus.git", "https://github.com/Gourieff/comfyui-reactor-node.git", "https://github.com/giriss/comfy-image-saver.git", "https://github.com/chrisgoringe/cg-use-everywhere.git", "https://github.com/liusida/ComfyUI-AutoCropFaces.git", "https://github.com/lquesada/ComfyUI-Inpaint-CropAndStitch.git", "https://github.com/nullquant/ComfyUI-BrushNet.git", "https://github.com/sipherxyz/comfyui-art-venture.git", "https://github.com/EllangoK/ComfyUI-post-processing-nodes.git", "https://github.com/MaraScott/ComfyUI_MaraScott_Nodes.git", "https://github.com/mav-rik/facerestore_cf.git", # Добавьте сюда ссылки на другие репозитории ], "Все узлы": [ "https://github.com/nosiu/comfyui-instantId-faceswap.git", "https://github.com/shadowcz007/comfyui-mixlab-nodes.git", "https://github.com/SeargeDP/SeargeSDXL.git", "https://github.com/Acly/comfyui-inpaint-nodes.git", "https://github.com/chflame163/ComfyUI_LayerStyle.git", "https://github.com/cdb-boop/ComfyUI-Bringing-Old-Photos-Back-to-Life.git", "https://github.com/coolzilj/ComfyUI-Photopea.git", "https://github.com/twri/sdxl_prompt_styler.git", "https://github.com/ArtVentureX/comfyui-animatediff.git", "https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git", "https://github.com/kijai/ComfyUI-Marigold.git", "https://github.com/ZHO-ZHO-ZHO/ComfyUI-PhotoMaker-ZHO.git", "https://github.com/ZHO-ZHO-ZHO/comfyui-portrait-master-zh-cn.git", "https://github.com/florestefano1975/comfyui-portrait-master.git", "https://github.com/AIrjen/OneButtonPrompt.git", "https://github.com/banodoco/steerable-motion.git", "https://github.com/huchenlei/ComfyUI-layerdiffuse.git", "https://github.com/AIGODLIKE/AIGODLIKE-COMFYUI-TRANSLATION.git", "https://github.com/mcmonkeyprojects/sd-dynamic-thresholding.git", "https://github.com/ZHO-ZHO-ZHO/ComfyUI-PixArt-alpha-Diffusers.git", "https://github.com/cdb-boop/comfyui-image-round.git", # Добавьте сюда ссылки на другие репозитории ], } # Проверка наличия папки с custom_nodes custom_nodes_path = os.path.join(comfyui_path, "custom_nodes") if not os.path.exists(custom_nodes_path): os.makedirs(custom_nodes_path) # Меню выбора варианта установки while True: print("Выберите вариант установки:") for i, option in enumerate(install_options.keys()): print(f"{i+1}. {option}") choice = input("Введите номер варианта: ") # Проверка ввода try: choice = int(choice) if 1 <= choice <= len(install_options): break else: print("Неверный номер варианта. Пожалуйста, введите число от 1 до", len(install_options)) except ValueError: print("Неверный ввод. Пожалуйста, введите число.") # Получение списка репозиториев для выбранного варианта selected_repos = [] if choice == 2: # Выбран вариант 2 selected_repos.extend(install_options["Базовые узлы"]) selected_repos.extend(install_options["Расширенные узлы"]) elif choice == 3: # Выбран вариант 3 selected_repos.extend(install_options["Базовые узлы"]) selected_repos.extend(install_options["Расширенные узлы"]) selected_repos.extend(install_options["Все узлы"]) else: selected_repos.extend(install_options[list(install_options.keys())[choice - 1]]) # Скачивание custom_nodes for repo_url in selected_repos: repo_name = repo_url.split("/")[-1].split(".")[0] repo_path = os.path.join(custom_nodes_path, repo_name) # Проверка, была ли уже скачана репозитория if os.path.exists(repo_path): print(f"Репозитория {repo_name} уже скачана.") continue # Скачивание репозитории print(colored(f"Скачивание {repo_name}...", 'cyan')) # print(f"Скачивание {repo_name}...") try: subprocess.run([os.path.join(git_bin_path, "git"), "clone", repo_url, repo_path], check=True) except subprocess.CalledProcessError as e: print(f"Ошибка при скачивании {repo_name}: {e}") continue # Проверка наличия requirements.txt requirements_path = os.path.join(repo_path, "requirements.txt") if os.path.exists(requirements_path): print(colored(f"Установка зависимостей для {repo_name}...", 'blue')) # print(f"Установка зависимостей для {repo_name}...") try: subprocess.run([os.path.join(python_embeded_path, "python"), "-m", "pip", "install", "-r", requirements_path], check=True) except subprocess.CalledProcessError as e: print(f"Ошибка при установке зависимостей: {e}") print(colored("Скачивание custom_nodes завершено...", 'green'))