-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
175 lines (148 loc) · 6.14 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
SHELL := /bin/bash
# If specified, open pdb on uncaught exception
DEBUG?=
# If specified, use a different python command
PY?=python3
# Unless specified otherwise, install python modules as user
USER_FLAG?=--user
# If specified, use a different command for pip
PIP?=$(PY) -m pip
# Unless specified otherwise, perform code coverage analysis
COV?=true
# Unless specified otherwise, run a linter. Also accepts only to run only linting and type-checking, disable code coverage
LINT?=true
# Unless specified otherwise, perform type-checking
MYPY?=true
# If specified, perform benchmarking (WARNING: silently disables code coverage)
BENCHMARK?=false
pytest_args?= -vl
ifeq ($(BENCHMARK),true)
pytest_args += --benchmark-min-time=0.05 --benchmark-sort=fullname --benchmark-group-by=fullfunc --benchmark-verbose
COV=false
endif
ifneq ($(LINT),false)
pytest_args += --flake8 --isort --pydocstyle
endif
ifeq ($(LINT),only)
pytest_args += --ignore=./ManifoldMarketManager/test --ignore=./ManifoldMarketManager/PyManifold/tests
COV=false
endif
ifneq ($(MYPY),false)
pytest_args += --mypy --mypy-ignore-missing-imports
endif
ifneq ($(COV),false)
pytest_args += --cov=ManifoldMarketManager --cov-branch --cov-report=term
endif
ifneq ($(https_proxy), )
PROXY_ARG=--proxy=$(https_proxy)
else
ifneq ($(http_proxy), )
PROXY_ARG=--proxy=$(http_proxy)
else
PROXY_ARG=
endif
endif
.PHONY: test
# Run tests sequentially
test: dependencies _test
.PHONY: test_all_%
# Run tests in parallel in all supported python versions
test_all_%:
@$(MAKE) test LINT=only $(MFLAGS)
@if command -v python3.8 &> /dev/null; then $(MAKE) test_$* PY=python3.8 LINT=false MYPY=false $(MFLAGS); else echo "Python 3.8 is not installed - skipping"; fi
@if command -v python3.9 &> /dev/null; then $(MAKE) test_$* PY=python3.9 LINT=false MYPY=false $(MFLAGS); else echo "Python 3.9 is not installed - skipping"; fi
@if command -v python3.10 &> /dev/null; then $(MAKE) test_$* PY=python3.10 LINT=false MYPY=false $(MFLAGS); else echo "Python 3.10 is not installed - skipping"; fi
@if command -v python3.11 &> /dev/null; then $(MAKE) test_$* PY=python3.11 LINT=false MYPY=false $(MFLAGS); else echo "Python 3.11 is not installed - skipping"; fi
.PHONY: test_all
# Run tests sequentially in all supported python versions
test_all:
@$(MAKE) test LINT=only $(MFLAGS)
@if command -v python3.8 &> /dev/null; then $(MAKE) test PY=python3.8 LINT=false MYPY=false $(MFLAGS); else echo "Python 3.8 is not installed - skipping"; fi
@if command -v python3.9 &> /dev/null; then $(MAKE) test PY=python3.9 LINT=false MYPY=false $(MFLAGS); else echo "Python 3.9 is not installed - skipping"; fi
@if command -v python3.10 &> /dev/null; then $(MAKE) test PY=python3.10 LINT=false MYPY=false $(MFLAGS); else echo "Python 3.10 is not installed - skipping"; fi
@if command -v python3.11 &> /dev/null; then $(MAKE) test PY=python3.11 LINT=false MYPY=false $(MFLAGS); else echo "Python 3.11 is not installed - skipping"; fi
.PHONY: test_%
# Run tests with a given number of parallel runners
test_%:
@$(MAKE) test pytest_args="$(pytest_args) -n$*" $(MFLAGS)
.PHONY: _test
_test:
@source env_personal.sh && ManifoldMarketManager_NO_CACHE=1 PYTHONPATH=${PYTHONPATH}:./ManifoldMarketManager/PyManifold $(PY) -m pytest ManifoldMarketManager $(pytest_args) -k 'not mypy-status' --ignore=./ManifoldMarketManager/test/manifold
.PHONY: dependencies
ifeq ($(MYPY),true)
# Load dependencies from pypi
dependencies:
@$(PIP) install -r requirements.txt $(USER_FLAG) $(PROXY_ARG)
else
dependencies:
@cat requirements.txt | grep -v "mypy" > .requirements.txt
@$(PIP) install -r .requirements.txt $(USER_FLAG) $(PROXY_ARG)
endif
.PHONY: run_%
# Run a specific account
run_%: LICENSE dependencies
@source env_$*.sh && $(PY) -O -m ManifoldMarketManager run
.PHONY: run
# Run all known accounts
run:
@$(MAKE) run_bot run_personal $(MFLAGS)
.PHONY: daemon
# Run all known accounts in a loop
daemon:
@./daemon.sh
.PHONY: quiet_daemon
# Run all known accounts in a loop (quietly)
quiet_daemon:
@while [ 1 ]; do\
$(MAKE) run $(MFLAGS);\
sleep 21600;\
done;
.PHONY: build
# Build a package
build: dependencies clean LICENSE
@$(PIP) install build
@$(PY) -m build
.PHONY: clean
# Clean up after a build
clean:
@rm -rf build dist logs .benchmarks .pytest_cache ManifoldMarketManager/*.egg-info test-reporter-latest-linux-amd64 .coverage .requirements.txt coverage.xml
@cd docs && $(MAKE) clean $(MFLAGS)
@mkdir logs
.PHONY: publish
# Publish new version to pypi
publish: build test_all upload_coverage
@$(PY) -m twine upload -u gappleto97 -s --sign-with gpg2 dist/*
@$(MAKE) clean $(MFLAGS)
.PHONY: graph
# Build a dependency graph of this package
graph: dependencies
@$(PIP) install pydeps $(USER_FLAG)
@PYTHONPATH=${PYTHONPATH}:./ManifoldMarketManager/PyManifold $(PY) -m pydeps --noshow --cluster -x ManifoldMarketManager.test pytest --max-bacon 100 -T png ManifoldMarketManager
.PHONY: import_%
# Create one or more markets from example.json and add them to the specified account
import_%: LICENSE dependencies
@source env_$*.sh && $(PY) example_json.py
.PHONY: upload_coverage
# Upload coverage reports to codeclimate
upload_coverage: .coverage
@coverage xml
@python -m coverage xml
@if [ ! -f ./test-reporter-latest-linux-amd64 ]; then wget https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64; chmod +x ./test-reporter-latest-linux-amd64; fi
@./test-reporter-latest-linux-amd64 after-build -t coverage.py -r eb0fb76d1b07b8f58d16c2ccd2ef6f9d2483faa25650522e6313f6564a6d0351
.PHONY: exe
# Make a PyInstaller exe (status: not yet supported)
exe:
$(PYTHON) -m pip install -r requirements.txt --user
$(PYTHON) -OO -m PyInstaller -F -n "research_bundle" $(ENTRY) --add-data ManifoldMarketManager/defaults:ManifoldMarketManager/defaults
.PHONY: html
# Make html docs (status: beta)
html:
cd docs && $(MAKE) html $(MFLAGS)
.PHONY: help
# Show this help.
help:
@echo Variables:
@awk '/^#/{c=substr($$0,3);next}c&&/^[[:alpha:]][[:alnum:]_]+\??=/{print substr($$1,1,index($$1,"?")),c}1{c=0}' $(MAKEFILE_LIST) | column -s? -t
@echo
@echo Commands:
@awk '/^#/{c=substr($$0,3);next}c&&/^[[:alpha:]][[:alnum:]_%%-]+:/{print substr($$1,1,index($$1,":")),c}1{c=0}' $(MAKEFILE_LIST) | column -s: -t