spark-rsi-mv
Native Rust recursive self-improvement engine with paired bootstrap evaluation and cryptographic ledger
Brought by drakestapleton
spark-rsi-mv / scripts / check-no-python.sh
| 1 | #!/bin/sh |
| 2 | # No-Python guard (Drake's rule, 2026-10-15: no Python anywhere in AIEN). |
| 3 | # Fails when git tracks any Python source, notebook, Python packaging or |
| 4 | # environment file, or any file whose first line is a python shebang. |
| 5 | # POSIX sh, git, grep and head only. |
| 6 | # Usage: sh scripts/check-no-python.sh (from anywhere inside the repository) |
| 7 | set -eu |
| 8 | cd "$(git rev-parse --show-toplevel)" |
| 9 | |
| 10 | # File names are matched case-insensitively (Foo.PY counts). |
| 11 | names='(^|/)(setup\.py|setup\.cfg|pyproject\.toml|pipfile|pipfile\.lock|poetry\.lock|uv\.lock|\.python-version|requirements[^/]*\.txt|requirements[^/]*\.in)$|\.(py|pyi|pyw|pyx|pyc|ipynb)$' |
| 12 | # Tracked paths that match the name rule but are not Python (one ERE, empty for none). |
| 13 | exempt='' |
| 14 | |
| 15 | # -z keeps non-ASCII names unquoted so the patterns see the real name. |
| 16 | found=$(git ls-files -z | tr '\0' '\n' | grep -i -E "$names" || true) |
| 17 | if [ -n "$exempt" ] && [ -n "$found" ]; then |
| 18 | found=$(printf '%s\n' "$found" | grep -v -E "$exempt" || true) |
| 19 | fi |
| 20 | # Candidates contain a python shebang line anywhere; keep those where it is line 1. |
| 21 | shebang=$(git grep -I -l -z -i -E '^#!.*python' -- . 2>/dev/null | tr '\0' '\n' | |
| 22 | while IFS= read -r f; do |
| 23 | if head -n 1 -- "$f" | grep -q -i -E '^#!.*python'; then printf '%s\n' "$f"; fi |
| 24 | done || true) |
| 25 | |
| 26 | if [ -n "$found" ] || [ -n "$shebang" ]; then |
| 27 | echo "no-python guard: FAIL. Python is not allowed in this repository. Offending tracked files:" >&2 |
| 28 | [ -n "$found" ] && printf '%s\n' "$found" | sed 's/^/ /' >&2 |
| 29 | [ -n "$shebang" ] && printf '%s\n' "$shebang" | sed 's/$/ (python shebang)/; s/^/ /' >&2 |
| 30 | exit 1 |
| 31 | fi |
| 32 | echo "no-python guard: PASS ($(git ls-files | wc -l | tr -d ' ') tracked files, none is Python)" |