|
1 | | -LANG=en_US.UTF-8 |
| 1 | +# This file is generated from sphinx-notes/cookiecutter. |
| 2 | +# You need to consider modifying the TEMPLATE or modifying THIS FILE. |
2 | 3 |
|
3 | | -MAKE = make |
4 | | -PY = python3 |
5 | | -RM = rm -rf |
| 4 | +LANG = en_US.UTF-8 |
6 | 5 |
|
7 | | -.PHONY: doc |
8 | | -doc: |
9 | | - $(RM) doc/_build |
10 | | - $(MAKE) -C doc/ |
| 6 | +MAKE = make |
| 7 | +PY = python3 |
| 8 | +RM = rm -rf |
| 9 | +GIT = git |
| 10 | +OPEN = xdg-open |
11 | 11 |
|
12 | | -.PHONY: dist |
13 | | -dist: setup.py |
14 | | - $(RM) dist/ build/ *.egg-info/ |
15 | | - $(PY) setup.py sdist bdist_wheel |
16 | | - $(PY) -m twine check dist/* |
| 12 | +.PHONY: docs |
| 13 | +docs: |
| 14 | + $(MAKE) -C docs/ |
17 | 15 |
|
18 | | -.PHONY: upload |
19 | | -upload: dist/ |
20 | | - $(PY) -m twine upload --repository pypi $<* |
| 16 | +.PHONY: view |
| 17 | +view: |
| 18 | + $(OPEN) docs/_build/html/index.html |
| 19 | + |
| 20 | +.PHONY: clean |
| 21 | +clean: |
| 22 | + $(MAKE) -C docs/ clean; $(RM) dist/ |
| 23 | + |
| 24 | +.PHONY: fmt |
| 25 | +fmt: |
| 26 | + ruff format src/ && ruff check --fix src/ |
| 27 | + |
| 28 | +.PHONY: test |
| 29 | +test: |
| 30 | + $(PY) -m unittest discover -s tests -v |
| 31 | + |
| 32 | +################################################################################ |
| 33 | +# Distribution Package |
| 34 | +################################################################################ |
| 35 | + |
| 36 | +# Build distribution package, for "install" or "upload". |
| 37 | +.PHONY: dist |
| 38 | +dist: pyproject.toml clean |
| 39 | + $(PY) -m build |
21 | 40 |
|
| 41 | +# Install distribution package to user directory. |
| 42 | +# |
| 43 | +# NOTE: It may breaks your system-level packages, use at your own risk. |
22 | 44 | .PHONY: install |
23 | 45 | install: dist |
| 46 | + export PIP_BREAK_SYSTEM_PACKAGES=1 # required by Python 3.11+, see PEP-668 |
24 | 47 | $(PY) -m pip install --user --no-deps --force-reinstall dist/*.whl |
25 | 48 |
|
26 | | -.PHONY: test |
27 | | -test: tests |
28 | | - $(PY) -m unittest discover -s tests -v |
| 49 | +# Publish wheel to PyPI offical server <https://pypi.org/> when you want to |
| 50 | +# You should have a PyPI account and have PyPI token configured. |
| 51 | +# |
| 52 | +# See also https://packaging.python.org/en/latest/tutorials/packaging-projects/#uploading-the-distribution-archives |
| 53 | +.PHONY: upload |
| 54 | +upload: dist |
| 55 | + $(PY) -m twine upload --repository pypi $</* |
| 56 | + |
| 57 | +################################################################################ |
| 58 | +# Cookiecutter Incremental Updates |
| 59 | +################################################################################ |
| 60 | + |
| 61 | +# Keep up to date with the latest template. |
| 62 | +# See https://github.com/sphinx-notes/cookiecutter. |
| 63 | +.PHONY: tmpl-update tmpl-update-done tmpl-apply-rej |
| 64 | + |
| 65 | +tmpl-update: |
| 66 | + $(PY) -m cruft update |
| 67 | + |
| 68 | +tmpl-update-done: |
| 69 | + $(GIT) commit -m "chore: Update project template to sphinx-notes/cookiecutter@$(shell jq -r '.commit' .cruft.json | head -c8)" |
| 70 | + |
| 71 | +tmpl-apply-rej: |
| 72 | + @for rej in $$(find . -name '*.rej'); do \ |
| 73 | + echo "applying $$rej..."; \ |
| 74 | + wiggle --replace $${rej%.rej} $$rej; \ |
| 75 | + done |
| 76 | + |
| 77 | +# Update project version. |
| 78 | +.PHONY: bump-version bump-version-done |
| 79 | + |
| 80 | +bump-version: |
| 81 | + @echo -n "Please enter the version to bump: " |
| 82 | + @read version && $(PY) -m cruft update --variables-to-update "{ \"version\" : \"$$version\" }" |
| 83 | + |
| 84 | +bump-version-done: |
| 85 | + VERSION=$(shell jq -r '.context.cookiecutter.version' .cruft.json); \ |
| 86 | + $(GIT) commit -m "chore: Bump version to $$VERSION"; \ |
| 87 | + $(GIT) tag $$VERSION |
| 88 | + |
| 89 | + |
| 90 | +################################################################################ |
| 91 | +# CUSTOM TARGETS |
| 92 | +################################################################################ |
0 commit comments