forked from ml-dev-bench/ml-dev-bench
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
193 lines (175 loc) · 8.21 KB
/
Makefile
File metadata and controls
193 lines (175 loc) · 8.21 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
SHELL=/bin/bash
# Makefile for project
# Variables
DEFAULT_WORKSPACE_DIR = "./workspace"
DEFAULT_MODEL = "gpt-4o"
CONFIG_FILE = config.toml
PRE_COMMIT_CONFIG_PATH = "./dev_config/python/.pre-commit-config.yaml"
PYTHON_VERSION = 3.12
# ANSI color codes
GREEN=$(shell tput -Txterm setaf 2)
YELLOW=$(shell tput -Txterm setaf 3)
RED=$(shell tput -Txterm setaf 1)
BLUE=$(shell tput -Txterm setaf 6)
RESET=$(shell tput -Txterm sgr0)
# Build
deploy-build:
@echo "$(GREEN)Building project...$(RESET)"
@$(MAKE) -s check-dependencies
@$(MAKE) -s install-deploy-python-dependencies
@$(MAKE) -s install-runtime-dependencies
@echo "$(GREEN)Build completed successfully.$(RESET)"
# @$(MAKE) -s check-dependencies
build:
@echo "$(GREEN)Building project...$(RESET)"
@$(MAKE) -s install-python-dependencies
@$(MAKE) -s install-pre-commit-hooks
@$(MAKE) -s install-runtime-dependencies
@echo "$(GREEN)Build completed successfully.$(RESET)"
check-dependencies:
@echo "$(YELLOW)Checking dependencies...$(RESET)"
@$(MAKE) -s check-system
@$(MAKE) -s check-python
@$(MAKE) -s check-poetry
@echo "$(GREEN)Dependencies checked successfully.$(RESET)"
check-system:
@echo "$(YELLOW)Checking system...$(RESET)"
@if [ "$(shell uname)" = "Darwin" ]; then \
echo "$(BLUE)macOS detected.$(RESET)"; \
elif [ "$(shell uname)" = "Linux" ]; then \
if [ -f "/etc/manjaro-release" ]; then \
echo "$(BLUE)Manjaro Linux detected.$(RESET)"; \
else \
echo "$(BLUE)Linux detected.$(RESET)"; \
fi; \
elif [ "$$(uname -r | grep -i microsoft)" ]; then \
echo "$(BLUE)Windows Subsystem for Linux detected.$(RESET)"; \
else \
echo "$(RED)Unsupported system detected. Please use macOS, Linux, or Windows Subsystem for Linux (WSL).$(RESET)"; \
exit 1; \
fi
check-python:
@echo "$(YELLOW)Checking Python installation...$(RESET)"
@if command -v python$(PYTHON_VERSION) > /dev/null; then \
echo "$(BLUE)$(shell python$(PYTHON_VERSION) --version) is already installed.$(RESET)"; \
else \
echo "$(RED)Python $(PYTHON_VERSION) is not installed. Please install Python $(PYTHON_VERSION) to continue.$(RESET)"; \
exit 1; \
fi
check-poetry:
@echo "$(YELLOW)Checking Poetry installation...$(RESET)"
@if command -v poetry > /dev/null; then \
POETRY_VERSION=$(shell poetry --version 2>&1 | sed -E 's/Poetry \(version ([0-9]+\.[0-9]+\.[0-9]+)\)/\1/'); \
IFS='.' read -r -a POETRY_VERSION_ARRAY <<< "$$POETRY_VERSION"; \
if [ $${POETRY_VERSION_ARRAY[0]} -ge 1 ] && [ $${POETRY_VERSION_ARRAY[1]} -ge 8 ]; then \
echo "$(BLUE)$(shell poetry --version) is already installed.$(RESET)"; \
else \
echo "$(RED)Poetry 1.8 or later is required. You can install poetry by running the following command, then adding Poetry to your PATH:"; \
echo "$(RED) curl -sSL https://install.python-poetry.org | python$(PYTHON_VERSION) -$(RESET)"; \
echo "$(RED)More detail here: https://python-poetry.org/docs/#installing-with-the-official-installer$(RESET)"; \
exit 1; \
fi; \
else \
echo "$(RED)Poetry is not installed. You can install poetry by running the following command, then adding Poetry to your PATH:"; \
echo "$(RED) curl -sSL https://install.python-poetry.org | python$(PYTHON_VERSION) -$(RESET)"; \
echo "$(RED)More detail here: https://python-poetry.org/docs/#installing-with-the-official-installer$(RESET)"; \
exit 1; \
fi
install-deploy-python-dependencies:
@echo "$(GREEN)Installing Python dependencies...$(RESET)"
@if [ -z "${TZ}" ]; then \
echo "Defaulting TZ (timezone) to UTC"; \
export TZ="UTC"; \
fi
poetry env use python$(PYTHON_VERSION)
@poetry install --without dev
@echo "$(GREEN)Python dependencies installed successfully.$(RESET)"
install-python-dependencies:
@echo "$(GREEN)Installing Python dependencies...$(RESET)"
@if [ -z "${TZ}" ]; then \
echo "Defaulting TZ (timezone) to UTC"; \
export TZ="UTC"; \
fi
poetry config installer.parallel true
poetry config virtualenvs.create true
poetry env use python$(PYTHON_VERSION)
@POETRY_REQUESTS_TIMEOUT=120 poetry install --no-interaction --verbose
@echo "$(GREEN)Python dependencies installed successfully.$(RESET)"
install-react-agent-dependencies:
@echo "$(GREEN)Installing Python dependencies with react-agent in new environment...$(RESET)"
@if [ -z "${TZ}" ]; then \
echo "Defaulting TZ (timezone) to UTC"; \
export TZ="UTC"; \
fi
@echo "$(YELLOW)Creating new virtual environment for react-agent...$(RESET)"
POETRY_VIRTUALENVS_PATH="./.venv-react" poetry env use python$(PYTHON_VERSION)
POETRY_VIRTUALENVS_PATH="./.venv-react" poetry install --with react-agent
@echo "$(GREEN)Python dependencies with react-agent installed successfully in .venv-react$(RESET)"
@echo "$(BLUE)To activate this environment, run: POETRY_VIRTUALENVS_PATH='./.venv-react' poetry shell$(RESET)"
install-aide-agent-dependencies:
@echo "$(GREEN)Installing Python dependencies with aide-agent in new environment...$(RESET)"
@if [ -z "${TZ}" ]; then \
echo "Defaulting TZ (timezone) to UTC"; \
export TZ="UTC"; \
fi
@echo "$(YELLOW)Creating new virtual environment for aide-agent...$(RESET)"
@rm -rf .venv-aide
@mkdir -p .venv-aide
POETRY_VIRTUALENVS_CREATE=true \
POETRY_VIRTUALENVS_IN_PROJECT=false \
POETRY_VIRTUALENVS_PATH="$(PWD)/.venv-aide" \
poetry env use python$(PYTHON_VERSION)
POETRY_VIRTUALENVS_CREATE=true \
POETRY_VIRTUALENVS_IN_PROJECT=false \
POETRY_VIRTUALENVS_PATH="$(PWD)/.venv-aide" \
poetry install --with aide
@echo "$(GREEN)Python dependencies with aide-agent installed successfully in .venv-aide$(RESET)"
@echo "$(BLUE)To activate this environment, run: POETRY_VIRTUALENVS_PATH='$(PWD)/.venv-aide' poetry shell$(RESET)"
install-runtime-dependencies:
@echo "$(GREEN)Installing runtime Python dependencies...$(RESET)"
@if [ -z "${TZ}" ]; then \
echo "Defaulting TZ (timezone) to UTC"; \
export TZ="UTC"; \
fi
cd runtime/dependencies && poetry env use python$(PYTHON_VERSION)
@cd runtime/dependencies && poetry install --no-root
@echo "$(GREEN)Runtime dependencies installed successfully.$(RESET)"
install-gcloud-key:
@echo "$(YELLOW)Installing Google Cloud SDK repository key...$(RESET)"
@sudo apt-get install apt-transport-https ca-certificates gnupg -y
@sudo rm -f /usr/share/keyrings/cloud.google.gpg
@curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo gpg --dearmor -o /usr/share/keyrings/cloud.google.gpg
@echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee /etc/apt/sources.list.d/google-cloud-sdk.list
@curl -fsSL https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
@sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C0BA5CE6DC6315A3
@sudo apt-get update
@echo "$(GREEN)Google Cloud SDK repository key installed successfully.$(RESET)"
install-openhands-agent-dependencies:
@echo "$(GREEN)Installing Python dependencies with openhands-agent in new environment...$(RESET)"
@if [ -z "${TZ}" ]; then \
echo "Defaulting TZ (timezone) to UTC"; \
export TZ="UTC"; \
fi
@echo "$(YELLOW)Creating new virtual environment for openhands-agent...$(RESET)"
@rm -rf .venv-openhands
@mkdir -p .venv-openhands
POETRY_VIRTUALENVS_CREATE=true \
POETRY_VIRTUALENVS_IN_PROJECT=false \
POETRY_VIRTUALENVS_PATH="$(PWD)/.venv-openhands" \
poetry env use python$(PYTHON_VERSION)
POETRY_VIRTUALENVS_CREATE=true \
POETRY_VIRTUALENVS_IN_PROJECT=false \
POETRY_VIRTUALENVS_PATH="$(PWD)/.venv-openhands" \
poetry install --with openhands-agent || ($(MAKE) -s install-gcloud-key && POETRY_VIRTUALENVS_PATH="$(PWD)/.venv-openhands" poetry install --with openhands-agent)
POETRY_VIRTUALENVS_PATH="$(PWD)/.venv-openhands" \
poetry run playwright install --with-deps chromium
@echo "$(GREEN)Python dependencies with openhands-agent installed successfully in .venv-openhands$(RESET)"
@echo "$(BLUE)To activate this environment, run: POETRY_VIRTUALENVS_PATH='$(PWD)/.venv-openhands' poetry shell$(RESET)"
install-pre-commit-hooks:
@echo "$(YELLOW)Installing pre-commit hooks...$(RESET)"
@git config --unset-all core.hooksPath || true
@poetry run pre-commit install --config $(PRE_COMMIT_CONFIG_PATH)
@echo "$(GREEN)Pre-commit hooks installed successfully.$(RESET)"
lint:
@echo "$(YELLOW)Running linters...$(RESET)"
@poetry run pre-commit run --files /**/* --show-diff-on-failure --config $(PRE_COMMIT_CONFIG_PATH)