.PHONY: build test upload install clean dev help

VENV := .venv
PYTHON := $(VENV)/bin/python
PIP := $(VENV)/bin/pip

help:
	@echo "Cleave development commands:"
	@echo "  make install    - Create venv and install in editable mode"
	@echo "  make dev        - Install with dev dependencies"
	@echo "  make test       - Run tests"
	@echo "  make build      - Build distribution packages"
	@echo "  make upload     - Upload to PyPI"
	@echo "  make clean      - Remove build artifacts"

$(VENV)/bin/activate:
	python3 -m venv $(VENV)
	$(PIP) install --upgrade pip

install: $(VENV)/bin/activate
	$(PIP) install -e .

dev: $(VENV)/bin/activate
	$(PIP) install -e ".[dev]"

test: dev
	$(VENV)/bin/pytest

build: $(VENV)/bin/activate
	$(PIP) install build
	$(PYTHON) -m build

upload: build
	$(PIP) install twine
	$(VENV)/bin/twine upload dist/*

clean:
	rm -rf dist/ build/ *.egg-info src/*.egg-info
	find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
	find . -type f -name "*.pyc" -delete
