-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildEnv.bat
65 lines (53 loc) · 2.15 KB
/
buildEnv.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
@echo off
REM This BAT file creates, activates a Python virtual environment, installs dependencies, and checks for executable scripts
REM Set the environment name (you can change 'venv' to any name you prefer)
set ENV_NAME=venv
REM Print starting message
echo ==============================================
echo Starting the virtual environment setup process
echo ==============================================
REM Check if Python is installed
python --version >nul 2>&1
IF ERRORLEVEL 1 (
echo [ERROR] Python is not installed or not in your PATH.
pause
exit /b
)
REM Print Python check success
echo [INFO] Python is installed and detected.
REM Create the virtual environment
echo [INFO] Creating the virtual environment: %ENV_NAME%...
python -m venv %ENV_NAME%
REM Check if the environment was created successfully
IF EXIST "%ENV_NAME%\Scripts\activate.bat" (
echo [SUCCESS] Virtual environment created successfully.
echo [INFO] Activating the virtual environment...
call %ENV_NAME%\Scripts\activate.bat
REM Install dependencies from requirements.txt if it exists
IF EXIST requirements.txt (
echo [INFO] requirements.txt found. Installing dependencies...
pip install -r requirements.txt
IF %ERRORLEVEL% EQU 0 (
echo [SUCCESS] Dependencies installed successfully.
) ELSE (
echo [ERROR] Failed to install dependencies. Please check requirements.txt.
)
) ELSE (
echo [WARNING] requirements.txt not found. Skipping dependency installation.
)
REM Make a script executable (Windows equivalent)
IF EXIST runScript.bat (
echo [INFO] runScript.bat found. No need for chmod on Windows.
echo [INFO] The script is ready to be executed as needed.
) ELSE (
echo [WARNING] runScript.bat not found. Skipping the executable step.
)
) ELSE (
echo [ERROR] Failed to create the virtual environment. Please check for errors.
)
REM Print completion message
echo ==============================================
echo Process completed. Review any messages above.
echo ==============================================
REM Pause to keep the command prompt open
pause