-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
64 lines (51 loc) · 2 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
NAME = {{NAME}}
PKG_DIR = src/$(NAME)
.PHONY: help
help: # Display help for all Makefile commands
@grep -E '^[a-zA-Z0-9 -]+:.*#' Makefile | sort | while read -r l; do printf "\033[1;32m$$(echo $$l | cut -f 1 -d':')\033[00m:$$(echo $$l | cut -f 2- -d'#')\n"; done
.PHONY: change-version
change-version: # Change the version of this project (requires VERSION=#.#.#)
pipenv run python3 scripts/changever.py $(VERSION)
.PHONY: build
build: # Build the package tarball and wheel
pipenv run python3 -m build .
.PHONY: setup
setup: # Setup this project's pipenv environment
pipenv install -d
.PHONY: install-self
install-self: # Install this project's python package using the pipenv's pip
pipenv run pip3 install --editable .
.PHONY: docs
docs: # Build the documentation for this package
pipenv run sphinx-apidoc -T -f -o doc $(PKG_DIR)
pipenv run sphinx-build doc/ docs/
.PHONY: clean-py
clean-py: # Clean up Python generated files
rm -rf $(PKG_DIR)/__pycache__
rm -rf src/*.egg-info
# Occassionally, this fails if a make release fails after this was run but before
# "dist/*" commited to git. Run "git add dist/*" and rerun make release.
.PHONY: clean
clean: clean-py # Remove build files - including a forced "git rm" of "dist/*"
git rm -f dist/* --ignore-unmatch
rm -rf dist
.PHONY: read-docs
read-docs: # Open the package docs locally
open docs/index.html
.PHONY: version
version: # Display the version of {{NAME}} installed in the pipenv
pipenv run python3 -m $(NAME) --version
.PHONY: release
release: change-version clean setup build docs # Build a new versioned release and push it (requires VERSION=#.#.#)
git add dist/* doc/* docs/* pyproject.toml $(PKG_DIR)/__init__.py
git commit -m "build: release v$(VERSION)"
git push
git tag -a v$(VERSION) -m "Release v$(VERSION)"
git push origin v$(VERSION)
$(MAKE) clean-py
.PHONY: tests
tests: # Run the pytest suite for this project.
pipenv run pytest tests/
.PHONY: pypi
pypi: # Upload all Python packages in "dist/" to PyPI.
pipenv run python3 -m twine upload dist/*