-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathinstall.sh
More file actions
59 lines (53 loc) · 1.51 KB
/
Copy pathinstall.sh
File metadata and controls
59 lines (53 loc) · 1.51 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
#!/bin/bash
# Function to check if a command exists
command_exists() {
command -v "$1" &> /dev/null
}
# Parse arguments
USE_CONDA=false
for arg in "$@"; do
if [ "$arg" == "--conda" ]; then
USE_CONDA=true
fi
done
# Check for Python 3.10 or Conda
if [ "$USE_CONDA" == true ] || ! command_exists python3.10; then
echo "Python 3.10 is not installed or --conda flag is used. Checking for Conda..."
if command_exists conda; then
echo "Conda is installed. Using Conda to create an environment."
if [ ! -d "venv" ]; then
echo "Creating Conda environment..."
conda create --yes --prefix ./venv python=3.10
else
echo "Conda environment already exists."
fi
source activate ./venv
else
echo "Neither Python 3.10 nor Conda are installed! Install one and rerun the script."
exit 1
fi
else
echo "Python 3.10 is installed. Using Python virtual environment."
if [ ! -d "venv" ]; then
echo "Creating virtual environment..."
python3.10 -m venv venv
else
echo "Virtual environment already exists."
fi
source venv/bin/activate
fi
# Install dependencies
if [ -f "requirements.txt" ]; then
echo "Installing required packages..."
pip install --upgrade pip
pip install -r requirements.txt
else
echo "requirements.txt file not found!"
fi
# Deactivate virtual environment
if [ "$USE_CONDA" == true ]; then
conda deactivate
else
deactivate
fi
echo "Script completed."