Runner
runner
Subprocess runner that targets the audited project's venv.
When auditing an external project, tools (ruff, mypy, pytest, etc.) must execute in that project's virtual environment, not axm-audit's own.
find_venv(project_path)
Locate the nearest .venv directory for a project.
Checks project_path first, then walks up the directory tree to
support uv monorepo workspaces where the shared .venv lives
at the workspace root rather than inside the individual package.
The search is bounded to :data:_MAX_VENV_SEARCH_DEPTH levels to
avoid accidentally picking up an unrelated .venv higher in the
file system.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_path
|
Path
|
Root of the project being audited. |
required |
Returns:
| Type | Description |
|---|---|
Path | None
|
The |
Path | None
|
environment exists in the project or any of its ancestors |
Path | None
|
(within the bounded depth). |
Source code in packages/axm-audit/src/axm_audit/core/runner.py
run_in_project(cmd, project_path, *, timeout=_DEFAULT_TIMEOUT, with_packages=None, capture_output=False, text=False, check=False)
Run a command in the target project's environment.
Locates the nearest .venv/ — either in project_path itself
or in an ancestor directory (for uv monorepo workspace members).
Uses uv run --directory to execute the command within the
correct environment. Falls back to running the command directly
with cwd set when no virtual environment is found.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cmd
|
list[str]
|
Command and arguments to run. |
required |
project_path
|
Path
|
Root of the project being audited. |
required |
timeout
|
int
|
Maximum seconds to wait before killing the subprocess. Defaults to 300 (5 minutes). |
_DEFAULT_TIMEOUT
|
with_packages
|
list[str] | None
|
Optional packages to inject at runtime via
|
None
|
capture_output
|
bool
|
Forwarded to |
False
|
text
|
bool
|
Forwarded to |
False
|
check
|
bool
|
Forwarded to |
False
|
Returns:
| Type | Description |
|---|---|
CompletedProcess[str]
|
CompletedProcess result. On timeout, returns a synthetic result |
CompletedProcess[str]
|
with |