# Makefile for Majmu Python library

.PHONY: help install install-dev test test-verbose clean lint format type-check build upload upload-test docs clean-build clean-pyc clean-test

help:
	@echo "Available commands:"
	@echo "  install      Install production dependencies"
	@echo "  install-dev  Install development dependencies"
	@echo "  test         Run tests"
	@echo "  test-verbose Run tests with verbose output"
	@echo "  lint         Run flake8 linting"
	@echo "  format       Format code with black"
	@echo "  type-check   Run mypy type checking"
	@echo "  build        Build distribution packages"
	@echo "  upload       Upload to PyPI"
	@echo "  upload-test  Upload to Test PyPI"
	@echo "  docs         Build documentation"
	@echo "  clean        Clean all build artifacts"
	@echo "  clean-build  Clean build artifacts"
	@echo "  clean-pyc    Clean Python file artifacts"
	@echo "  clean-test   Clean test artifacts"

install:
	pip install -r requirements.txt

install-dev:
	pip install -r requirements-dev.txt
	pre-commit install

test:
	pytest

test-verbose:
	pytest -v --cov=majmu --cov-report=term-missing

lint:
	flake8 majmu tests examples

format:
	black majmu tests examples

type-check:
	mypy majmu

build: clean
	python -m build

upload: build
	twine upload dist/*

upload-test: build
	twine upload --repository testpypi dist/*

docs:
	cd docs && make html

clean: clean-build clean-pyc clean-test

clean-build:
	rm -fr build/
	rm -fr dist/
	rm -fr .eggs/
	find . -name '*.egg-info' -exec rm -fr {} +
	find . -name '*.egg' -exec rm -fr {} +

clean-pyc:
	find . -name '*.pyc' -exec rm -f {} +
	find . -name '*.pyo' -exec rm -f {} +
	find . -name '*~' -exec rm -f {} +
	find . -name '__pycache__' -exec rm -fr {} +

clean-test:
	rm -fr .tox/
	rm -f .coverage
	rm -fr htmlcov/
	rm -fr .pytest_cache/
	rm -fr .mypy_cache/

# Development workflow
dev-setup: install-dev
	@echo "Development environment setup complete!"
	@echo "Run 'make test' to run tests"
	@echo "Run 'make format' to format code"
	@echo "Run 'make lint' to check code style"

# Quick quality check
check: format lint type-check test
	@echo "All quality checks passed!"

# Release workflow (for maintainers)
release-check: check
	@echo "Release checks passed!"
	@echo "Ready to build and upload to PyPI"

# Local development test
dev-test:
	python examples/basic_usage.py
