-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathsetup-venv.sh
More file actions
executable file
·61 lines (51 loc) · 1.58 KB
/
Copy pathsetup-venv.sh
File metadata and controls
executable file
·61 lines (51 loc) · 1.58 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
60
61
#!/bin/bash
# Virtual Environment Setup Helper
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
NC='\033[0m'
VENV_DIR="venv"
echo -e "${GREEN}Flask RESTful API - Virtual Environment Setup${NC}"
echo ""
# Check if venv exists
if [ -d "$VENV_DIR" ]; then
echo -e "${YELLOW}Virtual environment already exists at: $VENV_DIR${NC}"
echo ""
echo "To activate it, run:"
echo -e "${BLUE} source $VENV_DIR/bin/activate${NC}"
echo ""
echo "To recreate it, first remove the existing one:"
echo " rm -rf $VENV_DIR"
echo " $0"
exit 0
fi
# Create virtual environment
echo -e "${BLUE}Creating virtual environment...${NC}"
python3 -m venv $VENV_DIR
if [ $? -ne 0 ]; then
echo -e "${RED}Failed to create virtual environment${NC}"
echo "Make sure python3-venv is installed:"
echo " sudo apt-get install python3-venv # Ubuntu/Debian"
echo " sudo yum install python3-venv # CentOS/RHEL"
exit 1
fi
echo -e "${GREEN}✓ Virtual environment created${NC}"
echo ""
# Activate and install dependencies
echo -e "${BLUE}Activating virtual environment and installing dependencies...${NC}"
source $VENV_DIR/bin/activate
pip install --upgrade pip
pip install -r app/requirements.txt
echo ""
echo -e "${GREEN}✓ Setup complete!${NC}"
echo ""
echo "Virtual environment is now activated for this session."
echo ""
echo "To activate it in the future, run:"
echo -e "${BLUE} source $VENV_DIR/bin/activate${NC}"
echo ""
echo "To deactivate when done:"
echo -e "${BLUE} deactivate${NC}"
echo ""
echo "Now you can start the server:"
echo -e "${BLUE} ./run.sh --sqlite${NC}"