def test_get_custom_python_exe37(self): exe = pytype_source_utils.get_custom_python_exe((3, 7)) if sys.version_info[:2] == (3, 7): self.assertIsNone(exe) elif os.path.exists(pytype_source_utils.CUSTOM_PY37_EXE): self.assertIn("3.7", exe) else: self.assertIsNone(exe)
def get_python_exe(python_version): """Automatically infer the --python_exe argument. Arguments: python_version: the version tuple (e.g. (2, 7)) Returns: The inferred python_exe argument """ python_exe = "python%d.%d" % python_version # Use custom interpreters, if provided, in preference to the ones in $PATH custom_python_exe = pytype_source_utils.get_custom_python_exe(python_exe) if custom_python_exe: python_exe = custom_python_exe if USE_ANNOTATIONS_BACKPORT and python_version == (2, 7): python_exe += " -T" return python_exe
def get_python_exe(python_version): """Automatically infer the --python_exe argument. Arguments: python_version: the version tuple (e.g. (2, 7)) Returns: A tuple of the inferred python_exe argument and any command-line flags """ # Use custom interpreters, if provided, in preference to the ones in $PATH custom_python_exe = pytype_source_utils.get_custom_python_exe(python_version) if custom_python_exe: python_exe = custom_python_exe else: python_exe = "python%d.%d" % python_version if USE_ANNOTATIONS_BACKPORT and python_version == (2, 7): flags = ["-T"] else: flags = [] return python_exe, flags
def get_python_exes(python_version) -> Iterable[List[str]]: """Find possible python executables to use. Arguments: python_version: the version tuple (e.g. (3, 7)) Yields: The path to the executable """ # Use custom interpreters, if provided, in preference to the ones in $PATH custom_python_exe = pytype_source_utils.get_custom_python_exe( python_version) if custom_python_exe: yield [custom_python_exe] return for version in (format_version(python_version), "3"): if sys.platform == "win32": python_exe = ["py", f"-{version}"] else: python_exe = [f"python{version}"] yield python_exe
def get_python_exe(python_version) -> Tuple[List[str], List[str]]: """Find a python executable to use. Arguments: python_version: the version tuple (e.g. (2, 7)) Returns: A tuple of the path to the executable and any command-line flags """ # Use custom interpreters, if provided, in preference to the ones in $PATH custom_python_exe = pytype_source_utils.get_custom_python_exe(python_version) if custom_python_exe: python_exe = [custom_python_exe] elif sys.platform == "win32": python_exe = ["py", "-%d.%d" % python_version] else: python_exe = ["python%d.%d" % python_version] if USE_ANNOTATIONS_BACKPORT and python_version == (2, 7): flags = ["-T"] else: flags = [] return python_exe, flags
def testGetCustomPythonExe3(self): exe = pytype_source_utils.get_custom_python_exe(sys.version_info[:2]) self.assertIn("python3", exe)
def testGetCustomPythonExe27(self): exe = pytype_source_utils.get_custom_python_exe((2, 7)) self.assertIn("2.7", exe)
def testGetCustomPythonExe27(self): exe = pytype_source_utils.get_custom_python_exe((2, 7)) if utils.USE_ANNOTATIONS_BACKPORT: self.assertIn("2.7", exe) else: self.assertIsNone(exe)
def test_get_custom_python_exe3(self): exe = pytype_source_utils.get_custom_python_exe(sys.version_info[:2]) self.assertIsNone(exe)