From 276b2faa0b3abe6a99d534adb85cb777f76cf4f6 Mon Sep 17 00:00:00 2001 From: Leo Vasanko Date: Sun, 4 Oct 2026 16:50:37 +0000 Subject: [PATCH] benchmark.py: uv run shebang, executable bit, stdlib-random shadowing guard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- src/aeg/benchmark.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) mode change 100644 => 100755 src/aeg/benchmark.py diff --git a/src/aeg/benchmark.py b/src/aeg/benchmark.py old mode 100644 new mode 100755 index abad820..2706aa2 --- a/src/aeg/benchmark.py +++ b/src/aeg/benchmark.py @@ -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