Skip to main content

judge.resolve_python

judge.resolve_python(root, python)

The interpreter that scores candidates.

Parameters

Name Type Description Default
root Path Repository root. required
python Path | None The --python option, or None. required

Returns

Name Type Description
Path Path The absolute path of python if given, else of <root>/.venv/bin/python if it exists, else of the interpreter running spotregen. The path is made absolute with os.path.abspath, which does not follow symbolic links, so that the interpreter of a virtual environment keeps its environment. Scoring processes run in the worktree, where a relative path would not be found.

Raises

Name Type Description
ConfigurationError If the interpreter does not exist or is not executable.

Examples

import sys
from pathlib import Path
from tempfile import TemporaryDirectory

from spotregen.judge import resolve_python

with TemporaryDirectory() as tmp:
    print(resolve_python(Path(tmp), None) == Path(sys.executable))
True