# Released under the MIT License. See LICENSE for details.#"""This module defines the major Python version we are using in the project.Tools that need to do some work or regenerate files when this changes canadd this submodule file as a dependency."""frompathlibimportPath# import subprocessPYVER='3.12'PYVERNODOT=PYVER.replace('.','')_checked_valid_sys_executable=False# pylint: disable=invalid-name_valid_sys_executable:str|None=None
[docs]defget_project_python_executable(projroot:Path|str)->str:"""Return the path to a standalone Python interpreter for this project. In some cases, using sys.executable will return an executable such as a game binary that contains an embedded Python but is not actually a standard interpreter. Tool functionality can use this instead when an interpreter is needed. """ifisinstance(projroot,str):projroot=Path(projroot)path=Path(projroot,f'.venv/bin/python{PYVER}')ifnotpath.exists():raiseRuntimeError(f"Expected project Python executable not found at '{path}'.")returnstr(path)