-
Notifications
You must be signed in to change notification settings - Fork 178
/
Makefile
executable file
·218 lines (170 loc) · 6.25 KB
/
Makefile
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
# opentrons api makefile
include ../scripts/push.mk
include ../scripts/python.mk
SHX := npx shx
# make push wheel file (= rather than := to expand at every use)
firmware = $(wildcard smoothie/*.hex)
# python and pipenv config
sphinx_build := $(pipenv) run sphinx-build -W --keep-going
# todo(mm, 2021-10-04):
# 1. Resolve all Sphinx warnings.
# 2. Convert all recipes to use $(sphinx_build).
# 3. Delete $(sphinx_build_allow_warnings).
# github.com/Opentrons/opentrons/issues/6135
sphinx_build_allow_warnings := $(pipenv) run sphinx-build
ot_project := $(OPENTRONS_PROJECT)
project_rs_default = $(if $(ot_project),$(ot_project),robot-stack)
project_ir_default = $(if $(ot_project),$(ot_project),ot3)
# Find the version of the wheel from git using a helper script. We
# use python here so we can use the same version normalization that will be
# used to create the wheel.
wheel_file = dist/$(call python_get_wheelname,api,$(project_rs_default),opentrons,$(BUILD_NUMBER))
# Find the version of the sdist file from git using a helper script.
sdist_file = dist/$(call python_get_sdistname,api,$(project_rs_default),opentrons)
# Find the branch, sha, version that will be used to update the VERSION.json file
version_file = $(call python_get_git_version,api,$(project_rs_default),opentrons)
# These variables are for simulating python protocols
sim_log_level ?= info
simfile ?=
# These variables can be overriden when make is invoked to customize the
# behavior of pytest. For instance,
# make test tests=tests/opentrons/tools/test_pipette_memory.py would run only the
# specified test
tests ?= tests
cov_opts ?= --cov=src/opentrons --cov-report term-missing:skip-covered --cov-report xml:coverage.xml
test_opts ?=
# These variables must be overridden when make deploy or make deploy-staging is run
# to set the auth details for pypi
pypi_username ?=
pypi_password ?=
# Host key location for robot
ssh_key ?= $(default_ssh_key)
# Other SSH args for robot
ssh_opts ?= $(default_ssh_opts)
# Helper to safely bundle ssh options
ssh_helper = $(if $(ssh_key),-i $(ssh_key)) $(ssh_opts)
twine_auth_args := --username $(pypi_username) --password $(pypi_password)
twine_repository_url ?= $(pypi_test_upload_url)
# Defined separately than the clean target so the wheel file doesn’t have to
# depend on a PHONY target
clean_cmd = $(SHX) rm -rf build .coverage coverage.xml '*.egg-info'
clean_cache_cmd = $(SHX) rm -rf '**/__pycache__' '**/*.pyc' '**/.mypy_cache'
clean_wheel_cmd = $(clean_cmd) dist/*.whl
clean_sdist_cmd = $(clean_cmd) dist/*.tar.gz
clean_all_cmd = $(clean_cmd) dist
plot_type ?=
.PHONY: all
all: clean sdist wheel
.PHONY: setup
setup:
$(pipenv) sync $(pipenv_opts)
$(pipenv) run pip freeze
.PHONY: setup-ot2
setup-ot2:
$(pipenv) sync $(pipenv_opts)
$(pipenv) run pip uninstall -y python-can
$(pipenv) run pip freeze
.PHONY: clean
clean: docs-clean
$(clean_all_cmd)
$(clean_cache_cmd)
.PHONY: teardown
teardown:
$(pipenv) --rm
.PHONY: wheel
wheel: export OPENTRONS_PROJECT=$(project_rs_default)
wheel:
$(clean_wheel_cmd)
$(python) setup.py $(wheel_opts) bdist_wheel
$(SHX) rm -rf build
$(SHX) ls dist
.PHONY: sdist
sdist: export OPENTRONS_PROJECT=$(project_rs_default)
sdist:
$(clean_sdist_cmd)
$(python) setup.py sdist
$(SHX) rm -rf build
$(SHX) ls dist
.PHONY: test
test:
$(pytest) $(tests) $(test_opts)
.PHONY: test-cov
test-cov:
$(pytest) $(tests) $(test_opts) $(cov_opts)
.PHONY: test-ot2
test-ot2:
$(pytest) -m 'not ot3_only' $(tests) $(test_opts) --ot2-only --ignore-glob="**/*ot3*"
.PHONY: lint
lint:
$(python) -m mypy src tests
$(python) -m black --check src tests setup.py
$(python) -m flake8 src tests setup.py
.PHONY: format
format:
$(python) -m black src tests setup.py
docs/build/html/v%: docs/v%
$(sphinx_build) -b html -d docs/build/doctrees -n $< $@
docs/build/html/hardware: docs/hardware src/opentrons/hardware_control
$(sphinx_build_allow_warnings) -b html -d docs/build/doctrees -n $< $@
$(SHX) mkdir $@/_images/
docs/dist/v%: docs/build/html/v%
$(SHX) mkdir -p $@
$(SHX) cp -R $^ $(@D) $(if $(CI),,|| true)
docs/dist/hardware: docs/build/html/hardware
$(SHX) mkdir -p $@
$(SHX) cp -R $^ $(@D) $(if $(CI),,|| true)
docs/dist/ot1: docs/ot1
$(SHX) mkdir -p $@
$(SHX) cp -R $< $(@D)
docs/dist/%: docs/root/%
$(SHX) mkdir -p $(@D)
$(SHX) cp -R docs/root/* docs/dist/
.PHONY: docs
docs: docs/dist/index.html docs/dist/v1 docs/dist/v2 docs/dist/ot1 docs/dist/hardware
.PHONY: docs-clean
docs-clean:
$(SHX) rm -rf docs/dist docs/build
.PHONY: dev
dev:
echo "Command will be deprecated. Use \"make -C robot-server dev\""
$(MAKE) -C ../robot-server dev
.PHONY: local-shell
local-shell:
$(pipenv) shell
.PHONY: push-no-restart
push-no-restart: wheel
$(call push-python-package,$(host),$(ssh_key),$(ssh_opts),$(wheel_file))
.PHONY: push
push: push-no-restart
$(call restart-service,$(host),$(ssh_key),$(ssh_opts),"jupyter-notebook opentrons-robot-server")
.PHONY: push-no-restart-ot3
push-no-restart-ot3: sdist
echo $(sdist_file)
$(call push-python-sdist,$(host),$(ssh_key),$(ssh_opts),$(sdist_file),/opt/opentrons-robot-server,opentrons,src,,$(version_file))
ssh $(ssh_helper) root@$(host) "mount -o remount,rw / && mkdir -p /usr/local/bin"
scp $(ssh_helper) ./src/opentrons/hardware_control/scripts/ot3repl root@$(host):/usr/local/bin/
scp $(ssh_helper) ./src/opentrons/hardware_control/scripts/ot3gripper root@$(host):/usr/local/bin/
ssh $(ssh_helper) root@$(host) "mount -o remount,ro /"
.PHONY: push-ot3
push-ot3: push-no-restart-ot3
$(call restart-service,$(host),$(ssh_key),$(ssh_opts),"opentrons-robot-server")
.PHONY: simulate
simulate:
-$(python) -m opentrons.simulate -l $(sim_log_level) $(simfile)
# Launch the emulator application.
.PHONY: emulator
emulator:
-$(python) -m opentrons.hardware_control.emulation.app
.PHONY: deploy
deploy: wheel sdist
$(call python_upload_package,$(twine_auth_args),$(twine_repository_url),$(wheel_file),$(sdist_file))
# User must currently specify host, e.g.: `make term host=169.254.202.176`
.PHONY: term
term:
ssh $(ssh_helper) root@$(host)
.PHONY: plot-session
plot-session:
$(python) util/plot_session.py $(plot_type) $(plot_type).pdf
PHONY: command-schema
command-schema:
$(python) src/opentrons/protocol_engine/commands/generate_command_schema.py $(COMMAND_SCHEMA_VERSION) > ../shared-data/command/schemas/$(COMMAND_SCHEMA_VERSION).json