|
1 | | -.PHONY: test install |
| 1 | +# project metadata |
| 2 | +NAME := `python setup.py --name` |
| 3 | +FULLNAME := `python setup.py --fullname` |
| 4 | +VERSION := `python setup.py --version` |
| 5 | +BUILD := `git rev-parse --short HEAD` |
2 | 6 |
|
3 | | -install: |
4 | | - pip install . --no-index |
| 7 | +.PHONY: info help clean dist docs |
| 8 | +.DEFAULT_GOAL := help |
5 | 9 |
|
6 | | -uninstall: |
7 | | - pip uninstall jsonpath |
| 10 | +define PRINT_HELP_PYSCRIPT |
| 11 | +import re, sys |
8 | 12 |
|
9 | | -test: |
10 | | - pytest test -vv -s |
| 13 | +for line in sys.stdin: |
| 14 | + match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line) |
| 15 | + if match: |
| 16 | + target, help = match.groups() |
| 17 | + print("%-20s %s" % (target, help)) |
| 18 | +endef |
| 19 | +export PRINT_HELP_PYSCRIPT |
11 | 20 |
|
| 21 | +info: ## project info |
| 22 | + @echo $(FULLNAME) at $(BUILD) |
12 | 23 |
|
13 | | -PYCACHE_DIR := $(shell find . -name '__pycache__' -type d) |
14 | | -PYTEST_DIR := $(shell find . -name '.pytest_cache' -type d) |
15 | | -EGG_DIR := $(shell find . -name '*.egg-info' -type d) |
| 24 | +help: |
| 25 | + @python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST) |
16 | 26 |
|
17 | | -clean: |
18 | | - rm -rf $(PYCACHE_DIR) ${PYTEST_DIR} ${EGG_DIR} dist |
| 27 | +clean: clean-build clean-pyc ## remove all build, test, coverage and Python artifacts |
19 | 28 |
|
20 | | -package: clean |
| 29 | +clean-build: ## remove build artifacts |
| 30 | + rm -fr build/ |
| 31 | + rm -fr dist/ |
| 32 | + rm -fr .eggs/ |
| 33 | + find . -name '*.egg-info' -exec rm -fr {} + |
| 34 | + find . -name '*.egg' -exec rm -f {} + |
| 35 | + |
| 36 | +clean-pyc: ## remove Python file artifacts |
| 37 | + find . -name '*.pyc' -exec rm -f {} + |
| 38 | + find . -name '*.pyo' -exec rm -f {} + |
| 39 | + find . -name '*~' -exec rm -f {} + |
| 40 | + find . -name '__pycache__' -exec rm -fr {} + |
| 41 | + |
| 42 | +lint: ## check style with black |
| 43 | + find $(NAME) -name '*.py' -type f -not -path "*/pb/*" -not -path "*/data/*" -exec black {} + |
| 44 | + |
| 45 | +docs: ## format docs |
| 46 | + doctoc --gitlab README.md |
| 47 | + |
| 48 | +install: ## install the package to the active Python's site-packages |
| 49 | + pip install . -U --no-index |
| 50 | + |
| 51 | +uninstall: ## uninstall the package |
| 52 | + pip uninstall $(NAME) |
| 53 | + |
| 54 | +dist: clean ## package |
21 | 55 | python3 setup.py sdist bdist_wheel |
22 | 56 |
|
23 | | -upload: package |
| 57 | +upload: dist # upload the package to pypi |
24 | 58 | twine upload dist/* |
0 commit comments