configure: fallback to using local python when `uv` not present
What changed, and why it matters
This commit fixes a build problem on NixOS where the configure script couldn't find a working Python interpreter. It makes the build fall back to the local python3 when the 'uv' tool isn't available, and now errors out clearly if no Python is found. It is a build reliability fix, not a security vulnerability patch.
Treat as a normal build fix. No security response required. Ensure CI covers NixOS/sandboxed builds to prevent regressions.
Security signals we found
Build configuration hardening: explicit failure when required Python interpreter is missing
Sandbox/offline build compatibility improvement
No evidence of memory safety, cryptographic, or privilege-escalation issue in diff
Evidence from the diff
The configure script’s default_python() previously relied on ‘uv run python’ to discover Python. In sandboxed/offline builds (notably NixOS), uv may be absent or unable to fetch Python, causing builds to fail with ‘Permission denied’ or missing PYTHON. The patch adds a fallback that accepts a local python3 binary if it reports a Python 3 version, and adds an explicit configure-time error if PYTHON remains unset. The Nix package’s PYTHON override is removed because configure now handles detection.
Changed components
configurenix/pkgs/default.nixcontrib/msggen code generation build pathInspect captured patch +12 / −5
### configure
@@ -82,6 +82,12 @@ default_python()
echo "$p"
return
fi
+ # uv may be unavailable or unable to reach the network
+ # (offline/sandboxed builds); fall back to the interpreter itself.
+ if $p --version 2>&1 | grep -q "Python 3."; then
+ echo "$p"
+ return
+ fi
fi
done
}
@@ -345,6 +351,12 @@ done
# Now fill in any unset vars.
set_defaults
+if [ -z "$PYTHON" ]; then
+ echo "configure: no Python 3 interpreter found." >&2
+ echo "Install python3, or set it explicitly: ./configure PYTHON=/path/to/python3" >&2
+ exit 1
+fi
+
if [ "$ASAN" = "1" ]; then
if [ "$VALGRIND" = "1" ]; then
echo "Address sanitizer (ASAN) and valgrind cannot be enabled at the same time"
### nix/pkgs/default.nix
@@ -77,11 +77,6 @@ stdenv.mkDerivation {
configureFlags = [ "--disable-valgrind" ];
- # ./configure detects Python via `uv` (configure:default_python), which is not
- # part of this derivation. Point it at the python3 we already provide so the
- # codegen steps that call $(PYTHON) (e.g. devtools/blockreplace.py) work.
- preConfigure = "export PYTHON=python3";
-
enableParallelBuilding = true;
# workaround for build issue, happens only x86_64-darwin, not aarch64-darwinWhy this scored 19/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.