Repository navigation
Expand file tree
/
Copy pathsetup.bat
More file actions
129 lines (105 loc) · 3.44 KB
/
Copy pathsetup.bat
File metadata and controls
129 lines (105 loc) · 3.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
@echo off
setlocal
title Image Scraper Multitool - One-Click Setup
cd /d "%~dp0"
echo ======================================================
echo Image Scraper Multitool - Automated Setup
echo ======================================================
echo.
REM 1. Detect Python executable
set "PYTHON_CMD="
where py >nul 2>&1
if %errorlevel% equ 0 (
py -3 --version >nul 2>&1
if not errorlevel 1 set "PYTHON_CMD=py -3"
)
if not defined PYTHON_CMD (
where python >nul 2>&1
if %errorlevel% equ 0 set "PYTHON_CMD=python"
)
if not defined PYTHON_CMD goto :no_python
REM 2. Check Python version (>= 3.8)
echo [*] Checking Python installation...
%PYTHON_CMD% -c "import sys; sys.exit(0 if sys.version_info >= (3, 8) else 1)" >nul 2>&1
if errorlevel 1 goto :bad_python_version
echo [+] Found compatible Python:
%PYTHON_CMD% --version
REM 3. Check/Setup virtual environment
if not exist ".venv\Scripts\python.exe" goto :make_venv
".venv\Scripts\python.exe" -c "import sys" >nul 2>&1
if errorlevel 1 goto :repair_venv
echo [+] Existing virtual environment found.
goto :install_deps
:repair_venv
echo [*] Existing virtual environment is broken. Recreating .venv...
rmdir /s /q .venv >nul 2>&1
:make_venv
echo [*] Creating virtual environment (.venv)...
%PYTHON_CMD% -m venv .venv
if errorlevel 1 goto :venv_fail
echo [+] Virtual environment created successfully.
:install_deps
REM 4. Upgrade pip and install production dependencies
echo [*] Upgrading pip...
".venv\Scripts\python.exe" -m pip install --upgrade pip --quiet
echo [*] Installing dependencies from requirements.txt...
".venv\Scripts\python.exe" -m pip install -r requirements.txt
if errorlevel 1 goto :pip_fail
echo [+] Dependencies installed successfully.
REM 5. Optional developer tools
echo.
set "INSTALL_DEV="
set /p INSTALL_DEV="Would you like to install developer/test tools (pytest, ruff, mypy)? [y/N]: "
if /i "%INSTALL_DEV%"=="y" (
echo [*] Installing dev dependencies from requirements-dev.txt...
".venv\Scripts\python.exe" -m pip install -r requirements-dev.txt
if not errorlevel 1 (
echo [+] Developer dependencies installed.
) else (
echo [!] Warning: Dev dependencies could not be fully installed.
)
)
echo.
echo ======================================================
echo Setup Completed!
echo ======================================================
echo You can run the application anytime by double-clicking run.bat
echo.
REM 6. Launch prompt
set "LAUNCH_NOW="
set /p LAUNCH_NOW="Would you like to launch the GUI now? [Y/n]: "
if /i "%LAUNCH_NOW%"=="n" goto :finish
echo [*] Launching Image Scraper Multitool...
if exist ".venv\Scripts\pythonw.exe" (
start "" ".venv\Scripts\pythonw.exe" image_scraper_gui.py
) else (
start "" ".venv\Scripts\python.exe" image_scraper_gui.py
)
:finish
exit /b 0
:no_python
echo [ERROR] Python was not found on your system.
echo Please install Python 3.8 or higher from https://www.python.org/downloads/
echo Make sure to check "Add Python to PATH" during installation.
echo.
pause
exit /b 1
:bad_python_version
echo [ERROR] Python 3.8 or higher is required.
echo Detected version:
%PYTHON_CMD% --version
echo Please install a compatible Python version.
echo.
pause
exit /b 1
:venv_fail
echo [ERROR] Failed to create virtual environment.
echo Please ensure python-venv or ensurepip is available.
echo.
pause
exit /b 1
:pip_fail
echo [ERROR] Failed to install dependencies from requirements.txt.
echo.
pause
exit /b 1