Debian Codegraph @

Makefile

raw symbols SCIP
1 #
2 # Makefile
3 #
4 # Copyright (C) 2017-2022 Franco Masotti (franco \D\o\T masotti {-A-T-} tutanota \D\o\T com)
5 #
6 # This file is part of fpyutils.
7 #
8 # fpyutils is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
12 #
13 # fpyutils is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with fpyutils. If not, see <http://www.gnu.org/licenses/>.
20 #
21
22 export PACKAGE_NAME=fpyutils
23
24 # See
25 # https://docs.python.org/3/library/venv.html#how-venvs-work
26 export VENV_CMD=. .venv/bin/activate
27
28 default: install-dev
29
30 doc:
31 $(VENV_CMD) \
32 && $(MAKE) -C docs html \
33 && $(MAKE) -C docs latexpdf \
34 && deactivate
35
36 install:
37 # pip 23 introduced the '--break-system-packages' option.
38 python3 -c 'import pip; import sys; sys.exit(0) if int(pip.__version__.split(".")[0]) >= 23 else sys.exit(1)' \
39 && pip3 install --break-system-packages . --user \
40 || pip3 install . --user
41
42 uninstall:
43 # pip 23 introduced the '--break-system-packages' option.
44 python3 -c 'import pip; import sys; sys.exit(0) if int(pip.__version__.split(".")[0]) >= 23 else sys.exit(1)' \
45 && pip3 uninstall --break-system-packages --verbose --yes $(PACKAGE_NAME) \
46 || pip3 uninstall --verbose --yes $(PACKAGE_NAME)
47
48 install-dev:
49 python3 -m venv .venv
50 $(VENV_CMD) \
51 && pip install --requirement requirements-freeze.txt \
52 && deactivate
53 $(VENV_CMD) \
54 && pre-commit install \
55 && deactivate
56 $(VENV_CMD) \
57 && pre-commit install --hook-type commit-msg \
58 && deactivate
59
60 regenerate-freeze: uninstall-dev
61 python3 -m venv .venv
62 $(VENV_CMD) \
63 && pip install --requirement requirements.txt --requirement requirements-dev.txt \
64 && pip freeze --local > requirements-freeze.txt \
65 && deactivate
66
67 uninstall-dev:
68 rm -rf .venv
69
70 update: install-dev
71 $(VENV_CMD) \
72 && pre-commit autoupdate \
73 --repo https://github.com/pre-commit/pre-commit-hooks \
74 --repo https://github.com/PyCQA/bandit \
75 --repo https://github.com/pycqa/isort \
76 --repo https://codeberg.org/frnmst/md-toc \
77 --repo https://github.com/mgedmin/check-manifest \
78 --repo https://github.com/jorisroovers/gitlint \
79 && deactivate
80
81 test:
82 $(VENV_CMD) \
83 && tox run-parallel \
84 && deactivate
85
86 pre-commit:
87 $(VENV_CMD) \
88 && pre-commit run --all \
89 && deactivate
90
91 dist:
92 # Create a reproducible archive at least on the wheel.
93 # See
94 # https://bugs.python.org/issue31526
95 # https://bugs.python.org/issue38727
96 # https://github.com/pypa/setuptools/issues/1468
97 # https://github.com/pypa/setuptools/issues/2133
98 # https://reproducible-builds.org/docs/source-date-epoch/
99 $(VENV_CMD) \
100 && SOURCE_DATE_EPOCH=$$(git -c log.showSignature='false' log -1 --pretty=%ct) \
101 python -m build \
102 && deactivate
103 $(VENV_CMD) \
104 && twine check --strict dist/* \
105 && deactivate
106
107 upload:
108 $(VENV_CMD) \
109 && twine upload dist/* \
110 && deactivate
111
112 clean:
113 rm -rf build dist *.egg-info tests/benchmark-results
114 # Remove all markdown files except the readmes.
115 find -regex ".*\.[mM][dD]" ! -name 'README.md' ! -name 'CONTRIBUTING.md' -type f -exec rm -f {} +
116 $(VENV_CMD) \
117 && $(MAKE) -C docs clean \
118 && deactivate
119
120 .PHONY: default doc install uninstall install-dev uninstall-dev update test clean demo pre-comit