python.just
1 # Alpha-Delta Python Justfile 2 # Python commands for pip/poetry projects 3 4 set shell := ["bash", "-c"] 5 6 # Detect if using poetry 7 use_poetry := `if [ -f "pyproject.toml" ] && grep -q "tool.poetry" pyproject.toml 2>/dev/null; then echo "true"; else echo "false"; fi` 8 9 # Default: List available commands 10 default: 11 @just --list 12 13 # CI Entrypoint: Full pipeline matching python-master.yml 14 ci: install fmt lint audit test 15 @echo "Python CI complete" 16 17 # Install dependencies 18 install: 19 @if [ "{{use_poetry}}" = "true" ]; then poetry install; \ 20 elif [ -f "requirements.txt" ]; then pip install -r requirements.txt; \ 21 elif [ -f "backend/requirements.txt" ]; then pip install -r backend/requirements.txt; \ 22 else echo "No requirements found"; fi 23 24 # Format check (ruff format) 25 fmt: 26 ruff format --check . || echo "Format check failed" 27 28 # Lint (ruff check) 29 lint: 30 ruff check . 31 32 # Security audit (safety or pip-audit) 33 audit: 34 @if command -v safety &> /dev/null; then safety check; \ 35 elif command -v pip-audit &> /dev/null; then pip-audit; \ 36 else echo "Install safety: pip install safety"; fi 37 38 # Run tests (pytest) 39 test: 40 pytest 41 42 # Development shortcut 43 dev: install lint test 44 @echo "Dev checks complete" 45 46 # Clean build artifacts 47 clean: 48 rm -rf __pycache__ .pytest_cache .ruff_cache dist build *.egg-info 49 50 # Generate SBOM (using cyclonedx-py) 51 sbom: 52 @if command -v cyclonedx-py &> /dev/null; then \ 53 cyclonedx-py -r --format json -o sbom.json; \ 54 else \ 55 echo "Install cyclonedx-py: pip install cyclonedx-bom"; \ 56 fi 57 58 # Install dev tools 59 install-tools: 60 pip install ruff pytest safety cyclonedx-bom 61 @echo "Tools installed"