forked from cactus-compute/cactus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup
More file actions
executable file
·115 lines (95 loc) · 3.31 KB
/
setup
File metadata and controls
executable file
·115 lines (95 loc) · 3.31 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/bin/bash
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
echo "Please run: source ./setup"
exit 1
fi
set -e
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
VENV_DIR="$PROJECT_ROOT/venv"
REQUIREMENTS_FILE="${CACTUS_REQUIREMENTS:-$PROJECT_ROOT/python/requirements.txt}"
PARENT_REQUIREMENTS="$PROJECT_ROOT/../requirements.txt"
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
echo "Setting up Cactus development environment..."
echo "============================================="
echo ""
echo -e "${BLUE}Step 1: Configuring git hooks for DCO...${NC}"
git config core.hooksPath .githooks
echo -e "${GREEN}✓ Git hooks configured${NC}"
name=$(git config user.name)
email=$(git config user.email)
if [ -z "$name" ] || [ -z "$email" ]; then
echo ""
echo -e "${YELLOW}⚠️ Warning: Git user configuration is incomplete${NC}"
echo ""
echo "Please configure your git identity:"
echo " git config --global user.name \"Your Name\""
echo " git config --global user.email \"your.email@example.com\""
echo ""
else
echo -e "${GREEN}✓ Git user: $name <$email>${NC}"
fi
echo ""
echo -e "${BLUE}Step 2: Setting up Python virtual environment...${NC}"
if ! command -v python3 &> /dev/null; then
echo -e "${RED}Error: Python3 is not installed${NC}"
echo ""
echo "Please install Python3:"
echo " macOS: brew install python3"
echo " Ubuntu/Debian: sudo apt-get install python3 python3-venv"
exit 1
fi
if [ ! -d "$VENV_DIR" ]; then
if ! python3 -m venv "$VENV_DIR"; then
echo -e "${RED}Failed to create virtual environment${NC}"
echo "Please ensure python3-venv is installed:"
echo " Ubuntu/Debian: sudo apt-get install python3-venv"
echo " macOS: Should be included with Python3"
exit 1
fi
echo -e "${GREEN}✓ Virtual environment created${NC}"
else
echo -e "${GREEN}✓ Virtual environment already exists${NC}"
fi
source "$VENV_DIR/bin/activate"
echo ""
echo -e "${BLUE}Step 3: Installing Python dependencies...${NC}"
pip install --upgrade pip -q
if [ -f "$REQUIREMENTS_FILE" ]; then
if pip install -r "$REQUIREMENTS_FILE" -q; then
echo -e "${GREEN}✓ Dependencies installed${NC}"
else
echo -e "${RED}Failed to install dependencies${NC}"
exit 1
fi
else
echo -e "${YELLOW}Warning: requirements.txt not found${NC}"
fi
if [ -f "$PARENT_REQUIREMENTS" ] && [ "$PARENT_REQUIREMENTS" != "$REQUIREMENTS_FILE" ]; then
echo ""
echo -e "${BLUE}Detected parent repo requirements at: $PARENT_REQUIREMENTS${NC}"
echo -e "${BLUE}Installing parent repo requirements...${NC}"
if pip install -r "$PARENT_REQUIREMENTS" -q; then
echo -e "${GREEN}✓ Parent repo dependencies installed${NC}"
else
echo -e "${YELLOW}Warning: failed to install parent repo requirements${NC}"
fi
fi
echo ""
echo -e "${BLUE}Step 4: Installing cactus CLI tools...${NC}"
if pip install -e "$PROJECT_ROOT/python" --quiet; then
echo -e "${GREEN}✓ Cactus CLI installed${NC}"
else
echo -e "${RED}Failed to install cactus CLI${NC}"
exit 1
fi
echo ""
echo -e "${GREEN}=============================================${NC}"
echo -e "${GREEN}Setup complete!${NC}"
echo -e "${GREEN}=============================================${NC}"
echo ""
cactus --help
set +e