Debian Codegraph @

Makefile

raw
1 # This Makefile runs tests and builds the package to upload to pypi
2 # To use this Makefile, pip install py-make
3 # You also need to pip install also other required modules: `pip install flake8 nose coverage twine pytest pytest-cov`
4 # 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.
5 # Then, cd to this folder, and type `pymake -p` to list all commands, then `pymake <command>` to run the related entry.
6 # To test on multiple Python versions, install them, install also the C++ redistributables for each (so that Cython works), and then type `pymake testtox`.
7 # 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/
8 # for Python 3.10, read the updated instructions at: https://wiki.python.org/moin/WindowsCompilers
9
10 .PHONY:
11 alltests
12 all
13 flake8
14 test
15 testsetup
16 testsetuppost
17 testcoverage
18 testtox
19 distclean
20 coverclean
21 prebuildclean
22 clean
23 toxclean
24 installdev
25 install
26 build
27 buildupload
28 pypi
29 help
30
31 help:
32 @+make -p
33
34 alltests:
35 @+make test
36 @+make flake8
37 @+make testsetup
38
39 all:
40 @+make alltests
41 @+make build
42
43 flake8:
44 @+flake8 -j 8 --count --statistics --exit-zero .
45
46 test:
47 # Build the Cython extension
48 python setup.py build_ext --inplace
49 # Run the tests
50 python -m unittest discover tests
51
52 testnobinary:
53 # Run the tests
54 python -m unittest discover tests
55 #pytest --cov-branch
56
57 testnose:
58 nosetests -vv --with-coverage
59
60 testtox:
61 # Test for multiple Python versions
62 tox --skip-missing-interpreters -p all
63
64 testsetup:
65 python setup.py check --metadata --restructuredtext --strict
66
67 testsetuppost:
68 twine check "dist/*"
69
70 testcoverage:
71 # This is the preferred way to run the tests since Python 3.10
72 @+make coverclean
73 # Build the Cython extension
74 #python setup.py build_ext --inplace --cythonize # unnecessary to call build_ext --inplace now
75 python setup.py develop --cythonize
76 # Run the tests
77 # nosetests reedsolo --with-coverage --cover-package=reedsolo --cover-erase --cover-min-percentage=80 -d -v
78 # With PyTest, it is now necessary to first install the python module so that it is found (--cov=<module>)
79 #python setup.py develop
80 #pytest --cov-report term-missing --cov-config=.coveragerc --cov=. tests/ --cov-branch
81 #python setup.py develop --uninstall
82 coverage run --branch -m pytest . -v
83 coverage report -m
84
85
86 distclean:
87 @+make coverclean
88 @+make prebuildclean
89 @+make clean
90 @+make toxclean
91 prebuildclean:
92 @+python -c "import shutil; shutil.rmtree('build', True)"
93 @+python -c "import shutil; shutil.rmtree('dist', True)"
94 @+python -c "import shutil; shutil.rmtree('reedsolo.egg-info', True)"
95 coverclean:
96 @+python -c "import os; os.remove('.coverage') if os.path.exists('.coverage') else None"
97 @+python -c "import shutil; shutil.rmtree('__pycache__', True)"
98 @+python -c "import shutil; shutil.rmtree('tests/__pycache__', True)"
99 clean:
100 @+python -c "import os, glob; [os.remove(i) for i in glob.glob('*.py[co]')]"
101 @+python -c "import os, glob; [os.remove(i) for i in glob.glob('tests/*.py[co]')]"
102 toxclean:
103 @+python -c "import shutil; shutil.rmtree('.tox', True)"
104
105
106 installdev:
107 @+python setup.py develop --uninstall
108 @+python setup.py develop
109
110 install:
111 @+python setup.py install
112
113 build:
114 @+make prebuildclean
115 @+make testsetup
116 @+python setup.py sdist bdist_wheel
117 # @+python setup.py bdist_wininst
118 pymake testsetuppost # @+make does not work here, dunno why
119
120 pypi:
121 twine upload dist/*
122
123 buildupload:
124 @+make build
125 @+make pypi