From d9d4756506100909d00ae7d852e83b24e751b2ba Mon Sep 17 00:00:00 2001 From: ayushcodes10 Date: Wed, 23 Sep 2026 12:16:33 +0530 Subject: [PATCH] Re exec the hash seed pin as a module, not by replaying argv[0] The previous form replayed sys.argv[0] as the script path to run, which happens to work for a POSIX console script wrapper or a python dash m invocation, both of which are real, runnable Python content. It does not work for a uv, pip, or pipx console script launcher on Windows, which installs as a native executable stub with no such content, so the interpreter has nothing to open and every affected command failed outright the moment it tried to pin the seed. Re execing through the module flag instead never depends on argv[0] being anything runnable at all, so a launcher stub that is not even a real file no longer matters, and this now matches the exact invocation shape the end to end test for this function already exercised and proved working. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_017qfdzgbA5KedGEjD1AayNh (cherry picked from commit 6509f609dceb0f1de467920c3c9aa53ad5a529b5) --- graphify/__main__.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/graphify/__main__.py b/graphify/__main__.py index d4f266ce4..a2c5416de 100644 --- a/graphify/__main__.py +++ b/graphify/__main__.py @@ -522,7 +522,17 @@ def _pin_hash_seed_if_needed() -> None: if "PYTHONHASHSEED" in os.environ or "PYTEST_CURRENT_TEST" in os.environ: return try: - os.execvpe(sys.executable, [sys.executable, *sys.argv], {**os.environ, "PYTHONHASHSEED": "0"}) + # Re-exec as a module (-m graphify) rather than replaying sys.argv[0] + # as a script path: that works for a POSIX console-script wrapper or + # a `python -m graphify` invocation, but a uv/pip/pipx console-script + # launcher on Windows is a native .exe with no .py content, so + # `python.exe ` fails outright with "can't open + # file" -- every command this function touches (#3779). + os.execvpe( + sys.executable, + [sys.executable, "-m", "graphify", *sys.argv[1:]], + {**os.environ, "PYTHONHASHSEED": "0"}, + ) except OSError: pass