import os import sys import subprocess import importlib import importlib.metadata from packaging.requirements import Requirement def check_requirements_installed(requirements_path): with open(requirements_path, 'r', encoding='utf-8') as f: requirements = [Requirement(line.strip()) for line in f if line.strip() and not line.strip().startswith('#')] missing_packages = [] for requirement in requirements: try: version = importlib.metadata.version(requirement.name) if version not in requirement.specifier: missing_packages.append(str(requirement)) except importlib.metadata.PackageNotFoundError: missing_packages.append(str(requirement)) if missing_packages: print(f"Missing or outdated packages: {', '.join(missing_packages)}") print("Installing/Updating missing packages...") subprocess.check_call([sys.executable, '-s', '-m', 'pip', 'install', *missing_packages]) else: print("All packages from requirements.txt are installed and up to date.") requirements_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "requirements.txt") check_requirements_installed(requirements_path) from .install_init import init, get_system_info, install_llama system_info = get_system_info() install_llama(system_info) llama_cpp_agent_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "cpp_agent_req.txt") check_requirements_installed(llama_cpp_agent_path) init() node_list = [ "image.birefnet_LP", "image.rmbg_LP", "image.rembg_LP", "llm.llm_LP", "vlm.autotagger_LP", "vlm.llava_LP", "vlm.ram_LP", ] NODE_CLASS_MAPPINGS = {} NODE_DISPLAY_NAME_MAPPINGS = {} for module_name in node_list: imported_module = importlib.import_module(f".nodes.{module_name}", __name__) NODE_CLASS_MAPPINGS = {**NODE_CLASS_MAPPINGS, **imported_module.NODE_CLASS_MAPPINGS} NODE_DISPLAY_NAME_MAPPINGS = {**NODE_DISPLAY_NAME_MAPPINGS, **imported_module.NODE_DISPLAY_NAME_MAPPINGS} WEB_DIRECTORY = "./web" __all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS", "WEB_DIRECTORY"]