-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
226 lines (213 loc) · 11.4 KB
/
makefile
File metadata and controls
226 lines (213 loc) · 11.4 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# Makefile for ShearNet installation
# Ensure we use bash for consistent echo behavior
SHELL := /bin/bash
# Color definitions
RED := \033[0;31m
GREEN := \033[0;32m
YELLOW := \033[1;33m
BLUE := \033[0;34m
PURPLE := \033[0;35m
CYAN := \033[0;36m
WHITE := \033[1;37m
NC := \033[0m # No Color
# Bold variants
BOLD := \033[1m
BOLD_RED := \033[1;31m
BOLD_GREEN := \033[1;32m
# Conda source command
CONDA_ACTIVATE := source $$(conda info --base)/etc/profile.d/conda.sh
.PHONY: help install install-gpu install-gpu12 install-dev install-all clean test uninstall
help:
@printf "\n"
@printf "$(BOLD)$(CYAN)╔════════════════════════════════════════════╗$(NC)\n"
@printf "$(BOLD)$(CYAN)║ ShearNet Installation Options ║$(NC)\n"
@printf "$(BOLD)$(CYAN)╚════════════════════════════════════════════╝$(NC)\n"
@printf "\n"
@printf "$(BOLD)$(YELLOW)Basic Installation:$(NC)\n"
@printf " $(CYAN)make install$(NC) - Install CPU version\n"
@printf " $(CYAN)make install-gpu$(NC) - Install GPU version (CUDA 12)\n"
@printf "\n"
@printf "$(BOLD)$(YELLOW)Development Installation:$(NC)\n"
@printf " $(CYAN)make install-dev$(NC) - Install with development tools\n"
@printf " $(CYAN)make install-all$(NC) - Install GPU + dev tools\n"
@printf "\n"
@printf "$(BOLD)$(YELLOW)Maintenance:$(NC)\n"
@printf " $(CYAN)make test$(NC) - Run tests\n"
@printf " $(CYAN)make clean$(NC) - Remove ALL ShearNet environments\n"
@printf " $(CYAN)make uninstall$(NC) - Remove specific environment\n"
@printf "\n"
@printf "$(BOLD)$(GREEN)Example:$(NC) make install-gpu\n"
@printf "\n"
install:
@printf "\n"
@printf "$(BOLD)$(BLUE)════════════════════════════════════════════$(NC)\n"
@printf "$(BOLD)$(WHITE) Installing ShearNet (CPU Version) $(NC)\n"
@printf "$(BOLD)$(BLUE)════════════════════════════════════════════$(NC)\n"
@printf "\n"
@printf "$(YELLOW)→ Creating conda environment 'shearnet'...$(NC)\n"
@conda create -n shearnet python=3.11 pip numba -y --no-default-packages -q
@printf "$(GREEN)✓ Environment created$(NC)\n"
@printf "\n"
@printf "$(YELLOW)→ Installing ShearNet package and dependencies...$(NC)\n"
@$(CONDA_ACTIVATE) && conda activate shearnet && \
pip install -e . --quiet && \
printf "$(GREEN)✓ ShearNet installed$(NC)\n"
@printf "\n"
@printf "$(YELLOW)→ Installing NGmix...$(NC)\n"
@$(CONDA_ACTIVATE) && conda activate shearnet && \
pip install git+https://github.com/esheldon/ngmix.git --use-pep517 --quiet && \
printf "$(GREEN)✓ NGmix installed$(NC)\n"
@printf "\n"
@printf "$(YELLOW)→ Running post-installation setup...$(NC)\n"
@$(CONDA_ACTIVATE) && conda activate shearnet && \
python scripts/post_installation.py
@printf "$(GREEN)✓ Setup complete$(NC)\n"
@printf "\n"
@printf "$(BOLD)$(GREEN)════════════════════════════════════════════$(NC)\n"
@printf "$(BOLD)$(GREEN)✓ Installation successful!$(NC)\n"
@printf "$(BOLD)$(WHITE) Activate with: $(CYAN)conda activate shearnet$(NC)\n"
@printf "$(BOLD)$(GREEN)════════════════════════════════════════════$(NC)\n"
@printf "\n"
install-gpu:
@printf "\n"
@printf "$(BOLD)$(PURPLE)════════════════════════════════════════════$(NC)\n"
@printf "$(BOLD)$(WHITE) Installing ShearNet (GPU CUDA 12) $(NC)\n"
@printf "$(BOLD)$(PURPLE)════════════════════════════════════════════$(NC)\n"
@printf "\n"
@printf "$(YELLOW)→ Creating conda environment 'shearnet_gpu'...$(NC)\n"
@conda create -n shearnet_gpu python=3.11 pip numba -y --no-default-packages -q
@printf "$(GREEN)✓ Environment created$(NC)\n"
@printf "\n"
@printf "$(YELLOW)→ Installing ShearNet with GPU support (CUDA 12)...$(NC)\n"
@$(CONDA_ACTIVATE) && conda activate shearnet_gpu && \
pip install -U -e ".[gpu]" --quiet && \
printf "$(GREEN)✓ ShearNet GPU version installed$(NC)\n"
@printf "\n"
@printf "$(YELLOW)→ Installing NGmix...$(NC)\n"
@$(CONDA_ACTIVATE) && conda activate shearnet_gpu && \
pip install git+https://github.com/esheldon/ngmix.git --use-pep517 -q 2>&1 | grep -v DEPRECATION || true && \
printf "$(GREEN)✓ NGmix installed$(NC)\n"
@printf "\n"
@printf "$(YELLOW)→ Running post-installation setup...$(NC)\n"
@$(CONDA_ACTIVATE) && conda activate shearnet_gpu && \
python scripts/post_installation.py
@printf "$(GREEN)✓ Setup complete$(NC)\n"
@printf "\n"
@printf "$(BOLD)$(GREEN)════════════════════════════════════════════$(NC)\n"
@printf "$(BOLD)$(GREEN)✓ GPU Installation successful!$(NC)\n"
@printf "$(BOLD)$(WHITE) Activate with: $(CYAN)conda activate shearnet_gpu$(NC)\n"
@printf "$(BOLD)$(GREEN)════════════════════════════════════════════$(NC)\n"
@printf "\n"
install-dev:
@printf "\n"
@printf "$(BOLD)$(CYAN)════════════════════════════════════════════$(NC)\n"
@printf "$(BOLD)$(WHITE) Installing ShearNet (Development Mode) $(NC)\n"
@printf "$(BOLD)$(CYAN)════════════════════════════════════════════$(NC)\n"
@printf "\n"
@printf "$(YELLOW)→ Creating conda environment 'shearnet_dev'...$(NC)\n"
@conda create -n shearnet_dev python=3.11 pip numba -y --no-default-packages -q
@printf "$(GREEN)✓ Environment created$(NC)\n"
@printf "\n"
@printf "$(YELLOW)→ Installing ShearNet with development tools...$(NC)\n"
@$(CONDA_ACTIVATE) && conda activate shearnet_dev && \
pip install -e ".[dev]" --quiet && \
printf "$(GREEN)✓ ShearNet + dev tools installed$(NC)\n"
@printf "\n"
@printf "$(YELLOW)→ Installing NGmix...$(NC)\n"
@$(CONDA_ACTIVATE) && conda activate shearnet_dev && \
pip install git+https://github.com/esheldon/ngmix.git --quiet && \
printf "$(GREEN)✓ NGmix installed$(NC)\n"
@printf "\n"
@printf "$(YELLOW)→ Running post-installation setup...$(NC)\n"
@$(CONDA_ACTIVATE) && conda activate shearnet_dev && \
python scripts/post_installation.py
@printf "$(GREEN)✓ Setup complete$(NC)\n"
@printf "\n"
@printf "$(BOLD)$(GREEN)════════════════════════════════════════════$(NC)\n"
@printf "$(BOLD)$(GREEN)✓ Development installation successful!$(NC)\n"
@printf "$(BOLD)$(WHITE) Activate with: $(CYAN)conda activate shearnet_dev$(NC)\n"
@printf "$(BOLD)$(WHITE) Tools included: pytest, black, flake8, ipython$(NC)\n"
@printf "$(BOLD)$(GREEN)════════════════════════════════════════════$(NC)\n"
@printf "\n"
install-all:
@printf "\n"
@printf "$(BOLD)$(PURPLE)════════════════════════════════════════════$(NC)\n"
@printf "$(BOLD)$(WHITE) Installing ShearNet (GPU + Dev Tools) $(NC)\n"
@printf "$(BOLD)$(PURPLE)════════════════════════════════════════════$(NC)\n"
@printf "\n"
@printf "$(YELLOW)→ Creating conda environment 'shearnet_all'...$(NC)\n"
@conda create -n shearnet_all python=3.11 pip numba cudatoolkit=11.8 -y --no-default-packages -q
@printf "$(GREEN)✓ Environment created with CUDA support$(NC)\n"
@printf "\n"
@printf "$(YELLOW)→ Installing ShearNet with all features...$(NC)\n"
@$(CONDA_ACTIVATE) && conda activate shearnet_all && \
pip install -e ".[gpu,dev]" --quiet && \
printf "$(GREEN)✓ ShearNet complete installation finished$(NC)\n"
@printf "\n"
@printf "$(YELLOW)→ Installing NGmix...$(NC)\n"
@$(CONDA_ACTIVATE) && conda activate shearnet_all && \
pip install git+https://github.com/esheldon/ngmix.git --quiet && \
printf "$(GREEN)✓ NGmix installed$(NC)\n"
@printf "\n"
@printf "$(YELLOW)→ Running post-installation setup...$(NC)\n"
@$(CONDA_ACTIVATE) && conda activate shearnet_all && \
python scripts/post_installation.py
@printf "$(GREEN)✓ Setup complete$(NC)\n"
@printf "\n"
@printf "$(BOLD)$(GREEN)════════════════════════════════════════════$(NC)\n"
@printf "$(BOLD)$(GREEN)✓ Complete installation successful!$(NC)\n"
@printf "$(BOLD)$(WHITE) Activate with: $(CYAN)conda activate shearnet_all$(NC)\n"
@printf "$(BOLD)$(WHITE) Includes: GPU support + all dev tools$(NC)\n"
@printf "$(BOLD)$(GREEN)════════════════════════════════════════════$(NC)\n"
@printf "\n"
test:
@printf "\n"
@printf "$(BOLD)$(YELLOW)Running ShearNet tests...$(NC)\n"
@if conda env list | grep -q "shearnet"; then \
$(CONDA_ACTIVATE) && conda activate shearnet && \
pytest tests/ -v --color=yes; \
else \
printf "$(RED)Error: No ShearNet environment found!$(NC)\n"; \
printf "$(YELLOW)Run 'make install' first.$(NC)\n"; \
fi
clean:
@printf "\n"
@printf "$(BOLD)$(RED)════════════════════════════════════════════$(NC)\n"
@printf "$(BOLD)$(RED) Removing ALL ShearNet Environments $(NC)\n"
@printf "$(BOLD)$(RED)════════════════════════════════════════════$(NC)\n"
@printf "\n"
@printf "$(YELLOW)This will remove:$(NC)\n"
@printf " • shearnet\n"
@printf " • shearnet_gpu\n"
@printf " • shearnet_gpu12\n"
@printf " • shearnet_dev\n"
@printf " • shearnet_all\n"
@printf "\n"
@printf "$(BOLD)$(RED)Are you sure? [y/N] $(NC)"; \
read -n 1 -r REPLY; \
printf "\n"; \
if [[ $$REPLY =~ ^[Yy]$$ ]]; then \
printf "$(YELLOW)→ Removing environments...$(NC)\n"; \
conda env remove -n shearnet -y 2>/dev/null || true; \
conda env remove -n shearnet_gpu -y 2>/dev/null || true; \
conda env remove -n shearnet_gpu12 -y 2>/dev/null || true; \
conda env remove -n shearnet_dev -y 2>/dev/null || true; \
conda env remove -n shearnet_all -y 2>/dev/null || true; \
printf "$(GREEN)✓ All environments removed$(NC)\n"; \
else \
printf "$(YELLOW)Cancelled$(NC)\n"; \
fi
uninstall:
@printf "\n"
@printf "$(BOLD)$(YELLOW)Available ShearNet environments:$(NC)\n"
@conda env list | grep shearnet || printf "$(RED)No ShearNet environments found$(NC)\n"
@printf "\n"
@printf "$(BOLD)Enter environment name to remove: $(NC)"; \
read env_name; \
if conda env list | grep -q "$$env_name"; then \
printf "$(YELLOW)→ Removing $$env_name...$(NC)\n"; \
conda env remove -n $$env_name -y; \
printf "$(GREEN)✓ Environment removed$(NC)\n"; \
else \
printf "$(RED)Environment '$$env_name' not found$(NC)\n"; \
fi