-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathMakefile
95 lines (66 loc) · 1.6 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
VENV=venv
PIP?=pip
MODULES=qiskit_alice_bob_provider tests
BUILD_DIR=dist
BASE_URL=
API_KEY=
ifeq ($(OS),Windows_NT)
ACTIVATE=$(VENV)/Scripts/activate
PYTHON3_PATH=$(cmd which python3 2> nul)
else
ACTIVATE=$(VENV)/bin/activate
PYTHON3_PATH=$(shell which python3 2> /dev/null)
endif
ifeq ($(PYTHON3_PATH),)
PYTHON=python
else
PYTHON=python3
endif
#### Virtual environment
$(VENV):
$(PYTHON) -m venv $(VENV)
install: $(VENV)
. $(ACTIVATE) && $(PIP) install -e .[dev]
clear:
rm -rf $(VENV)
#### Formatting
_black:
. $(ACTIVATE) && black $(MODULES)
_isort:
. $(ACTIVATE) && isort $(MODULES)
_single_quotes:
. $(ACTIVATE) && \
pre-commit run --all-files double-quote-string-fixer
format: _black _isort _single_quotes
#### Linting
_check_black:
. $(ACTIVATE) && black --check $(MODULES)
_check_isort:
. $(ACTIVATE) && isort --check-only $(MODULES)
_flake8:
. $(ACTIVATE) && flake8 $(MODULES)
_pylint:
. $(ACTIVATE) && pylint $(MODULES)
_mypy:
. $(ACTIVATE) && mypy $(MODULES)
lint: _check_black _check_isort _mypy _flake8 _pylint
#### Tests
unit-tests:
. $(ACTIVATE) && pytest tests/
integration-tests:
. $(ACTIVATE) && pytest --base-url=$(BASE_URL) \
--api-key=$(API_KEY) tests/
coverage:
. $(ACTIVATE) \
&& coverage run --omit='tests/*' -m pytest tests/ \
&& coverage html \
&& open htmlcov/index.html
test: lint unit-tests
#### Build
build: install
rm -rf $(BUILD_DIR)
. $(ACTIVATE) && python -m build -o $(BUILD_DIR)
test-publish: build
. $(ACTIVATE) && python -m twine upload -r testpypi dist/*
publish: build
. $(ACTIVATE) && python -m twine upload dist/*