forked from barrettfdavis/online_actogram
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
136 lines (116 loc) · 4.26 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
# This Makefile runs tests and builds the package to upload to pypi
# To use this Makefile, pip install py3make
# then do: py3make <command>
# You also need to pip install also other required modules: `pip install --editable .[test]`
# 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.
# Then, cd to this folder, and type `webactogram -p` to list all commands, then `webactogram <command>` to run the related entry.
# To test on multiple Python versions, install them, install also the C++ redistributables for each (so that Cython works), and then type `webactogram testtox`.
# 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!)
#
# IMPORTANT: for compatibility with `python setup.py make [alias]`, ensure:
# 1. Every alias is preceded by @[+]make (eg: @make alias)
# 2. A maximum of one @make alias or command per line
.PHONY:
alltests
all
flake8
test
testnose
testsetup
testcoverage
testtimer
distclean
coverclean
prebuildclean
clean
toxclean
installdev
install
build
buildupload
upload
help
none
run
help:
@+make -p
alltests:
@+make testcoverage
@+make flake8
@+make testsetup
all:
@+make alltests
@+make build
flake8:
@+flake8 -j 8 --count --statistics --exit-zero .
test:
tox --skip-missing-interpreters
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
@+make installdev
# Run the tests
# With PyTest, it is now necessary to first install the python module so that it is found (--cov=<module>)
coverage run --branch -m pytest -v
coverage report -m
testcoveragexdist:
# This parallelizes tests to make them run faster, thanks to pytest-xdist
@+make coverclean
@+make installdev
# Run the tests
# With PyTest, it is now necessary to first install the python module so that it is found (--cov=<module>)
coverage run --branch -m pytest -n auto -v
#coverage report -m # cannot send a report from parallelized xdist
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('webactogram.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/webactogram.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] --verbose --use-pep517
install:
@+make prebuildclean
@+python -m pip install --upgrade . --verbose --use-pep517
bandit:
bandit webactogram/*
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
@+make testsetuppost
upload:
twine upload dist/*
buildupload:
@+make build
@+make upload
none:
# used for unit testing
run:
python -Om webactogram