Skip to content

Commit c4e4746

Browse files
committed
Address review comments
.agents/codebase-insights.txt: ci/test/python-recorder-smoke.sh: src/ct/trace/record.nim: Signed-off-by: Tzanko Matev <[email protected]>
1 parent 4539f6c commit c4e4746

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

.agents/codebase-insights.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@
2222
is always terminated when the app exits.
2323
- `ct record` now prefers `CODETRACER_PYTHON_INTERPRETER`, `PYTHON_EXECUTABLE`, `PYTHONEXECUTABLE`, or PATH resolution to locate the Python runtime before delegating to the db backend, and `db-backend-record` expects the resolved interpreter via `--python-interpreter` when launching the recorder.
2424
- `ct record` resolves Python via env vars (`CODETRACER_PYTHON_INTERPRETER`, `PYTHON_EXECUTABLE`, `PYTHONEXECUTABLE`, `PYTHON`) before checking PATH. When falling back to PATH we now call `findExe(..., followSymlinks=false)` so virtualenv launchers keep their original location and `pyvenv.cfg` remains discoverable.
25+
- Interpreter overrides (e.g. `CODETRACER_PYTHON_INTERPRETER`) are now treated as authoritative; if the configured path cannot be resolved we error instead of silently falling back to PATH.
2526
- `ct record` verifies that `codetracer_python_recorder` is importable before launching the db backend and prints actionable guidance if the module is missing or broken.
2627
- Sudoku test-program datasets include intentionally invalid boards (e.g., examples #3 and #6) with duplicate digits inside a sub-grid; solvers should detect and report these gracefully.

ci/test/python-recorder-smoke.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,14 @@ if [[ ${INTERP_STATUS} -eq 0 ]]; then
136136
exit 1
137137
fi
138138

139-
if ! grep -q "Python module \`codetracer_python_recorder\` is not installed for interpreter" <<<"${MISSING_INTERP_OUTPUT}"; then
140-
echo "error: missing interpreter output did not mention missing interpreter"
139+
if ! grep -q "CODETRACER_PYTHON_INTERPRETER is set" <<<"${MISSING_INTERP_OUTPUT}"; then
140+
echo "error: missing interpreter output did not explain which override failed"
141141
echo "${MISSING_INTERP_OUTPUT}"
142142
exit 1
143143
fi
144144

145-
if ! grep -q "CODETRACER_PYTHON_INTERPRETER" <<<"${MISSING_INTERP_OUTPUT}"; then
146-
echo "error: missing interpreter output did not reference CODETRACER_PYTHON_INTERPRETER hint"
145+
if ! grep -q "does not resolve to a Python interpreter" <<<"${MISSING_INTERP_OUTPUT}"; then
146+
echo "error: missing interpreter output did not describe the resolution failure"
147147
echo "${MISSING_INTERP_OUTPUT}"
148148
exit 1
149149
fi

src/ct/trace/record.nim

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ proc resolveInterpreterCandidate(candidate: string): string =
4646

4747
""
4848

49-
proc resolvePythonInterpreter(): string =
49+
proc resolvePythonInterpreter(): tuple[path: string, error: string] =
5050
## Resolve the Python interpreter by inspecting common environment variables and PATH.
51+
## Authoritative overrides (env vars) must point to a valid interpreter; otherwise we surface the failure.
5152
let envCandidates = @[
5253
"CODETRACER_PYTHON_INTERPRETER",
5354
"PYTHON_EXECUTABLE",
@@ -60,14 +61,18 @@ proc resolvePythonInterpreter(): string =
6061
if value.len > 0:
6162
let resolved = resolveInterpreterCandidate(value)
6263
if resolved.len > 0:
63-
return resolved
64+
return (resolved, "")
65+
else:
66+
let trimmedValue = value.strip()
67+
let presentedValue = if trimmedValue.len > 0: trimmedValue else: value
68+
return ("", fmt"{envName} is set to '{presentedValue}' but it does not resolve to a Python interpreter. Update the variable or unset it to fall back to PATH detection.")
6469

6570
for binary in ["python3", "python", "py"]:
6671
let resolved = resolveInterpreterCandidate(binary)
6772
if resolved.len > 0:
68-
return resolved
73+
return (resolved, "")
6974

70-
""
75+
("", "")
7176

7277
type PythonRecorderCheckStatus = enum
7378
recorderPresent,
@@ -227,7 +232,10 @@ proc record*(lang: string,
227232
pargs.add(socketPath)
228233

229234
if detectedLang == LangPythonDb:
230-
let pythonInterpreter = resolvePythonInterpreter()
235+
let (pythonInterpreter, resolverError) = resolvePythonInterpreter()
236+
if resolverError.len > 0:
237+
echo "error: " & resolverError
238+
quit(1)
231239
if pythonInterpreter.len == 0:
232240
echo "error: Python interpreter not found. Set CODETRACER_PYTHON_INTERPRETER or ensure `python` is on PATH."
233241
quit(1)

0 commit comments

Comments
 (0)