| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
export PACKAGE_NAME=fpyutils |
| 23 |
|
| 24 |
|
| 25 |
|
| 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 |