-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.bat
82 lines (73 loc) · 2.92 KB
/
run.bat
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
@echo off
title Python Project Launcher
cls
REM Check if the venv directory exists
IF NOT EXIST "venv" (
echo =====================================================
echo Virtual environment folder "venv" not found.
echo Creating a new virtual environment...
echo =====================================================
python -m venv venv
REM Check if the virtual environment was created successfully
IF ERRORLEVEL 1 (
echo [ERROR] Failed to create virtual environment.
pause
exit /b
)
echo [INFO] Virtual environment created successfully.
echo =====================================================
echo Activating virtual environment and installing packages...
echo =====================================================
call venv\Scripts\activate
) ELSE (
echo =====================================================
echo Virtual environment detected. Activating...
echo =====================================================
call venv\Scripts\activate
)
REM Check if the "requirements.txt" file exists
IF NOT EXIST "requirements.txt" (
echo =====================================================
echo "requirements.txt" not found.
echo Creating a blank "requirements.txt"...
echo =====================================================
echo # Add your project dependencies here > requirements.txt
)
REM Check if the "src" directory exists
IF NOT EXIST "src" (
echo =====================================================
echo "src" folder not found. Creating "src" folder and "main.py"...
echo =====================================================
mkdir src
echo # Your main Python script goes here > src\main.py
) ELSE (
REM Check if "main.py" exists inside the "src" folder
IF NOT EXIST "src\main.py" (
echo =====================================================
echo "main.py" not found in "src" folder. Creating "main.py"...
echo =====================================================
echo # Your main Python script goes here > src\main.py
)
)
REM Install required packages
echo =====================================================
echo [INFO] Installing required packages from "requirements.txt"...
echo =====================================================
pip install -r requirements.txt
REM Check if the packages were installed successfully
IF ERRORLEVEL 1 (
echo [ERROR] Failed to install packages.
pause
exit /b
)
REM Run main.py with Python from the virtual environment
echo =====================================================
echo Running "src\main.py"...
echo =====================================================
python src\console_interface.py
REM Pause to allow the user to see the output
echo =====================================================
echo [INFO] Script execution completed.
echo Press any key to exit.
echo =====================================================
pause >nul