-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.bat
59 lines (52 loc) · 1.61 KB
/
install.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
@echo off
setlocal
:: Step 1: Check if Python is installed
python --version >nul 2>&1
if %errorlevel% neq 0 (
echo Python is not installed. Please install Python 3.x.
exit /b 1
)
:: Step 2: Create a virtual environment
if not exist "venv" (
echo Creating virtual environment...
python -m venv venv
if %errorlevel% neq 0 (
echo Failed to create virtual environment.
exit /b 1
)
)
:: Step 3: Activate the virtual environment
call venv\Scripts\activate
if %errorlevel% neq 0 (
echo Failed to activate virtual environment.
exit /b 1
)
:: Step 4: Install or update dependencies from requirements.txt
pip install -r requirements.txt -U
if errorlevel 1 (
echo Error installing or updating dependencies. Check requirements.txt for errors.
)
:: Step 5: Check for the existence of .env file and set environment variables
if not exist ".env" (
echo .env file not found. Creating a sample .env file.
(
echo # OpenAI API Key
echo OPENAI_API_KEY = "your-openai-api-key"
echo.
echo # Serper.dev API Key
echo SERPER_API_KEY = "your-serper-api-key"
) > .env
echo Please edit the .env file and add your API keys.
) else (
:: Loop through each line in the .env file
for /f "tokens=1,* delims==" %%x in (.env) do (
:: Skip comments and blank lines
if not "%%x"=="" if not "%%x"=="#" (
:: Set environment variable using the key-value pair
set %%x=%%y
)
)
)
:: Deactivate the virtual environment
deactivate
echo Setup complete. To activate the virtual environment, run: venv\Scripts\activate