-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
141 lines (115 loc) · 3.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
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
.PHONY: all environment install install-mac install-linux install-windows lint validate test test-example coverage coverage-html coverage-xml coverage-erase
CODE_COVERAGE ?= 80
WINDOWS_32BIT_GMPY2 ?= packages/gmpy2-2.0.8-cp38-cp38-win32.whl
WINDOWS_64BIT_GMPY2 ?= packages/gmpy2-2.0.8-cp38-cp38-win_amd64.whl
OS ?= $(shell python -c 'import platform; print(platform.system())')
IS_64_BIT ?= $(shell python -c 'from sys import maxsize; print(maxsize > 2**32)')
# Change these if necessary for your local platform; maybe we need to do some kind of autoconf
# to detect these things?
PIPENV = pipenv
PYTHON38 = python3.8
PIP38 = pip3.8
all: sys-dependencies environment install validate lint coverage
requirements.txt: Pipfile
$(PIP38) freeze > requirements.txt
# Generates the `typings` directory with boto3 stubs, which we commit as
# part of the repository, rather than regenerating every time.
boto3_stubs:
$(PIP38) install mypy_boto3_builder
$(PYTHON38) -m mypy_boto3_builder --installed --skip-services typings -d -s s3 ec2
environment:
@echo 🔧 PIPENV SETUP
$(PIP38) install pipenv
$(PIPENV) install --dev
sys-dependencies:
@echo 📦 Install System Dependencies
@echo Operating System identified as $(OS)
ifeq ($(OS), Linux)
make sys-dependencies-linux
endif
ifeq ($(OS), Darwin)
make sys-dependencies-mac
endif
ifeq ($(OS), Windows)
make sys-dependencies-windows
endif
ifeq ($(OS), Windows_NT)
make sys-dependencies-windows
endif
install:
@echo 📦 Install Module
@echo Operating System identified as $(OS)
ifeq ($(OS), Linux)
make install-linux
endif
ifeq ($(OS), Darwin)
make install-mac
endif
ifeq ($(OS), Windows)
make install-windows
endif
ifeq ($(OS), Windows_NT)
make install-windows
endif
sys-dependencies-mac:
@echo 🍎 MACOS DEPENDENCIES
# gmpy2 requirements
brew install gmp || true
install-mac:
@echo 🍎 MACOS INSTALL
$(PIPENV) run python -m pip install -e .
sys-dependencies-linux:
@echo 🐧 LINUX DEPENDENCIES
# gmpy2 requirements
sudo apt-get install libgmp-dev
sudo apt-get install libmpfr-dev
sudo apt-get install libmpc-dev
install-linux:
@echo 🐧 LINUX INSTALL
$(PIPENV) run python -m pip install -e .
sys-dependencies-windows:
@echo 🏁 WINDOWS DEPENDENCIES
# currently nothing?
install-windows:
@echo 🏁 WINDOWS INSTALL
ifeq ($(IS_64_BIT), True)
$(PIPENV) run python -m pip install -f $(WINDOWS_64BIT_GMPY2) -e .
endif
ifeq ($(IS_64_BIT), False)
$(PIPENV) run python -m pip install -f $(WINDOWS_32BIT_GMPY2) -e .
endif
black:
black apps src tests setup.py
lint:
@echo 💚 LINT
@echo 1.Pylint
$(PIPENV) run pylint .
@echo 2.Black Formatting
$(PIPENV) run black --check apps src tests setup.py
@echo 3.Mypy Static Typing
$(PIPENV) run mypy apps src tests setup.py
@echo 4.Package Metadata
$(PIPENV) run python setup.py check --strict --metadata --restructuredtext
# @echo 5.Docstring
# pipenv run pydocstyle
auto-lint: black lint
validate:
@echo ✅ VALIDATE
@$(PIPENV) run python -c 'import electionguard; print(electionguard.__package__ + " successfully imported")'
test:
@echo ✅ TEST
$(PIPENV) run pytest . -x
coverage:
@echo ✅ COVERAGE
$(PIPENV) run coverage run -m pytest
$(PIPENV) run coverage report --fail-under=$(CODE_COVERAGE)
coverage-html:
$(PIPENV) run coverage html -d coverage
coverage-xml:
$(PIPENV) run coverage xml
coverage-erase:
@$(PIPENV) run coverage erase
upgrade-electionguard:
$(PIPENV) uninstall electionguard
$(PIPENV) install -e 'git+https://github.com/microsoft/electionguard-python.git@feature/generic_chaum_petersen#egg=electionguard'
# pipenv install -e 'git+https://github.com/microsoft/electionguard-python.git#egg=electionguard'