-
Notifications
You must be signed in to change notification settings - Fork 175
/
Makefile
executable file
·121 lines (95 loc) · 3.42 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
# opentrons robot server makefile
include ../scripts/push.mk
include ../scripts/python.mk
SHX := npx shx
# Path of source package
SRC_PATH = server_utils
# Project to get the version for
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,server-utils,$(project_rs_default),server_utils,$(BUILD_NUMBER))
# Find the version of the sdist 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 sdist.
sdist_file = dist/$(call python_get_sdistname,server-utils,$(project_rs_default),server_utils)
# Find the branch, sha, version that will be used to update the VERSION.json file
version_file = $(call python_get_git_version,server-utils,$(project_rs_default),server_utils)
# 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
cov_opts ?= --cov=$(SRC_PATH) --cov-report term-missing:skip-covered --cov-report xml:coverage.xml
test_opts ?=
# Host key location for robot
ssh_key ?= $(default_ssh_key)
# Pubkey location for buildroot robot to install with install-key
br_ssh_pubkey ?= $(ssh_key).pub
# Other SSH args for robot
ssh_opts ?= $(default_ssh_opts)
# Source discovery
# For the python sources
ot_py_sources := $(filter %.py,$(shell $(SHX) find $(SRC_PATH)))
ot_sources := $(ot_py_sources)
# 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
.PHONY: all
all: clean sdist wheel
.PHONY: setup
setup:
$(pipenv) sync $(pipenv_opts)
$(pipenv) run pip freeze
.PHONY: clean
clean:
$(clean_all_cmd)
$(clean_cache_cmd)
.PHONY: teardown
teardown:
$(pipenv) --rm
.PHONY: wheel
wheel: export OPENTRONS_PROJECT=$(project_rs_default)
wheel: setup.py $(ot_sources)
$(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: setup.py $(ot_sources)
$(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: lint
lint:
$(python) -m mypy $(SRC_PATH) $(tests)
$(python) -m black --check .
$(python) -m flake8 $(SRC_PATH) $(tests) setup.py
.PHONY: format
format:
$(python) -m black .
.PHONY: local-shell
local-shell:
$(pipenv) shell
.PHONY: push
push: wheel
$(call push-python-package,$(host),$(ssh_key),$(ssh_opts),$(wheel_file))
.PHONY: push-ot3
push-ot3: sdist
$(call push-python-sdist,$(host),$(ssh_key),$(ssh_opts),$(sdist_file),"/opt/opentrons-system-server","server_utils",,,$(version_file))
$(call push-python-sdist,$(host),$(ssh_key),$(ssh_opts),$(sdist_file),"/opt/opentrons-robot-server","server_utils")