VENV_DIR = $(shell pwd)/.venv
PYTHON   = $(VENV_DIR)/bin/python
PIP      = $(VENV_DIR)/bin/pip
PYTEST   = $(VENV_DIR)/bin/pytest
RUFF     = $(VENV_DIR)/bin/ruff

.DEFAULT_GOAL := all
.PHONY: all bootstrap venv install test lint format clean help

all: bootstrap test lint

help:
	@echo "erldistpy targets"
	@echo "  make bootstrap   - create venv, install editable + dev deps"
	@echo "  make test        - run pytest"
	@echo "  make lint        - ruff check"
	@echo "  make format      - ruff format"
	@echo "  make clean       - drop venv + caches"

venv:
	test -d $(VENV_DIR) || python3 -m venv $(VENV_DIR)
	$(PIP) install --upgrade pip wheel setuptools

bootstrap: venv
	$(PIP) install -e ".[dev]"

install: bootstrap

test:
	$(PYTEST) -v

lint:
	$(RUFF) check erldistpy tests

format:
	$(RUFF) format erldistpy tests

clean:
	rm -rf $(VENV_DIR)
	rm -rf .pytest_cache .ruff_cache
	rm -rf build dist *.egg-info
	find . -type d -name __pycache__ -exec rm -rf {} +
