forked from Opentrons/opentrons
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
executable file
·181 lines (144 loc) · 4.97 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
# opentrons api makefile
SHELL := /bin/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
python := pipenv run python
pip := pipenv run pip
pytest := pipenv run py.test
pipenv_opts := --dev
pipenv_opts += $(and $(CI),--keep-outdated --clear)
# 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/opentrons-$(shell $(python) build_tools.py normalize_version)-py2.py3-none-any.whl
wheel_pattern := dist/opentrons-%-py2.py3-none-any.whl
# 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 ?=
# 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 ?=
twine_auth_args := --username $(pypi_username) --password $(pypi_password)
# 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)
# 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'
.PHONY: all
all: clean wheel
.PHONY: install
install:
pipenv sync $(pipenv_opts)
.PHONY: clean
clean:
$(clean_cmd)
.PHONY: uninstall
uninstall:
pipenv --rm
$(wheel_pattern): setup.py $(ot_sources)
$(clean_cmd)
$(python) setup.py bdist_wheel
shx rm -rf build
$(python) -m twine check $@
shx ls dist
wheel: $(wheel_file)
.PHONY: test
test: local-install
$(pytest) $(tests) $(test_opts)
.PHONY: lint
lint: $(ot_py_sources)
$(python) -m mypy src/opentrons
$(python) -m pylama src/opentrons tests
.PHONY: docs docs-html docs-doctest docs-pdf
docs-html: local-install
shx rm -rf docs/build/html
pipenv run sphinx-build -b html -d docs/build/doctrees docs/source docs/build/html
docs-doctest: local-install
shx rm -rf docs/build/doctest
pipenv run sphinx-build -b doctest -d docs/build/doctrees docs/source docs/build/doctest
docs-pdf: local-install
-shx rm -rf docs/build/pdf
-pipenv run sphinx-build -b latex -d docs/build/doctrees docs/source docs/build/pdf
-$(MAKE) -C docs/build/pdf all-pdf
.PHONY: docs
docs: docs-pdf docs-html
shx mkdir -p docs/dist
shx cp -R docs/build/html/. docs/public/. docs/dist
-shx cp docs/build/pdf/OpentronsAPI.pdf docs/dist/_static
.PHONY: publish
publish:
cd scripts && publish.sh && doc-deploy.sh
.PHONY: dev
dev: export ENABLE_VIRTUAL_SMOOTHIE := true
dev: local-install
$(python) -m opentrons.main -P 31950
.PHONY: local-install
local-install: wheel
$(pip) install --ignore-installed --no-deps $(wildcard dist/opentrons-*.whl)
.PHONY: local-shell
local-shell: local-install
pipenv shell
.PHONY: deploy-staging
deploy-staging: wheel
-$(python) -m twine upload --repository-url "https://test.pypi.org/legacy/"\
$(twine_auth_args)\
$(wheel_file)
.PHONY: deploy
deploy: wheel
$(python) -m twine upload $(twine_auth_args)\
$(wheel_file)
.PHONY: push
push: wheel
curl -X POST \
-H "Content-Type: multipart/form-data" \
-F "whl=@$(wildcard dist/opentrons-*.whl)" \
http://$(host):31950/server/update
.PHONY: flash
flash:
curl -X POST \
-H "Content-Type: multipart/form-data" \
-F "hex=@$(firmware)" \
http://$(host):31950/server/update/firmware
.PHONY: restart
restart:
curl -X POST http://$(host):31950/server/restart
.PHONY: change-right
change-right:
curl -X POST \
-H "Content-Type: application/json" \
-d '{"target": "mount", "mount": "right", "point": [65, 40, 30]}' \
http://$(host):31950/robot/move
curl -X POST \
-H "Content-Type: application/json" \
-d '{"axes": ["c"]}' \
http://$(host):31950/motors/disengage
.PHONY: change-left
change-left:
curl -X POST \
-H "Content-Type: application/json" \
-d '{"target": "mount", "mount": "left", "point": [325, 40, 30]}' \
http://$(host):31950/robot/move
curl -X POST \
-H "Content-Type: application/json" \
-d '{"axes": ["b"]}' \
http://$(host):31950/motors/disengage
# User must currently specify host, e.g.: `make term host=169.254.202.176`
.PHONY: term
term:
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@$(host)