|
0<0# : ^ |
|
''' |
|
@echo off |
|
setlocal enabledelayedexpansion |
|
|
|
|
|
set CURRENT_DIR=!cd! |
|
|
|
|
|
set VENV_ACTIVATED=0 |
|
|
|
|
|
set PYTHON_EXECUTABLE=python |
|
|
|
echo [Allor]: Searching for Python environments. |
|
|
|
|
|
if exist "..\..\venv\" goto venv |
|
|
|
|
|
if exist "..\..\..\python_embeded\" goto portable |
|
|
|
|
|
where /q python && if !ERRORLEVEL! equ 0 goto system |
|
|
|
|
|
goto not_found_environment |
|
|
|
:venv |
|
|
|
cd ..\.. |
|
|
|
|
|
if exist "venv\Scripts\activate" ( |
|
echo [Allor]: Found venv Python environment. |
|
|
|
|
|
call venv\Scripts\activate |
|
|
|
|
|
set VENV_ACTIVATED=1 |
|
|
|
|
|
cd !CURRENT_DIR! |
|
|
|
|
|
if exist "requirements.txt" ( |
|
|
|
pip install -r requirements.txt --no-warn-script-location --quiet |
|
) else ( |
|
echo [Allor]: requirements.txt not found in the current directory. |
|
exit /b |
|
) |
|
) |
|
goto git |
|
|
|
:portable |
|
|
|
cd ..\..\.. |
|
|
|
|
|
if exist "python_embeded\python.exe" ( |
|
echo [Allor]: Found portable Python environment. |
|
|
|
|
|
set VENV_ACTIVATED=2 |
|
|
|
|
|
set PYTHON_EXECUTABLE=!cd!\python_embeded\python.exe |
|
|
|
|
|
call !PYTHON_EXECUTABLE! -s -m pip install -r !CURRENT_DIR!\requirements.txt --no-warn-script-location --quiet |
|
|
|
|
|
cd !CURRENT_DIR! |
|
) |
|
goto git |
|
|
|
:system |
|
set /p user_input=[Allor]: Only the system Python environment is detected. Should this be used for Allor dependencies? (y/N): |
|
|
|
if /i "%user_input%"=="y" goto confirmed |
|
if /i "%user_input%"=="yes" goto confirmed |
|
goto not_found_environment |
|
|
|
:confirmed |
|
|
|
set VENV_ACTIVATED=3 |
|
|
|
|
|
call !PYTHON_EXECUTABLE! -s -m pip install -r !CURRENT_DIR!\requirements.txt --no-warn-script-location --quiet |
|
|
|
|
|
cd !CURRENT_DIR! |
|
goto git |
|
|
|
:not_found_environment |
|
|
|
echo [Allor]: None of the Python environments were found. |
|
exit /b |
|
|
|
:git |
|
where /q git && if !ERRORLEVEL! equ 0 ( |
|
echo [Allor]: Git found. |
|
|
|
|
|
if not exist ".git" ( |
|
echo [Allor]: This directory is not a git repository. Initializing a new repository. |
|
|
|
git init -b main |
|
git remote add origin https://github.com/Nourepide/ComfyUI-Allor |
|
git fetch origin main |
|
git reset --hard origin/main |
|
) else ( |
|
echo [Allor]: This directory is already a git repository. |
|
) |
|
) else ( |
|
echo [Allor]: Git is not installed. Using GitPython instead. |
|
|
|
|
|
call !PYTHON_EXECUTABLE! %~f0 |
|
) |
|
|
|
|
|
if !VENV_ACTIVATED! equ 1 ( |
|
deactivate |
|
) |
|
|
|
echo [Allor]: Install complete successful. |
|
|
|
endlocal |
|
exit /b |
|
''' |
|
import git |
|
from pathlib import Path |
|
|
|
# Check if the current directory is a git repository |
|
if not (Path('.git').exists() or Path('.git').is_dir()): |
|
from git import Repo |
|
|
|
print("[Allor]: This directory is not a git repository. Initializing a new repository.") |
|
|
|
repo = Repo.init(initial_branch='main') |
|
origin = repo.create_remote('origin', 'https://github.com/Nourepide/ComfyUI-Allor') |
|
origin.fetch('main') |
|
repo.git.reset('--hard', 'origin/main') |
|
else: |
|
print('[Allor]: This directory is already a git repository.') |
|
|