-
Notifications
You must be signed in to change notification settings - Fork 36
/
requirements.sh
69 lines (58 loc) · 1.82 KB
/
requirements.sh
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
#!/bin/bash
# Define colors
YELLOW='\033[1;33m'
GREEN='\033[1;32m'
RED='\033[1;31m'
MAGENTA='\033[1;35m'
NC='\033[0m'
# Check if Homebrew is already installed
echo -e "${YELLOW}Checking for Homebrew...${NC}"
if command -v brew >/dev/null 2>&1; then
echo -e "${GREEN}Homebrew is already installed${NC}"
else
echo -e "${YELLOW}Installing Homebrew...${NC}"
# Run Homebrew installation script
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo -e "${GREEN}Homebrew installation finished${NC}"
fi
# Install Python and pip
echo -e "${YELLOW}Checking and Installing Python and pip...${NC}"
brew install python
if command -v pip3 >/dev/null 2>&1; then
echo -e "${GREEN}pip3 is already installed${NC}"
else
echo -e "${RED}Error: pip3 not found after installing Python${NC}"
exit 1
fi
# Save Python script to check and install dependencies
echo -e "${YELLOW}Checking and installing project dependencies...${NC}"
cat > check_and_install_reqs.py << 'EOF'
import sys
import pkg_resources
from subprocess import call
from termcolor import colored
requirements = [
'Flask',
'Flask-Sijax',
'mimerender',
'pymongo',
'six',
'bcrypt',
'termcolor',
'requests',
'urllib3', # this library provides urlretrieve
'tqdm',
]
for req in requirements:
try:
pkg_resources.get_distribution(req)
print(colored(f"{req} is already installed", 'magenta'))
except pkg_resources.DistributionNotFound:
print(colored(f"Installing {req}...", 'yellow'))
call([sys.executable, '-m', 'pip', 'install', req])
EOF
python3 -m pip install termcolor
python3 check_and_install_reqs.py
rm check_and_install_reqs.py
echo -e "${MAGENTA}Finished checking and installing project dependencies${NC}"
echo -e "${MAGENTA}You are all set!${NC}"