-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
188 lines (159 loc) · 7.2 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
.PHONY: clean clean-test clean-pyc clean-build docs help local_testnets
.DEFAULT_GOAL := help
define BROWSER_PYSCRIPT
import os, webbrowser, sys
try:
from urllib import pathname2url
except:
from urllib.request import pathname2url
webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1])))
endef
export BROWSER_PYSCRIPT
define PRINT_HELP_PYSCRIPT
import re, sys
for line in sys.stdin:
match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line)
if match:
target, help = match.groups()
print("%-20s %s" % (target, help))
endef
export PRINT_HELP_PYSCRIPT
BROWSER := python -c "$$BROWSER_PYSCRIPT"
ifndef AERGO_TYPES_SRC
TYPES_SRC := $(GOPATH)/src/github.com/aergoio/aergo/config/types.go
else
TYPES_SRC := $(AERGO_TYPES_SRC)
endif
help:
@python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)
clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts
clean-all: clean clean_local_testnets ## remove all including docker data
clean-build: ## remove build artifacts
rm -fr build/
rm -fr dist/
rm -fr .eggs/
find . -name '*.egg-info' -exec rm -fr {} +
find . -name '*.egg' -exec rm -rf {} +
clean-pyc: ## remove Python file artifacts
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +
find . -name '__pycache__' -exec rm -fr {} +
clean-test: ## remove test and coverage artifacts
rm -fr .tox/
rm -f .coverage
rm -fr htmlcov/
rm -fr .pytest_cache
rm -f coverage.xml
lint: ## check style with flake8
# ignore W503 as it will be considered best practice
flake8 \
--exclude=*_pb2_grpc.py,*_pb2.py,aergo_conf.py \
--ignore=W503 \
--per-file-ignores="__init__.py:F401" \
aergo tests
test: ## run tests quickly with the default Python
pytest -s
test-all: ## run tests on every Python version with tox
tox
coverage: ## check code coverage quickly with the default Python
pytest --cov-report=html --cov=aergo/ tests/
release: dist ## package and upload a release
twine upload dist/*
dist: clean ## builds source and wheel package
python setup.py sdist
python setup.py bdist_wheel
ls -l dist
install: clean ## install the package to the active Python's site-packages
python setup.py install
# Updating requirements.txt and requirements_dev.txt:
# pipenv lock -r > requirements.txt
# pipenv lock --dev -r > requirements_dev.txt
uninstall: ## uninstall the package in the active Python's site-packages
pip uninstall aergo-herapy -y
protoc: ## generate *_pb2.py and *_pb2_grpc.py in aergo/herapy/grpc from aergo-protobuf/proto/*.proto
python -m grpc_tools.protoc \
-I./aergo-protobuf/proto \
--python_out=./aergo/herapy/grpc \
--grpc_python_out=./aergo/herapy/grpc \
./aergo-protobuf/proto/*.proto
find ./aergo/herapy/grpc -type f -name '*_pb2.py' -exec sed -i '' -e 's/^import\(.*\)_pb2\(.*\)$$/from . import\1_pb2\2/g' {} \;
find ./aergo/herapy/grpc -type f -name '*_pb2_grpc.py' -exec sed -i '' -e 's/^import\(.*\)_pb2\(.*\)$$/from . import\1_pb2\2/g' {} \;
protoclean: ## remove all generated files in aergo/herapy/grpc by 'make protoc'
rm -f aergo/herapy/grpc/*_pb2*.py
aergo-types: ## generate aergo/herapy/obj/aergo_conf.py from github.com/aergoio/aergo/config/types.go
ifneq ($(wildcard $(TYPES_SRC)), )
python ./scripts/generate_aergo_conf.py $(TYPES_SRC) ./scripts/aergo_default_conf.toml > ./aergo/herapy/obj/aergo_conf.py
else
@echo "ERROR: Cannot find 'AERGO_TYPES_SRC':" $(TYPES_SRC)
endif
local_testnets:
docker-compose -f ./local_test_nodes/docker-compose.yml up
clean_local_testnets:
docker-compose -f ./local_test_nodes/docker-compose.yml down
rm -fr ./local_test_nodes/*/data
mypy:
mypy -p aergo -p tests
ex: ## run all examples in the examples directory
pip show aergo-herapy
@echo "===============================" > make.ex.out
@echo "Result of 'examples/account.py'" >> make.ex.out
@echo "===============================" >> make.ex.out
@echo "Run ... 'examples/account.py'"
@python ./examples/account.py > make.ex.out
@echo "=======================================" >> make.ex.out
@echo "Result of 'examples/account_exp_imp.py'" >> make.ex.out
@echo "=======================================" >> make.ex.out
@echo "Run ... 'examples/account_exp_imp.py'"
@python ./examples/account_exp_imp.py >> make.ex.out
@echo "=====================================" >> make.ex.out
@echo "Result of 'examples/account_proof.py'" >> make.ex.out
@echo "=====================================" >> make.ex.out
@echo "Run ... 'examples/account_proof.py'"
@python ./examples/account_proof.py >> make.ex.out
@echo "==================================" >> make.ex.out
@echo "Result of 'examples/blockchain.py'" >> make.ex.out
@echo "==================================" >> make.ex.out
@echo "Run ... 'examples/blockchain.py'"
@python ./examples/blockchain.py >> make.ex.out
@echo "=========================================" >> make.ex.out
@echo "Result of 'examples/blockchain_stream.py'" >> make.ex.out
@echo "=========================================" >> make.ex.out
@echo "Run ... 'examples/blockchain_stream.py'"
@python ./examples/blockchain_stream.py >> make.ex.out
@echo "=====================================" >> make.ex.out
@echo "Result of 'examples/smartcontract.py'" >> make.ex.out
@echo "=====================================" >> make.ex.out
@echo "Run ... 'examples/smartcontract.py'"
@python ./examples/smartcontract.py >> make.ex.out
@echo "=========================================" >> make.ex.out
@echo "Result of 'examples/smartcontract_event.py'" >> make.ex.out
@echo "=========================================" >> make.ex.out
@echo "Run ... 'examples/smartcontract_event.py'"
@python ./examples/smartcontract_event.py >> make.ex.out
@echo "=========================================" >> make.ex.out
@echo "Result of 'examples/smartcontract_event_stream.py'" >> make.ex.out
@echo "=========================================" >> make.ex.out
@echo "Run ... 'examples/smartcontract_event_stream.py'"
@python ./examples/smartcontract_event_stream.py >> make.ex.out
@echo "================================================" >> make.ex.out
@echo "Result of 'examples/smartcontract_batch_call.py'" >> make.ex.out
@echo "================================================" >> make.ex.out
@echo "Run ... 'examples/smartcontract_batch_call.py'"
@python ./examples/smartcontract_batch_call.py >> make.ex.out
@echo "===========================================" >> make.ex.out
@echo "Result of 'examples/smartcontract_query.py'" >> make.ex.out
@echo "===========================================" >> make.ex.out
@echo "Run ... 'examples/smartcontract_query.py'"
@python ./examples/smartcontract_query.py >> make.ex.out
@echo "===================================" >> make.ex.out
@echo "Result of 'examples/transaction.py'" >> make.ex.out
@echo "===================================" >> make.ex.out
@echo "Run ... 'examples/transaction.py'"
@python ./examples/transaction.py >> make.ex.out
@echo "=========================================" >> make.ex.out
@echo "Result of 'examples/transaction_batch.py'" >> make.ex.out
@echo "=========================================" >> make.ex.out
@echo "Run ... 'examples/transaction_batch.py'"
@python ./examples/transaction_batch.py >> make.ex.out
@echo "See 'make.ex.out' to check the results"