Esempio n. 1
0
    def get_versions(self):
        versions = defaultdict(PathEntry)
        from pythonfinder._vendor.pep514tools import environment as pep514env

        env_versions = pep514env.findall()
        path = None
        for version_object in env_versions:
            install_path = getattr(version_object.info, 'install_path', None)
            if install_path is None:
                continue
            path = ensure_path(install_path.__getattr__(""))
            try:
                py_version = PythonVersion.from_windows_launcher(
                    version_object)
            except InvalidPythonVersion:
                continue
            self.version_list.append(py_version)
            base_dir = PathEntry.create(
                path,
                is_root=True,
                only_python=True,
                pythons={py_version.comes_from.path: py_version},
            )
            versions[py_version.version_tuple[:5]] = base_dir
            self.paths.append(base_dir)
        return versions
Esempio n. 2
0
    def get_versions(self):
        # type: () -> DefaultDict[Tuple, PathEntry]
        versions = defaultdict(PathEntry)  # type: DefaultDict[Tuple, PathEntry]
        from pythonfinder._vendor.pep514tools import environment as pep514env

        env_versions = pep514env.findall()
        path = None
        for version_object in env_versions:
            install_path = getattr(version_object.info, "install_path", None)
            if install_path is None:
                continue
            try:
                path = ensure_path(install_path.__getattr__(""))
            except AttributeError:
                continue
            try:
                py_version = PythonVersion.from_windows_launcher(version_object)
            except InvalidPythonVersion:
                continue
            if py_version is None:
                continue
            self.version_list.append(py_version)
            python_path = (
                py_version.comes_from.path
                if py_version.comes_from
                else py_version.executable
            )
            python_kwargs = {python_path: py_version} if python_path is not None else {}
            base_dir = PathEntry.create(
                path, is_root=True, only_python=True, pythons=python_kwargs
            )
            versions[py_version.version_tuple[:5]] = base_dir
            self.paths.append(base_dir)
        return versions
Esempio n. 3
0
 def _populate_windows_python_versions(cls):
     from pythonfinder._vendor.pep514tools import environment
     versions = environment.findall()
     path = None
     for version_object in versions:
         path = Path(version_object.info.install_path.__getattr__(
             '')).joinpath('python.exe')
         version = version_object.info.sys_version
         full_version = version_object.info.version
         architecture = getattr(version_object, 'sys_architecture',
                                SYSTEM_ARCH)
         for v in [version, full_version, architecture]:
             if not cls.PYTHON_VERSIONS.get(v):
                 cls.PYTHON_VERSIONS[v] = '{0}'.format(path)
         cls.register_python(path, full_version, architecture)
Esempio n. 4
0
    def get_versions(self):
        versions = defaultdict(PathEntry)
        from pythonfinder._vendor.pep514tools import environment as pep514env

        env_versions = pep514env.findall()
        path = None
        for version_object in env_versions:
            path = ensure_path(version_object.info.install_path.__getattr__(""))
            try:
                py_version = PythonVersion.from_windows_launcher(version_object)
            except InvalidPythonVersion:
                continue
            self.version_list.append(py_version)
            base_dir = PathEntry.create(
                path,
                is_root=True,
                only_python=True,
                pythons={py_version.comes_from.path: py_version},
            )
            versions[py_version.version_tuple[:5]] = base_dir
            self.paths.append(base_dir)
        return versions