|
1 | | -.PHONY: clean clean-test clean-pyc clean-build docs help |
2 | | -.DEFAULT_GOAL := help |
| 1 | +.PHONY: install lint format test docs clean |
3 | 2 |
|
4 | | -define BROWSER_PYSCRIPT |
5 | | -import os, webbrowser, sys |
| 3 | +install: ## Install dev dependencies |
| 4 | + uv sync --extra dev |
6 | 5 |
|
7 | | -try: |
8 | | - from urllib import pathname2url |
9 | | -except: |
10 | | - from urllib.request import pathname2url |
| 6 | +lint: ## Run linting and type checking |
| 7 | + uv run ruff check . |
| 8 | + uv run mypy socials |
11 | 9 |
|
12 | | -webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1]))) |
13 | | -endef |
14 | | -export BROWSER_PYSCRIPT |
| 10 | +format: ## Format code |
| 11 | + uv run ruff format . |
| 12 | + uv run ruff check --fix . |
15 | 13 |
|
16 | | -define PRINT_HELP_PYSCRIPT |
17 | | -import re, sys |
| 14 | +test: ## Run tests |
| 15 | + uv run pytest |
18 | 16 |
|
19 | | -for line in sys.stdin: |
20 | | - match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line) |
21 | | - if match: |
22 | | - target, help = match.groups() |
23 | | - print("%-20s %s" % (target, help)) |
24 | | -endef |
25 | | -export PRINT_HELP_PYSCRIPT |
| 17 | +docs: ## Serve documentation locally |
| 18 | + uv run mkdocs serve |
26 | 19 |
|
27 | | -BROWSER := python -c "$$BROWSER_PYSCRIPT" |
28 | | - |
29 | | -help: |
30 | | - @python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST) |
31 | | - |
32 | | -clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts |
33 | | - |
34 | | -clean-build: ## remove build artifacts |
35 | | - rm -fr build/ |
36 | | - rm -fr dist/ |
37 | | - rm -fr .eggs/ |
38 | | - find . -name '*.egg-info' -exec rm -fr {} + |
39 | | - find . -name '*.egg' -exec rm -f {} + |
40 | | - |
41 | | -clean-pyc: ## remove Python file artifacts |
42 | | - find . -name '*.pyc' -exec rm -f {} + |
43 | | - find . -name '*.pyo' -exec rm -f {} + |
44 | | - find . -name '*~' -exec rm -f {} + |
45 | | - find . -name '__pycache__' -exec rm -fr {} + |
46 | | - |
47 | | -clean-test: ## remove test and coverage artifacts |
48 | | - rm -fr .tox/ |
49 | | - rm -f .coverage |
50 | | - rm -fr htmlcov/ |
51 | | - rm -fr .pytest_cache |
52 | | - |
53 | | -lint: ## check style with flake8 |
54 | | - flake8 socials tests |
55 | | - |
56 | | -test: ## run tests quickly with the default Python |
57 | | - py.test |
58 | | - |
59 | | -test-all: ## run tests on every Python version with tox |
60 | | - tox |
61 | | - |
62 | | -coverage: ## check code coverage quickly with the default Python |
63 | | - coverage run --source socials -m pytest |
64 | | - coverage report -m |
65 | | - coverage html |
66 | | - $(BROWSER) htmlcov/index.html |
67 | | - |
68 | | -docs: ## generate Sphinx HTML documentation, including API docs |
69 | | - rm -f docs/socials.rst |
70 | | - rm -f docs/modules.rst |
71 | | - sphinx-apidoc -o docs/ socials |
72 | | - $(MAKE) -C docs clean |
73 | | - $(MAKE) -C docs html |
74 | | - $(BROWSER) docs/_build/html/index.html |
75 | | - |
76 | | -servedocs: docs ## compile the docs watching for changes |
77 | | - watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D . |
78 | | - |
79 | | -release: dist ## package and upload a release |
80 | | - twine upload dist/* |
81 | | - |
82 | | -dist: clean ## builds source and wheel package |
83 | | - python setup.py sdist |
84 | | - python setup.py bdist_wheel |
85 | | - ls -l dist |
86 | | - |
87 | | -install: clean ## install the package to the active Python's site-packages |
88 | | - python setup.py install |
| 20 | +clean: ## Remove build artifacts |
| 21 | + rm -rf build/ dist/ .eggs/ *.egg-info/ |
| 22 | + rm -rf .pytest_cache/ .ruff_cache/ .mypy_cache/ |
| 23 | + rm -rf htmlcov/ .coverage coverage.xml |
| 24 | + find . -name '*.pyc' -delete |
| 25 | + find . -name '__pycache__' -delete |
0 commit comments