PYTHON ?= python3
PYTHONPATH := libexec:tests

.PHONY: test quality validate release clean-bytecode catalog

test:
	PYTHONDONTWRITEBYTECODE=1 PYTHONWARNINGS=error::ResourceWarning PYTHONPATH=$(PYTHONPATH) \
		$(PYTHON) scripts/run_tests.py

quality:
	ruff format --check .
	ruff check .
	mypy
	pyright
	shellcheck install.sh uninstall.sh bin/*.in
	shfmt -d install.sh uninstall.sh bin/*.in

validate:
	PYTHONDONTWRITEBYTECODE=1 $(PYTHON) scripts/validate_package.py

release:
	PYTHONDONTWRITEBYTECODE=1 $(PYTHON) scripts/build_release.py

catalog:
	PYTHONDONTWRITEBYTECODE=1 $(PYTHON) scripts/generate_catalog.py

clean-bytecode:
	find . -type d -name __pycache__ -prune -exec rm -rf {} +
	find . -type f \( -name '*.pyc' -o -name '*.pyo' \) -delete
	find . -type d \( -name .mypy_cache -o -name .ruff_cache \) -prune -exec rm -rf {} +
