|
2 | 2 |
|
3 | 3 | # Check if Python3 is installed |
4 | 4 | if ! command -v python3 &> /dev/null; then |
5 | | - echo "Error: Python3 is not installed." |
| 5 | + echo "Error: Python3 is not installed." |
| 6 | + exit 1 |
6 | 7 | fi |
7 | 8 |
|
8 | 9 | # Check if .venv folder exists, create if missing |
9 | 10 | if [ ! -d ".venv" ]; then |
10 | | - echo ".venv folder not found. Creating a new virtual environment..." |
11 | | - python3 -m venv .venv |
| 11 | + echo ".venv folder not found. Creating a new virtual environment..." |
| 12 | + python3 -m venv .venv |
12 | 13 |
|
13 | | - if [ $? -ne 0 ]; then |
14 | | - echo "Failed to create a virtual environment." |
15 | | - fi |
| 14 | + if [ $? -ne 0 ]; then |
| 15 | + echo "Error: Failed to create a virtual environment." |
| 16 | + exit 1 |
| 17 | + fi |
16 | 18 |
|
17 | | - echo ".venv created successfully." |
| 19 | + echo ".venv created successfully." |
18 | 20 | fi |
19 | 21 |
|
20 | 22 | # Activate the virtual environment (cross-platform support) |
21 | 23 | echo "Activating the virtual environment..." |
22 | 24 | if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then |
23 | | - source .venv/Scripts/activate |
| 25 | + source .venv/Scripts/activate |
24 | 26 | else |
25 | | - source .venv/bin/activate |
| 27 | + source .venv/bin/activate |
26 | 28 | fi |
27 | 29 |
|
28 | 30 | # Check if activation was successful |
29 | 31 | if [ "$VIRTUAL_ENV" != "" ]; then |
30 | | - echo "Virtual environment activated: $VIRTUAL_ENV" |
| 32 | + echo "Virtual environment activated: $VIRTUAL_ENV" |
31 | 33 | else |
32 | | - echo "Failed to activate the virtual environment." |
| 34 | + echo "Error: Failed to activate the virtual environment." |
| 35 | + exit 1 |
33 | 36 | fi |
34 | 37 |
|
35 | 38 | # Check if requirements.txt exists and install dependencies |
36 | 39 | if [ ! -f "requirements.txt" ]; then |
37 | | - echo "Error: requirements.txt file not found in the current directory." |
38 | | - deactivate # Clean up before exiting. |
| 40 | + echo "Error: requirements.txt file not found or not available in the current directory." |
| 41 | + echo "Please ensure that requirements.txt exists and is readable." |
| 42 | + deactivate |
| 43 | + exit 1 |
39 | 44 | fi |
40 | 45 |
|
41 | 46 | echo "Installing dependencies from requirements.txt..." |
42 | 47 | pip install -r requirements.txt > pip_install.log 2>&1 |
43 | 48 |
|
44 | 49 | if [ $? -eq 0 ]; then |
45 | | - echo "Dependencies installed successfully." |
| 50 | + echo "Dependencies installed successfully." |
46 | 51 | else |
47 | | - echo "Error occurred while installing dependencies. Check pip_install.log for details." |
| 52 | + echo "Error occurred while installing dependencies. Check pip_install.log for details." |
| 53 | + deactivate |
| 54 | + exit 1 |
48 | 55 | fi |
49 | 56 |
|
50 | 57 | # Deactivate the virtual environment (optional) |
|
0 commit comments