|
1 | | -SRC_CORE=src |
2 | | -SRC_TEST=tests |
3 | | -SRC_RESOURCES=resources |
4 | | -PYTHON=python3 |
5 | | -PYDOC=pydoc3 |
6 | | -PIP=pip3 |
7 | | - |
8 | | - |
9 | | -help: ## Print help for each target |
10 | | - $(info Things3 low-level Python API.) |
11 | | - $(info =============================) |
12 | | - $(info ) |
13 | | - $(info Available commands:) |
14 | | - $(info ) |
15 | | - @grep '^[[:alnum:]_-]*:.* ##' $(MAKEFILE_LIST) \ |
16 | | - | sort | awk 'BEGIN {FS=":.* ## "}; {printf "%-25s %s\n", $$1, $$2};' |
17 | | - |
18 | | -run: ## Run the code |
19 | | - @$(PYTHON) $(SRC_CORE)/hello.py -f -n Foo test |
20 | | - |
21 | | -test: ## Test the code |
22 | | - @type coverage >/dev/null 2>&1 || (echo "Run '$(PIP) install coverage' first." >&2 ; exit 1) |
23 | | - @coverage run --source . -m unittest |
24 | | - @coverage report |
25 | | - @coverage html |
26 | | - |
27 | | -test_integration: ## Test the code |
28 | | - @type coverage >/dev/null 2>&1 || (echo "Run '$(PIP) install coverage' first." >&2 ; exit 1) |
29 | | - @coverage run --source . -m $(SRC_TEST).integration.test_api_integration |
30 | | - @coverage report |
31 | | - |
32 | | -doc: ## Document the code |
33 | | - @$(PYDOC) src |
34 | | - |
35 | | -clean: ## Cleanup |
36 | | - @rm -f $(SRC_CORE)/*.pyc |
37 | | - @rm -rf $(SRC_CORE)/__pycache__ |
38 | | - @rm -f $(SRC_TEST)/*.pyc |
39 | | - @rm -rf $(SRC_TEST)/__pycache__ |
40 | | - |
41 | | -auto-style: ## Style the code |
42 | | - @if type autopep8 >/dev/null 2>&1 ; then autopep8 -i -r $(SRC_CORE) ; \ |
43 | | - else echo "SKIPPED. Run '$(PIP) install autopep8' first." >&2 ; fi |
44 | | - |
45 | | -code-style: ## Test the code style |
46 | | - @if type pycodestyle >/dev/null 2>&1 ; then pycodestyle --max-line-length=80 $(SRC_CORE) ; \ |
47 | | - else echo "SKIPPED. Run '$(PIP) install pycodestyle' first." >&2 ; fi |
48 | | - |
49 | | -code-count: ## Count the lines of code |
50 | | - @if type cloc >/dev/null 2>&1 ; then cloc $(SRC_CORE) ; \ |
51 | | - else echo "SKIPPED. Run 'brew install cloc' first." >&2 ; fi |
52 | | - |
53 | | -code-lint: ## Lint the code |
54 | | - @if type pyflakes >/dev/null 2>&1 ; then pyflakes $(SRC_CORE) ; \ |
55 | | - else echo "SKIPPED. Run '$(PIP) install pyflakes' first." >&2 ; fi |
56 | | - @if type pylint >/dev/null 2>&1 ; then pylint $(SRC_CORE) ; \ |
57 | | - else echo "SKIPPED. Run '$(PIP) install pylint' first." >&2 ; fi |
58 | | - @if type flake8 >/dev/null 2>&1 ; then flake8 --max-complexity 10 $(SRC_CORE) ; \ |
59 | | - else echo "SKIPPED. Run '$(PIP) install flake8' first." >&2 ; fi |
60 | | - @if type pyright >/dev/null 2>&1 ; then pyright $(SRC_CORE) ; \ |
61 | | - else echo "SKIPPED. Run 'npm install -f pyright' first." >&2 ; fi |
62 | | - @if type mypy >/dev/null 2>&1 ; then mypy --ignore-missing-imports $(SRC_CORE) ; \ |
63 | | - else echo "SKIPPED. Run '$(PIP) install mypy' first." >&2 ; fi |
64 | | - |
65 | | -css-lint: ## Lint the CSS code |
66 | | - @if type csslint >/dev/null 2>&1 ; then csslint --format=compact $(SRC_RESOURCES)/*.css ; \ |
67 | | - else echo "SKIPPED. Run 'npm install -g csslint' first." >&2 ; fi |
68 | | - |
69 | | -js-lint: ## Lint the JavaScript code |
70 | | - @if type jslint >/dev/null 2>&1 ; then jslint $(SRC_RESOURCES)/*.js ; \ |
71 | | - else echo "SKIPPED. Run 'npm install -g jslint' first." >&2 ; fi |
72 | | - |
73 | | -html-lint: ## Lint the HTML code |
74 | | - @if type tidy >/dev/null 2>&1 ; then tidy -qe $(SRC_RESOURCES)/*.html ; \ |
75 | | - else echo "SKIPPED. Run 'brew install tidy' first." >&2 ; fi |
76 | | - |
77 | | -lint: code-style code-lint css-lint js-lint html-lint ## Run all linters |
78 | | - |
79 | | -deps-update: ## Update the dependencies |
80 | | - @if type pur >/dev/null 2>&1 ; then pur -r requirements.txt ; \ |
81 | | - else echo "SKIPPED. Run '$(PIP) install pur' first." >&2 ; fi |
82 | | - |
83 | | -deps-install: ## Install the dependencies |
84 | | - @type $(PIP) >/dev/null 2>&1 || (echo "Run 'curl https://bootstrap.pypa.io/get-pip.py|sudo python3' first." >&2 ; exit 1) |
85 | | - @$(PIP) install -r requirements.txt |
86 | | - |
87 | | -deps-create: ## Create the dependencies |
88 | | - @if type pipreqs >/dev/null 2>&1 ; then pipreqs --use-local --force . ; \ |
89 | | - else echo "SKIPPED. Run '$(PIP) install pipreqs' first." >&2 ; fi |
90 | | - |
91 | | -feedback: ## Provide feedback |
92 | | - @open https://github.com/AlexanderWillner/python-boilerplate/issues |
93 | | - |
94 | | -build: ## build project |
95 | | - python3 -m pip install --upgrade build ; \ |
96 | | - python3 -m build |
97 | | - |
98 | | -upload: |
99 | | - python3 -m twine upload dist/* |
| 1 | +SRC_CORE=src |
| 2 | +SRC_TEST=tests |
| 3 | +SRC_RESOURCES=resources |
| 4 | +PYTHON=python3 |
| 5 | +PYDOC=pydoc3 |
| 6 | +PIP=pip3 |
| 7 | + |
| 8 | + |
| 9 | +help: ## Print help for each target |
| 10 | + $(info Things3 low-level Python API.) |
| 11 | + $(info =============================) |
| 12 | + $(info ) |
| 13 | + $(info Available commands:) |
| 14 | + $(info ) |
| 15 | + @grep '^[[:alnum:]_-]*:.* ##' $(MAKEFILE_LIST) \ |
| 16 | + | sort | awk 'BEGIN {FS=":.* ## "}; {printf "%-25s %s\n", $$1, $$2};' |
| 17 | + |
| 18 | +run: ## Run the code |
| 19 | + @$(PYTHON) $(SRC_CORE)/hello.py -f -n Foo test |
| 20 | + |
| 21 | +test: ## Test the code |
| 22 | + @type coverage >/dev/null 2>&1 || (echo "Run '$(PIP) install coverage' first." >&2 ; exit 1) |
| 23 | + @coverage run --source . -m unittest |
| 24 | + @coverage report |
| 25 | + @coverage html |
| 26 | + |
| 27 | +test_integration: ## Test the code |
| 28 | + @type coverage >/dev/null 2>&1 || (echo "Run '$(PIP) install coverage' first." >&2 ; exit 1) |
| 29 | + @coverage run --source . -m $(SRC_TEST).integration.test_api_integration |
| 30 | + @coverage report |
| 31 | + |
| 32 | +doc: ## Document the code |
| 33 | + @$(PYDOC) src |
| 34 | + |
| 35 | +clean: ## Cleanup |
| 36 | + @rm -f $(SRC_CORE)/*.pyc |
| 37 | + @rm -rf $(SRC_CORE)/__pycache__ |
| 38 | + @rm -f $(SRC_TEST)/*.pyc |
| 39 | + @rm -rf $(SRC_TEST)/__pycache__ |
| 40 | + |
| 41 | +auto-style: ## Style the code |
| 42 | + @if type autopep8 >/dev/null 2>&1 ; then autopep8 -i -r $(SRC_CORE) ; \ |
| 43 | + else echo "SKIPPED. Run '$(PIP) install autopep8' first." >&2 ; fi |
| 44 | + |
| 45 | +code-style: ## Test the code style |
| 46 | + @if type pycodestyle >/dev/null 2>&1 ; then pycodestyle --max-line-length=80 $(SRC_CORE) ; \ |
| 47 | + else echo "SKIPPED. Run '$(PIP) install pycodestyle' first." >&2 ; fi |
| 48 | + |
| 49 | +code-count: ## Count the lines of code |
| 50 | + @if type cloc >/dev/null 2>&1 ; then cloc $(SRC_CORE) ; \ |
| 51 | + else echo "SKIPPED. Run 'brew install cloc' first." >&2 ; fi |
| 52 | + |
| 53 | +code-lint: ## Lint the code |
| 54 | + @if type pyflakes >/dev/null 2>&1 ; then pyflakes $(SRC_CORE) ; \ |
| 55 | + else echo "SKIPPED. Run '$(PIP) install pyflakes' first." >&2 ; fi |
| 56 | + @if type pylint >/dev/null 2>&1 ; then pylint $(SRC_CORE) ; \ |
| 57 | + else echo "SKIPPED. Run '$(PIP) install pylint' first." >&2 ; fi |
| 58 | + @if type flake8 >/dev/null 2>&1 ; then flake8 --max-complexity 10 $(SRC_CORE) ; \ |
| 59 | + else echo "SKIPPED. Run '$(PIP) install flake8' first." >&2 ; fi |
| 60 | + @if type pyright >/dev/null 2>&1 ; then pyright $(SRC_CORE) ; \ |
| 61 | + else echo "SKIPPED. Run 'npm install -f pyright' first." >&2 ; fi |
| 62 | + @if type mypy >/dev/null 2>&1 ; then mypy --ignore-missing-imports $(SRC_CORE) ; \ |
| 63 | + else echo "SKIPPED. Run '$(PIP) install mypy' first." >&2 ; fi |
| 64 | + |
| 65 | +css-lint: ## Lint the CSS code |
| 66 | + @if type csslint >/dev/null 2>&1 ; then csslint --format=compact $(SRC_RESOURCES)/*.css ; \ |
| 67 | + else echo "SKIPPED. Run 'npm install -g csslint' first." >&2 ; fi |
| 68 | + |
| 69 | +js-lint: ## Lint the JavaScript code |
| 70 | + @if type jslint >/dev/null 2>&1 ; then jslint $(SRC_RESOURCES)/*.js ; \ |
| 71 | + else echo "SKIPPED. Run 'npm install -g jslint' first." >&2 ; fi |
| 72 | + |
| 73 | +html-lint: ## Lint the HTML code |
| 74 | + @if type tidy >/dev/null 2>&1 ; then tidy -qe $(SRC_RESOURCES)/*.html ; \ |
| 75 | + else echo "SKIPPED. Run 'brew install tidy' first." >&2 ; fi |
| 76 | + |
| 77 | +lint: code-style code-lint css-lint js-lint html-lint ## Run all linters |
| 78 | + |
| 79 | +deps-update: ## Update the dependencies |
| 80 | + @if type pur >/dev/null 2>&1 ; then pur -r requirements.txt ; \ |
| 81 | + else echo "SKIPPED. Run '$(PIP) install pur' first." >&2 ; fi |
| 82 | + |
| 83 | +deps-install: ## Install the dependencies |
| 84 | + @type $(PIP) >/dev/null 2>&1 || (echo "Run 'curl https://bootstrap.pypa.io/get-pip.py|sudo python3' first." >&2 ; exit 1) |
| 85 | + @$(PIP) install -r requirements.txt |
| 86 | + |
| 87 | +deps-create: ## Create the dependencies |
| 88 | + @if type pipreqs >/dev/null 2>&1 ; then pipreqs --use-local --force . ; \ |
| 89 | + else echo "SKIPPED. Run '$(PIP) install pipreqs' first." >&2 ; fi |
| 90 | + |
| 91 | +feedback: ## Provide feedback |
| 92 | + @open https://github.com/AlexanderWillner/python-boilerplate/issues |
| 93 | + |
| 94 | +build: ## build project |
| 95 | + python3 -m pip install --upgrade build ; \ |
| 96 | + python3 -m build |
| 97 | + |
| 98 | +upload: |
| 99 | + python3 -m twine upload dist/* |
0 commit comments