- parse .pre-commit-config.yaml rev fields with a regex instead of yaml.safe_load; the file is repo-controlled and flat, so stdlib covers it and the lint extra stays two pins (pyyaml removed) - normalize YAML-quoted and v-prefixed revs so a quoting change can't produce a false mismatch - derive the checked tool list from REPO_TO_TOOL instead of a third hardcoded copy - drop the Makefile PyYAML probe made moot by the above - halve persist-step comments in ci.yml; kept detached-HEAD reset, never-reopen, and sed fail-by-name rationale
137 lines
4.8 KiB
Makefile
137 lines
4.8 KiB
Makefile
# Pandas TA Classic - Makefile
|
|
# ============================
|
|
# Quick reference for common development tasks
|
|
# Python version: the latest stable plus the prior 4 versions (dynamically managed via CI/CD)
|
|
|
|
# Package manager detection (prefer uv if available, fallback to pip)
|
|
PIP := $(shell if command -v uv >/dev/null 2>&1; then echo "uv pip"; else echo "pip"; fi)
|
|
|
|
# Python: use the local venv if it exists, otherwise fall back to system python
|
|
PYTHON := $(shell if [ -f .venv/bin/python ]; then echo ".venv/bin/python"; else echo "python3"; fi)
|
|
|
|
.PHONY: all help clean caches install install-dev install-all init test test-ext test-metrics test-strats test-ta test-utils test-all fixtures docs docs-serve lint format typecheck
|
|
|
|
# Default target
|
|
all: test
|
|
|
|
# Help command - show available targets
|
|
help:
|
|
@echo "Pandas TA Classic - Development Commands"
|
|
@echo "========================================"
|
|
@echo ""
|
|
@echo "Installation:"
|
|
@echo " make install Install package in editable mode"
|
|
@echo " make install-dev Install with development dependencies"
|
|
@echo " make install-all Install with all optional dependencies"
|
|
@echo ""
|
|
@echo "Testing:"
|
|
@echo " make test Run all tests"
|
|
@echo " make test-all Regenerate fixtures, then run all tests"
|
|
@echo " make test-ta Run indicator tests"
|
|
@echo " make test-ext Run extended indicator tests"
|
|
@echo " make test-utils Run utility tests"
|
|
@echo " make test-metrics Run metrics tests"
|
|
@echo " make test-strats Run strategy tests"
|
|
@echo ""
|
|
@echo "Fixtures:"
|
|
@echo " make fixtures Regenerate expected_values.json + regression_snapshots.json"
|
|
@echo ""
|
|
@echo "Documentation:"
|
|
@echo " make docs Build Sphinx documentation"
|
|
@echo " make docs-serve Build and serve documentation locally"
|
|
@echo ""
|
|
@echo "Maintenance:"
|
|
@echo " make clean Remove Python cache files"
|
|
@echo " make lint Run code quality checks"
|
|
@echo " make format Format code with black"
|
|
@echo " make typecheck Run mypy against the requires-python floor"
|
|
@echo ""
|
|
@echo "Package manager: $(PIP)"
|
|
|
|
# Installation targets
|
|
install:
|
|
$(PIP) install -e .
|
|
|
|
install-dev:
|
|
$(PIP) install -e ".[dev]"
|
|
|
|
install-all:
|
|
$(PIP) install -e ".[all]"
|
|
|
|
# Legacy target for backwards compatibility
|
|
init: install-dev
|
|
@echo "Note: 'make init' is deprecated. Use 'make install-dev' instead."
|
|
|
|
# Testing targets
|
|
test: test-utils test-metrics test-ta test-ext test-strats
|
|
|
|
test-ext:
|
|
$(PYTHON) -m unittest discover -s tests -p "test_ext_indicator_*.py" -v
|
|
|
|
test-metrics:
|
|
$(PYTHON) -m unittest tests.test_utils_metrics -v
|
|
|
|
test-strats:
|
|
$(PYTHON) -m unittest tests.test_strategy -v
|
|
|
|
test-ta:
|
|
$(PYTHON) -m unittest discover -s tests -p "test_indicator_*.py" -v
|
|
|
|
test-utils:
|
|
$(PYTHON) -m unittest tests.test_utils -v
|
|
|
|
# Regenerate JSON fixture files from TA-Lib oracle + native code
|
|
fixtures:
|
|
@echo "Regenerating expected_values.json..."
|
|
$(PYTHON) -m tests.fixtures.generate_fixtures
|
|
@echo "Regenerating regression_snapshots.json..."
|
|
$(PYTHON) -m tests.fixtures.generate_regression_snapshots
|
|
@echo "Fixtures regenerated."
|
|
|
|
# Regenerate fixtures then run the full test suite
|
|
test-all: fixtures
|
|
@echo "Running full test suite..."
|
|
$(PYTHON) -m unittest discover tests/ -v
|
|
|
|
# Documentation targets
|
|
docs:
|
|
@echo "Building Sphinx documentation..."
|
|
cd docs && make html
|
|
@echo "Documentation built: docs/_build/html/index.html"
|
|
|
|
docs-serve: docs
|
|
@echo "Starting local documentation server..."
|
|
@echo "Open http://localhost:8000 in your browser"
|
|
cd docs/_build/html && $(PYTHON) -m http.server 8000
|
|
|
|
# Maintenance targets
|
|
clean:
|
|
@echo "Cleaning Python cache files..."
|
|
find . -type f -name '*.pyc' -delete
|
|
find . -type d -name '__pycache__' -delete
|
|
find . -type d -name '*.egg-info' -exec rm -rf {} + 2>/dev/null || true
|
|
find . -type d -name '.pytest_cache' -exec rm -rf {} + 2>/dev/null || true
|
|
rm -rf build dist .eggs 2>/dev/null || true
|
|
@echo "Clean complete!"
|
|
|
|
caches:
|
|
@echo "Finding Python cache files..."
|
|
find . \( -type f -name '*.pyc' \) -o \( -type d -name '__pycache__' \)
|
|
|
|
lint:
|
|
@echo "Running ruff..."
|
|
ruff check pandas_ta_classic --select E9,F63,F7,F82
|
|
ruff check pandas_ta_classic --extend-select C901,E501 --exit-zero
|
|
@echo "Checking black/ruff versions match .pre-commit-config.yaml..."
|
|
$(PYTHON) tools/check_lint_versions.py
|
|
|
|
format:
|
|
@echo "Formatting code with black..."
|
|
black pandas_ta_classic/
|
|
|
|
# Derives the mypy target version from project.requires-python instead of
|
|
# hardcoding it a second time, so the two can't drift out of sync.
|
|
typecheck:
|
|
@MYPY_PY=$$($(PYTHON) -c "import re, tomllib; print(re.search(r'\d+\.\d+', tomllib.load(open('pyproject.toml', 'rb'))['project']['requires-python']).group())"); \
|
|
echo "Type checking against Python $$MYPY_PY (from requires-python)..."; \
|
|
$(PYTHON) -m mypy --python-version $$MYPY_PY
|