Python
add autoinstaller
Chris Maloneb295c27bb6ec
diff --git a/install.bat b/install.batnew file mode 100644index 0000000..675ddaa--- /dev/null+++ b/install.bat@@ -0,0 +1,55 @@+@echo off+setlocal enabledelayedexpansion+title WanGP Installer++:MENU+cls+echo ======================================================+echo WAN2GP INSTALLER MENU+echo ======================================================+echo 1. Automatic Install (Standard: venv)+echo 2. Use 'uv' (Recommended - Handles Python 3.11 better)+echo 3. Use 'Conda'+echo 4. No Environment (Not Recommended)+echo 5. Exit+echo ------------------------------------------------------+set /p choice="Select an option (1-4): "++if "%choice%"=="1" (+ set "ENV_TYPE=venv"+ goto START_INSTALL+)++if "%choice%"=="2" (+ set "ENV_TYPE=uv"+ where uv >nul 2>nul+ if !errorlevel! neq 0 (+ echo [!] 'uv' not found.+ echo 1. Install 'uv' via PowerShell (Recommended)+ echo 2. Install 'uv' via Pip+ set /p uv_choice="Select method: "+ if "!uv_choice!"=="1" (+ powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"+ set "PATH=!USERPROFILE!\.local\bin;!APPDATA!\uv\bin;!PATH!"+ )+ if "!uv_choice!"=="2" python -m pip install uv+ )+ goto START_INSTALL+)++if "%choice%"=="3" (+ set "ENV_TYPE=conda"+ goto START_INSTALL+)++if "%choice%"=="4" (+ set "ENV_TYPE=none"+ goto START_INSTALL+)++if "%choice%"=="5" exit+goto MENU++:START_INSTALL+python setup.py install --env !ENV_TYPE!+pause\ No newline at end of filediff --git a/run.bat b/run.batnew file mode 100644index 0000000..55bf389--- /dev/null+++ b/run.bat@@ -0,0 +1,3 @@+@echo off+python setup.py run+pause\ No newline at end of filediff --git a/setup.py b/setup.pynew file mode 100644index 0000000..c6519ac--- /dev/null+++ b/setup.py@@ -0,0 +1,136 @@+import os+import sys+import json+import subprocess+import argparse+import shutil++CONFIG_PATH = "setup_config.json"+ENV_MAP = {+ "uv": {"dir": "env_uv", "create": "uv venv --python {ver} {dir}", "run": r"{dir}\Scripts\python.exe", "install": r"{dir}\Scripts\python.exe -m uv pip install"},+ "venv": {"dir": "env_venv", "create": "{sys_py} -m venv {dir}", "run": r"{dir}\Scripts\python.exe", "install": r"{dir}\Scripts\python.exe -m pip install"},+ "conda": {"dir": "wangp", "create": "conda create -y -n {dir} python={ver}", "run": "conda run -n {dir} python", "install": "conda run -n {dir} pip install"},+ "none": {"dir": "", "create": "", "run": "python", "install": "pip install"}+}++def load_config():+ with open(CONFIG_PATH, 'r') as f: return json.load(f)++def get_gpu_name():+ try: return subprocess.check_output(["nvidia-smi", "--query-gpu=name", "--format=csv,noheader"], encoding='utf-8').strip()+ except: return None++def get_profile_key(gpu):+ if not gpu: return "RTX_40"+ g = gpu.upper()+ if "50" in g: return "RTX_50"+ if "40" in g: return "RTX_40"+ if "30" in g: return "RTX_30"+ if "20" in g or "QUADRO" in g: return "RTX_20"+ return "GTX_10"++def run_cmd(cmd):+ if not cmd: return+ print(f"\n>>> Running: {cmd}")+ subprocess.run(cmd, shell=True, check=True)++def list_installs():+ found = []+ for k, v in ENV_MAP.items():+ if k in ["conda", "none"]: continue+ if os.path.exists(os.path.join(v["dir"], "Scripts", "python.exe")): found.append(k)+ try:+ res = subprocess.check_output("conda env list", shell=True, encoding='utf-8')+ if "wangp " in res: found.append("conda")+ except: pass+ return found++def get_active_env():+ installs = list_installs()+ return installs[0] if installs else "none"++def install_from_keys(env_type, py_k, torch_k, triton_k, sage_k, flash_k, kernel_list, config):+ env_dir = ENV_MAP[env_type]["dir"]+ target_py_ver = config['components']['python'][py_k]['ver']++ print(f"\n[1/3] Preparing Environment: {env_type} (Python {target_py_ver})...")+ if env_type != "none":+ if env_type == "conda": run_cmd(f"conda env remove -y -n {env_dir}")+ elif os.path.exists(env_dir): shutil.rmtree(env_dir)+ run_cmd(ENV_MAP[env_type]["create"].format(ver=target_py_ver, dir=env_dir, sys_py=sys.executable))++ pip = ENV_MAP[env_type]["install"].format(dir=env_dir)++ print(f"\n[2/3] Installing Torch: {config['components']['torch'][torch_k]['label']}...")+ run_cmd(f"{pip} {config['components']['torch'][torch_k]['cmd']}")++ print(f"\n[3/3] Installing Requirements & Extras...")+ run_cmd(f"{pip} -r requirements.txt")+ if triton_k: run_cmd(f"{pip} {config['components']['triton'][triton_k]['cmd']}")+ if sage_k: run_cmd(f"{pip} {config['components']['sage'][sage_k]['cmd']}")+ if flash_k: run_cmd(f"{pip} {config['components']['flash'][flash_k]['cmd']}")+ for k in kernel_list: run_cmd(f"{pip} {config['components']['kernels'][k]['cmd']}")++def menu(title, options, recommended_key=None):+ print(f"\n--- {title} ---")+ keys = list(options.keys())+ for i, k in enumerate(keys):+ rec = " [RECOMMENDED]" if k == recommended_key else ""+ print(f"{i+1}. {options[k]['label']}{rec}")+ choice = input(f"Select option (Enter for Recommended): ")+ if choice == "" and recommended_key: return recommended_key+ try: return keys[int(choice)-1]+ except: return recommended_key++def do_migrate(config):+ print("\n" + "="*60)+ print(" WAN2GP AUTOMATED PLATFORM MIGRATION (TO 3.11)")+ print("="*60)+ env = get_active_env()+ if env == "none":+ print("No environment found. Please run install.bat first.")+ return++ confirm = input(f"This will nuke your {env} and rebuild with Python 3.11 / Torch 2.10.\nProceed? (y/n): ")+ if confirm.lower() != 'y': return++ target = config['gpu_profiles']['RTX_50']+ install_from_keys(env, target['python'], target['torch'], target['triton'], target['sage'], target['flash'], target['kernels'], config)++def do_upgrade(config):+ print("\n" + "="*60)+ print(" WAN2GP MANUAL COMPONENT UPGRADE")+ print("="*60)+ env = get_active_env()+ gpu = get_gpu_name()+ rec = config['gpu_profiles'][get_profile_key(gpu)]++ py_k = menu("Python Version", config['components']['python'], rec['python'])+ torch_k = menu("Torch Version", config['components']['torch'], rec['torch'])+ triton_k = menu("Triton", config['components']['triton'], rec['triton'])+ sage_k = menu("Sage Attention", config['components']['sage'], rec['sage'])+ flash_k = menu("Flash Attention", config['components']['flash'], rec['flash'])++ install_from_keys(env, py_k, torch_k, triton_k, sage_k, flash_k, rec['kernels'], config)++if __name__ == "__main__":+ parser = argparse.ArgumentParser()+ parser.add_argument("mode", choices=["install", "run", "update", "migrate", "upgrade"])+ parser.add_argument("--env", default="venv")+ args = parser.parse_args()+ cfg = load_config()++ if args.mode == "install":+ p = cfg['gpu_profiles'][get_profile_key(get_gpu_name())]+ install_from_keys(args.env, p['python'], p['torch'], p['triton'], p['sage'], p['flash'], p['kernels'], cfg)+ elif args.mode == "run":+ env = get_active_env()+ run_cmd(f"{ENV_MAP[env]['run'].format(dir=ENV_MAP[env]['dir'])} wgp.py")+ elif args.mode == "update":+ run_cmd("git pull")+ env = get_active_env()+ run_cmd(f"{ENV_MAP[env]['run'].format(dir=ENV_MAP[env]['dir'])} -m pip install -r requirements.txt")+ elif args.mode == "migrate":+ do_migrate(cfg)+ elif args.mode == "upgrade":+ do_upgrade(cfg)\ No newline at end of filediff --git a/setup_config.json b/setup_config.jsonnew file mode 100644index 0000000..8cb30c1--- /dev/null+++ b/setup_config.json@@ -0,0 +1,39 @@+{+ "components": {+ "python": {+ "3.10": { "ver": "3.10.9", "label": "Python 3.10.9 (Legacy)" },+ "3.11": { "ver": "3.11.14", "label": "Python 3.11.14 (Recommended)" }+ },+ "torch": {+ "cu126": { "label": "Torch 2.6.0 + CUDA 12.6", "cmd": "torch==2.6.0+cu126 torchvision==0.21.0+cu126 torchaudio==2.6.0+cu126 --index-url https://download.pytorch.org/whl/cu126" },+ "cu128": { "label": "Torch 2.7.1 + CUDA 12.8", "cmd": "torch==2.7.1 torchvision==0.22.1 torchaudio==2.7.1 --index-url https://download.pytorch.org/whl/cu128" },+ "cu130": { "label": "Torch 2.10.0 + CUDA 13.0", "cmd": "torch==2.10.0 torchvision torchaudio --index-url https://download.pytorch.org/whl/cu130" }+ },+ "triton": {+ "v33": { "label": "Triton-Windows < 3.3", "cmd": "-U \"triton-windows<3.3\"" },+ "v34": { "label": "Triton-Windows < 3.4", "cmd": "-U \"triton-windows<3.4\"" },+ "latest": { "label": "Triton-Windows Latest", "cmd": "-U triton-windows" }+ },+ "sage": {+ "v1": { "label": "Sage Attention 1.0.6", "cmd": "sageattention==1.0.6" },+ "v211": { "label": "Sage Attention 2.1.1 (CUDA 12.6/Py3.10)", "cmd": "https://github.com/woct0rdho/SageAttention/releases/download/v2.1.1-windows/sageattention-2.1.1+cu126torch2.6.0-cp310-cp310-win_amd64.whl" },+ "v220": { "label": "Sage Attention 2.2.0 (CUDA 12.8/Py3.10)", "cmd": "https://github.com/woct0rdho/SageAttention/releases/download/v2.2.0-windows/sageattention-2.2.0+cu128torch2.7.1-cp310-cp310-win_amd64.whl" },+ "v220_cu13": { "label": "Sage Attention 2.2.0 (CUDA 13.0/Py3.11)", "cmd": "https://github.com/woct0rdho/SageAttention/releases/download/v2.2.0-windows.post4/sageattention-2.2.0+cu130torch2.9.0andhigher.post4-cp39-abi3-win_amd64.whl" }+ },+ "flash": {+ "v271": { "label": "Flash Attention 2.7.4 (CUDA 12.8/Py3.10)", "cmd": "https://github.com/Redtash1/Flash_Attention_2_Windows/releases/download/v2.7.0-v2.7.4/flash_attn-2.7.4.post1+cu128torch2.7.0cxx11abiFALSE-cp310-cp310-win_amd64.whl" },+ "v210": { "label": "Flash Attention 2.8.3 (CUDA 13.0/Py3.11)", "cmd": "https://github.com/deepbeepmeep/kernels/releases/download/Flash2/flash_attn-2.8.3-cp311-cp311-win_amd64.whl" }+ },+ "kernels": {+ "nunchaku": { "label": "Nunchaku INT4/FP4 (Py3.10)", "cmd": "https://github.com/deepbeepmeep/kernels/releases/download/v1.2.0_Nunchaku/nunchaku-1.2.0+torch2.7-cp310-cp310-win_amd64.whl" },+ "light2xv": { "label": "Light2xv NVFP4 (Py3.11 - RTX 50xx Only)", "cmd": "https://github.com/deepbeepmeep/kernels/releases/download/Light2xv/lightx2v_kernel-0.0.2+torch2.10.0-cp311-abi3-win_amd64.whl" }+ }+ },+ "gpu_profiles": {+ "GTX_10": { "python": "3.10", "torch": "cu126", "triton": null, "sage": null, "flash": null, "kernels": [] },+ "RTX_20": { "python": "3.10", "torch": "cu126", "triton": "v33", "sage": "v1", "flash": null, "kernels": [] },+ "RTX_30": { "python": "3.10", "torch": "cu126", "triton": "v33", "sage": "v211", "flash": null, "kernels": [] },+ "RTX_40": { "python": "3.10", "torch": "cu128", "triton": "v34", "sage": "v220", "flash": "v271", "kernels": ["nunchaku"] },+ "RTX_50": { "python": "3.11", "torch": "cu130", "triton": "latest", "sage": "v220_cu13", "flash": "v210", "kernels": ["light2xv"] }+ }+}\ No newline at end of filediff --git a/update.bat b/update.batnew file mode 100644index 0000000..0131441--- /dev/null+++ b/update.bat@@ -0,0 +1,37 @@+@echo off+setlocal enabledelayedexpansion+title WanGP Update & Upgrade++:MENU+cls+echo ======================================================+echo WAN2GP UPDATE / UPGRADE+echo ======================================================+echo 1. Simple Update (git pull + pip requirements)+echo 2. Upgrade (Upgrade Torch, Triton, Sage Attention, etc.)+echo 3. Platform Migration (Upgrade to Py 3.11/Torch 2.10)+echo 4. Exit+echo ------------------------------------------------------+set /p choice="Select an option (1-4): "++if "%choice%"=="1" (+ python setup.py update+ pause+ goto MENU+)++if "%choice%"=="2" (+ python setup.py upgrade+ pause+ goto MENU+)++if "%choice%"=="3" (+ echo [!] This will rebuild your environment with Python 3.11/Torch 2.10+ python setup.py migrate+ pause+ goto MENU+)++if "%choice%"=="4" exit+goto MENU\ No newline at end of file