forked from tomerfiliba-org/reedsolomon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
179 lines (155 loc) · 6.88 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
# This Makefile runs tests and builds the package to upload to pypi
# To use this Makefile, pip install py3make
# then cd to this folder, and do: py3make <command>
# or: python.exe -m py3make <command>
# You can also type `py3make -p` to list all commands, then `py3make <command>` to run the related entry.
# You also need to pip install also other required modules: `pip install flake8 coverage twine pytest pytest-cov validate-pyproject[all] pytest-xdist rstcheck` , or simply `pip install --editable .[test,testmeta]`
# Up to Python 3.9 included, nosetests was used, but from 3.10 onward, support for it was dropped since it is not maintained anymore, so that pytest and pytest-cov are used instead.
# To test on multiple Python versions, install them, install also the C++ redistributables for each (so that Cython works), and then type `pymake testtox`.
# To pymake buildupload (deploy on pypi), you need to `pip install cython` and install a C++ compiler, on Windows and with Python 3.7 you need Microsoft Visual C++ 14.0. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/fr/visual-cpp-build-tools/
# for Python 3.10, read the updated instructions at: https://wiki.python.org/moin/WindowsCompilers
# CRITICAL NOTE: if you get a "FileNotFoundError" exception when trying to call @+python or @+make, then it is because you used spaces instead of a hard TAB character to indent! TODO: bugfix this. It happens only for @+ commands and for those after the first command (if the @+ command with spaces as indentation is the first and only statement in a command, it works!)
.PHONY:
alltests
all
flake8
test
testsetup
testpyproject
testsetuppost
testcoverage
testtox
distclean
coverclean
prebuildclean
clean
toxclean
installdev
install
build
buildupload
pypi
help
help:
@+make -p
alltests:
@+make test
@+make flake8
@+make testsetup
all:
@+make alltests
@+make build
flake8:
@+flake8 -j 8 --count --statistics --exit-zero .
test:
# Only for Py2
# Build the Cython extension
python setup.py build_ext --inplace
# Run the tests
@+python -m unittest discover tests
testnobinary:
# Only for Py2
# Run the tests
@+python -m unittest discover tests
#pytest --cov-branch
testnose:
# Only for Py2
@+python -m nose -vv --with-coverage
testtox:
# Test for multiple Python versions
tox --skip-missing-interpreters -p all
testsetup:
# Only for Py2
python setup.py check --metadata --restructuredtext --strict
testpyproject:
validate-pyproject pyproject.toml -v
testsetuppost:
twine check "dist/*"
testrst:
rstcheck README.rst
testcoverage:
# This is the preferred way to run the tests since Python 3.10
@+make coverclean
# Build the Cython extension and install module in editable mode
#python setup.py build_ext --inplace --cythonize # unnecessary to call build_ext --inplace now
#python -m pip install -e . --config-setting="--build-option=--cythonize"
python setup.py develop --cythonize # unfortunately much faster than current pep517 options which do not allow to only build the extension
# Run the tests
# nosetests reedsolo --with-coverage --cover-package=reedsolo --cover-erase --cover-min-percentage=80 -d -v
# With PyTest, it is now necessary to first install the python module so that it is found (--cov=<module>)
#python setup.py develop
#pytest --cov-report term-missing --cov-config=.coveragerc --cov=. tests/ --cov-branch
#python setup.py develop --uninstall
coverage run --branch -m pytest -v
coverage report -m
testcoveragexdist:
# This parallelizes tests to make them run faster, thanks to pytest-xdist
@+make coverclean
# Build the Cython extension and install module in editable mode
#python setup.py build_ext --inplace --cythonize # unnecessary to call build_ext --inplace now
#python setup.py develop --cythonize # unfortunately much faster than current pep517 options which do not allow to only build the extension
@+make installdev
# Run the tests
# nosetests reedsolo --with-coverage --cover-package=reedsolo --cover-erase --cover-min-percentage=80 -d -v
# With PyTest, it is now necessary to first install the python module so that it is found (--cov=<module>)
#python setup.py develop
#pytest --cov-report term-missing --cov-config=.coveragerc --cov=. tests/ --cov-branch
#python setup.py develop --uninstall
coverage run --branch -m pytest -n auto -v
#coverage report -m # cannot send a report from parallelized xdist
testcoveragenocython:
# This is the preferred way to run the tests since Python 3.10
@+make coverclean
# Run the tests
# nosetests reedsolo --with-coverage --cover-package=reedsolo --cover-erase --cover-min-percentage=80 -d -v
# With PyTest, it is now necessary to first install the python module so that it is found (--cov=<module>)
#python setup.py develop
#pytest --cov-report term-missing --cov-config=.coveragerc --cov=. tests/ --cov-branch
#python setup.py develop --uninstall
coverage run --branch -m pytest -v
coverage report -m
distclean:
@+make coverclean
@+make prebuildclean
@+make clean
@+make toxclean
prebuildclean:
@+python -c "import shutil; shutil.rmtree('build', True)"
@+python -c "import shutil; shutil.rmtree('dist', True)"
@+python -c "import shutil; shutil.rmtree('reedsolo.egg-info', True)"
# IMPORTANT: systematically delete `src/<project.name>.egg-info` folder before rebuilding, otherwise the list of included files will not get updated (it's in `SOURCES.txt` file in this folder)
# also very important to delete egg-info before any new build or pip install, otherwise may cause an error that multiple egg-info folders are present
@+python -c "import shutil; shutil.rmtree('src/reedsolo.egg-info', True)"
coverclean:
@+python -c "import os; os.remove('.coverage') if os.path.exists('.coverage') else None"
@+python -c "import shutil; shutil.rmtree('__pycache__', True)"
@+python -c "import shutil; shutil.rmtree('tests/__pycache__', True)"
clean:
@+python -c "import os, glob; [os.remove(i) for i in glob.glob('*.py[co]')]"
@+python -c "import os, glob; [os.remove(i) for i in glob.glob('tests/*.py[co]')]"
toxclean:
@+python -c "import shutil; shutil.rmtree('.tox', True)"
installdev:
@+make prebuildclean
@+python -m pip install --upgrade --editable .[test,testmeta] --config-setting="--build-option=--cythonize" --verbose --use-pep517
install:
@+make prebuildclean
@+python -m pip install --upgrade . --config-setting="--build-option=--cythonize" --verbose --use-pep517
bandit:
bandit reedsolo.py
build:
# requires `pip install build`
@+make testrst
@+make prebuildclean
#@+make testsetup
@+make testpyproject
# For build, do NOT use the -w flag, otherwise only the wheel will be built, but we need sdist for source distros such as Debian and Gentoo!
@+python -sBm build --config-setting="--build-option=--cythonize"
@+make testsetuppost
buildwheelhouse:
cibuildwheel --platform auto
upload:
twine upload dist/*
buildupload:
@+make build
@+make upload