benchmark.py: uv run shebang, executable bit, stdlib-random shadowing guard
release / build-wheels (windows, cmd) (push) Failing after 10s
release / build-wheels (linux, bash) (push) Failing after 47s
release / build-wheels (macos, bash) (push) Successful in 1m25s
release / publish-pypi (push) Skipped

Fixes CI EXE001 (shebang on non-executable file). Running the script
directly puts src/aeg on sys.path, where aeg/random.py would shadow the
stdlib random module that secrets and others import — pop it before any
imports so both direct execution and -m aeg.benchmark work.
This commit is contained in:
LeoVasanko committed 2026-10-04 16:50:37 +00:00
1 parent b4404b42e6
commit 276b2faa0b
1 file changed
+12 -1
Regular → Executable
+12 -1
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env -S uv run
"""
Python benchmark matching src/test/benchmark.zig for all supported Aegis algorithms.
@@ -7,8 +7,19 @@ It performs two benchmarks with the same parameters as the Zig version:
- AEGIS MAC (clone state pattern)
Output format and throughput units mirror the Zig benchmark (Mb/s).
Runnable directly (./src/aeg/benchmark.py) or as python -m aeg.benchmark.
"""
# Direct execution puts this package's directory on sys.path, where our
# random.py would shadow the stdlib random module — drop it before imports.
import sys
from pathlib import Path
_pkg_dir = str(Path(__file__).resolve().parent)
if sys.path and Path(sys.path[0]).resolve() == Path(_pkg_dir):
sys.path.pop(0)
import secrets
import time