|
| 1 | +# Simple Makefile for use with a uv-based development environment |
| 2 | +.PHONY: install |
| 3 | +install: ## Install the virtual environment |
| 4 | + @echo "🚀 Creating virtual environment" |
| 5 | + @uv sync |
| 6 | + |
| 7 | +.PHONY: check |
| 8 | +check: ## Run code quality tools. |
| 9 | + @echo "🚀 Checking lock file consistency with 'pyproject.toml'" |
| 10 | + @uv lock --locked |
| 11 | + @echo "🚀 Linting code: Running pre-commit" |
| 12 | + @uv run pre-commit run -a |
| 13 | + @echo "🚀 Static type checking: Running mypy" |
| 14 | + @uv run mypy |
| 15 | + |
| 16 | +.PHONY: test |
| 17 | +test: ## Test the code with pytest. |
| 18 | + @echo "🚀 Testing code: Running pytest" |
| 19 | + @uv run python -m pytest --cov --cov-config=pyproject.toml --cov-report=xml tests |
| 20 | + @uv run python -m pytest --cov --cov-config=pyproject.toml --cov-report=xml tests_isolated |
| 21 | + |
| 22 | +.PHONY: docs-test |
| 23 | +docs-test: ## Test if documentation can be built without warnings or errors |
| 24 | + @uv run mkdocs build -s |
| 25 | + |
| 26 | +.PHONY: docs |
| 27 | +docs: ## Build and serve the documentation |
| 28 | + @uv run mkdocs serve |
| 29 | + |
| 30 | +.PHONY: build |
| 31 | +build: clean-build ## Build wheel file |
| 32 | + @echo "🚀 Creating wheel file" |
| 33 | + @uvx --from build pyproject-build --installer uv |
| 34 | + |
| 35 | +.PHONY: clean-build |
| 36 | +clean-build: ## Clean build artifacts |
| 37 | + @echo "🚀 Removing build artifacts" |
| 38 | + @uv run python -c "import shutil; import os; shutil.rmtree('dist') if os.path.exists('dist') else None" |
| 39 | + |
| 40 | +.PHONY: tag |
| 41 | +tag: ## Add a Git tag and push it to origin with syntax: make tag TAG=tag_name |
| 42 | + @echo "🚀 Creating git tag: ${TAG}" |
| 43 | + @git tag -a ${TAG} -m "" |
| 44 | + @echo "🚀 Pushing tag to origin: ${TAG}" |
| 45 | + @git push origin ${TAG} |
| 46 | + |
| 47 | +.PHONY: validate-tag |
| 48 | +validate-tag: ## Check to make sure that a tag exists for the current HEAD and it looks like a valid version number |
| 49 | + @echo "🚀 Validating version tag" |
| 50 | + @uv run inv validatetag |
| 51 | + |
| 52 | +.PHONY: publish-test |
| 53 | +publish-test: validate-tag build ## Test publishing a release to PyPI. |
| 54 | + @echo "🚀 Publishing: Dry run." |
| 55 | + @uvx twine upload --repository testpypi dist/* |
| 56 | + |
| 57 | +.PHONY: publish |
| 58 | +publish: validate-tag build ## Publish a release to PyPI. |
| 59 | + @echo "🚀 Publishing." |
| 60 | + @uvx twine upload dist/* |
| 61 | + |
| 62 | +.PHONY: help |
| 63 | +help: |
| 64 | + @uv run python -c "import re; \ |
| 65 | + [[print(f'\033[36m{m[0]:<20}\033[0m {m[1]}') for m in re.findall(r'^([a-zA-Z_-]+):.*?## (.*)$$', open(makefile).read(), re.M)] for makefile in ('$(MAKEFILE_LIST)').strip().split()]" |
| 66 | + |
| 67 | +.DEFAULT_GOAL := help |
0 commit comments