Skip to main content

judge.tool_versions

judge.tool_versions(python, source_dir, timeout)

The Python and pytest versions and the installed distributions of the scorer.

The probe runs in the scoring environment in a neutral temporary directory, not in the caller’s (python -c puts the working directory first on sys.path). The third value is the SHA-256 of the sorted lines name==version of every distribution the interpreter finds (the name in lower case, each run of -, _ and . as one -), joined by newlines. A virtual environment is mutable; this is what shows that two runs scored in the same one.

Parameters

Name Type Description Default
python Path The interpreter that scores. required
source_dir str Directory that holds the package, for PYTHONPATH. required
timeout float Seconds the probe may take. required

Returns

Name Type Description
tuple[str, str, str] tuple[str, str, str]: (python version, pytest version, packages hash).

Raises

Name Type Description
ExternalToolError If the probe cannot be run, fails (pytest is not installed), times out or prints something else. There is no "unknown": a verdict from an environment nobody can name would be a verdict about the machine.

Examples

import sys
from pathlib import Path

from babregen.judge import tool_versions

python, pytest_version, packages = tool_versions(Path(sys.executable), "src", 60)
print(python == sys.version.split()[0], len(packages))
True 64