|
1 | 1 |
|
2 | | -cov: ## check code coverage |
3 | | - poetry run pytest -n 4 --cov deltadefi |
4 | | - |
5 | | -cov-html: cov ## check code coverage and generate an html report |
6 | | - poetry run coverage html -d cov_html |
7 | | - $(BROWSER) cov_html/index.html |
8 | | - |
9 | | -test: ## runs tests |
10 | | - poetry run dotenv run -- pytest -vv |
11 | | - |
12 | | -clean-test: ## remove test and coverage artifacts |
13 | | - rm -f .coverage |
14 | | - rm -fr cov_html/ |
15 | | - rm -fr .pytest_cache |
16 | | - |
17 | | -docs: ## build the documentation |
18 | | - poetry export --dev --without-hashes > docs/requirements.txt |
19 | | - rm -r -f docs/build |
20 | | - poetry run sphinx-build docs/source docs/build/html |
21 | | - $(BROWSER) docs/build/html/index.html |
22 | | - |
23 | | -format: ## runs code style and formatter |
24 | | - poetry run isort . |
25 | | - poetry run black . |
26 | | - |
27 | | -deps: |
28 | | - poetry lock |
29 | | - poetry install |
| 2 | +# Makefile for deltadefi-python-sdk (uv-managed Python project) |
| 3 | +# Usage examples: |
| 4 | +# make install # create venv and install project + dev deps |
| 5 | +# make test # run pytest |
| 6 | +# make fmt lint # format + lint with Ruff |
| 7 | +# make build # build the package |
| 8 | +# make help # list targets |
| 9 | + |
| 10 | +SHELL := /bin/bash |
| 11 | +.DEFAULT_GOAL := help |
| 12 | + |
| 13 | +UV := uv |
| 14 | +PY := python |
| 15 | + |
| 16 | +.PHONY: help venv install fmt lint type test cov build clean docs deps |
| 17 | + |
| 18 | +help: ## Show this help with grouped commands |
| 19 | + @echo "Available commands:" |
| 20 | + @echo "" |
| 21 | + @echo "📦 Installation & Setup:" |
| 22 | + @grep -E '^[a-zA-Z_\-]+:.*##.*install' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*## "}; {printf " \033[36m%-12s\033[0m %s\n", $$1, $$2}' |
| 23 | + @echo "" |
| 24 | + @echo "🔧 Testing & Quality:" |
| 25 | + @grep -E '^[a-zA-Z_\-]+:.*##.*\[(test|lint|format|type|quality|check)\]' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*## "}; {printf " \033[36m%-12s\033[0m %s\n", $$1, $$2}' |
| 26 | + @echo "" |
| 27 | + @echo "🏗️ Building & Distribution:" |
| 28 | + @grep -E '^[a-zA-Z_\-]+:.*##.*\[(build|dist)\]' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*## "}; {printf " \033[36m%-12s\033[0m %s\n", $$1, $$2}' |
| 29 | + @echo "" |
| 30 | + @echo "📚 Other Utilities:" |
| 31 | + @grep -E '^[a-zA-Z_\-]+:.*##[^[]*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*## "}; {printf " \033[36m%-12s\033[0m %s\n", $$1, $$2}' |
| 32 | + |
| 33 | +# 📦 Installation & Setup |
| 34 | +venv: ## Create virtual environment [install] |
| 35 | + @$(UV) venv |
| 36 | + |
| 37 | +install: ## Install project in editable mode with dependencies [install] |
| 38 | + @$(UV) pip install -e . --group dev --group docs |
| 39 | + |
| 40 | +deps: install ## Install dependencies (alias for install) [install] |
| 41 | + |
| 42 | +# 🔧 Testing & Quality |
| 43 | +fmt: ## Format code with Ruff formatter [format] |
| 44 | + @$(UV) run ruff format . |
| 45 | + |
| 46 | +lint: ## Lint with Ruff (auto-fix + fail on remaining issues) [lint] |
| 47 | + @$(UV) run ruff check --fix --exit-non-zero-on-fix . |
| 48 | + |
| 49 | +type: ## Static type-check with mypy [type] |
| 50 | + @$(UV) run mypy --config-file=pyproject.toml src/ || true |
| 51 | + |
| 52 | +test: install ## Run tests with pytest [test] |
| 53 | + @$(UV) run pytest -vv |
| 54 | + |
| 55 | +cov: install ## Check code coverage [test] |
| 56 | + @$(UV) run pytest -n 4 --cov deltadefi |
| 57 | + |
| 58 | +cov-html: cov ## Check code coverage and generate HTML report [test] |
| 59 | + @$(UV) run coverage html -d cov_html |
| 60 | + @echo "Coverage report generated in cov_html/" |
| 61 | + |
| 62 | +# 🏗️ Building & Distribution |
| 63 | +build: install ## Build the package [build] |
| 64 | + @$(UV) build |
| 65 | + |
| 66 | +# 📚 Other Utilities |
| 67 | +docs: install ## Build the documentation |
| 68 | + @mkdir -p docs/requirements |
| 69 | + @$(UV) export --group docs > docs/requirements.txt |
| 70 | + @rm -r -f docs/build |
| 71 | + @$(UV) run sphinx-build docs/source docs/build/html |
| 72 | + @echo "Documentation built in docs/build/html/" |
| 73 | + |
| 74 | +clean-test: ## Remove test and coverage artifacts |
| 75 | + @rm -f .coverage |
| 76 | + @rm -fr cov_html/ |
| 77 | + @rm -fr .pytest_cache |
| 78 | + |
| 79 | +clean: clean-test ## Remove caches, build artifacts, and temp files |
| 80 | + @rm -rf .mypy_cache .ruff_cache dist build |
| 81 | + @find . -type d -name __pycache__ -prune -exec rm -rf {} + |
| 82 | + |
| 83 | +version: ## Show uv and Python versions |
| 84 | + @$(UV) --version |
| 85 | + @$(UV) run $(PY) -c "import platform; print('Python', platform.python_version())" |
0 commit comments