forked from Opentrons/opentrons
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·183 lines (140 loc) · 5.5 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
# opentrons api makefile
include ../scripts/push.mk
include ../scripts/python.mk
# using bash instead of /bin/bash in SHELL prevents macOS optimizing away our PATH update
SHELL := bash
# add yarn CLI dev deps to PATH (for cross platform POSIX commands via shx)
# and also make an explicit version for shx for use in the shell function,
# where PATH won’t be propagated
PATH := $(shell cd .. && yarn bin):$(PATH)
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
# Find the version of the wheel from package.json 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,opentrons,$(BUILD_NUMBER))
# 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_qc_scripts.py would run only the
# specified test
tests ?= tests
test_opts ?= --cov=src/opentrons --cov-report term-missing:skip-covered --cov-report xml:coverage.xml
# 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 buildroot robot
br_ssh_key ?= $(default_ssh_key)
# Other SSH args for buildroot robots
ssh_opts ?= $(default_ssh_opts)
twine_auth_args := --username $(pypi_username) --password $(pypi_password)
twine_repository_url ?= $(pypi_test_upload_url)
# Source discovery
# For the python sources
ot_py_sources := $(filter %.py,$(shell $(SHX) find src/opentrons/))
# And the out of tree shared data
ot_shared_data_sources := $(filter %.json,$(shell $(SHX) find ../shared-data/))
# And the arbitrary stuff in resources
ot_resources := $(filter %,$(shell $(SHX) find src/opentrons/resources))
ot_sources := $(ot_py_sources) $(ot_shared_data_sources) $(ot_resources)
ot_tests_to_typecheck := \
tests/opentrons/protocol_api_experimental \
tests/opentrons/protocol_engine \
tests/opentrons/motion_planning \
tests/opentrons/file_runner
# 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 dist .coverage coverage.xml '*.egg-info' '**/__pycache__' '**/*.pyc' 'src/**/.mypy_cache'
plot_type ?=
.PHONY: all
all: clean wheel
.PHONY: setup
setup:
$(pipenv) sync $(pipenv_opts)
$(pipenv) run pip freeze
.PHONY: clean
clean: docs-clean
$(clean_cmd)
.PHONY: teardown
teardown:
$(pipenv) --rm
dist/opentrons-%-py2.py3-none-any.whl: setup.py $(ot_sources)
$(clean_cmd)
$(python) setup.py $(wheel_opts) bdist_wheel
$(SHX) rm -rf build
$(SHX) ls dist
wheel: $(wheel_file)
.PHONY: test
test:
$(pytest) $(tests) $(test_opts)
.PHONY: lint
lint: $(ot_py_sources)
$(python) -m mypy src/opentrons $(ot_tests_to_typecheck)
$(python) -m flake8 setup.py src/opentrons tests
docs/build/html/v%: docs/v%
$(sphinx_build) -b html -d docs/build/doctrees -n $< $@
$(SHX) cp docs/img/lightbulb.jpg $@/_images/ # sphinx wont automatically do this because it's only in a template
docs/build/html/hardware: docs/hardware src/opentrons/hardware_control
$(sphinx_build) -b html -d docs/build/doctrees -n $< $@
$(SHX) mkdir $@/_images/
$(SHX) cp docs/img/lightbulb.jpg $@/_images/
docs/build/pdf/OpentronsPythonAPIV%.pdf: docs/v%
$(sphinx_build) -b latex -d docs/build/doctrees $< $(@D)
$(MAKE) -C $(@D) all-pdf $(if $(CI),>/dev/null,|| $(SHX) echo "latex build failed (pdflatex not installed?)")
$(SHX) ls $(@D)/*.pdf $(if $(CI),,|| $(SHX) echo "no pdf produced")
docs/build/pdf/OT2HardwareControl.pdf: docs/hardware
$(sphinx_build) -b latex -d docs/build/doctrees $< $(@D)
$(MAKE) -C $(@D) all-pdf $(if $(CI),>/dev/null,|| $(SHX) echo "latex build failed (pdflatex not installed)")
docs/dist/v%: docs/build/html/v% docs/build/pdf/OpentronsPythonAPIV%.pdf
$(SHX) mkdir -p $@
$(SHX) cp -R $^ $(@D) $(if $(CI),,|| true)
docs/dist/hardware: docs/build/html/hardware docs/build/pdf/OT2HardwareControl.pdf
$(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),$(br_ssh_key),$(ssh_opts),$(wheel_file))
.PHONY: push
push: push-no-restart
$(call restart-service,$(host),$(br_ssh_key),$(ssh_opts),"jupyter-notebook 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
$(call python_upload_package,$(twine_auth_args),$(twine_repository_url),$(wheel_file))
# User must currently specify host, e.g.: `make term host=169.254.202.176`
.PHONY: term
term:
ssh -i $(br_ssh_key) $(ssh_opts) root@$(host)
.PHONY: plot-session
plot-session:
$(python) util/plot_session.py $(plot_type) $(plot_type).pdf