How to use the pythonfinder.Finder function in pythonfinder

To help you get started, we’ve selected a few pythonfinder examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sarugaku / pythonfinder / tests / test_utils.py View on Github external
def _get_python_versions():
    finder = Finder(global_search=True, system=False, ignore_unsupported=True)
    pythons = finder.find_all_python_versions()
    for v in pythons:
        py = v.py_version
        comes_from = getattr(py, "comes_from", None)
        if comes_from is not None:
            comes_from_path = getattr(comes_from, "path", v.path)
        else:
            comes_from_path = v.path
    return sorted(list(pythons))
github dephell / dephell / dephell / pythons.py View on Github external
class Python:
    path = attr.ib(type=Path)
    version = attr.ib(type=Version)
    name = attr.ib(type=str)
    implementation = attr.ib(type=str)
    abstract = attr.ib(type=bool, default=False)

    def get_short_version(self, size=2) -> Version:
        numbers = map(str, self.version.release[:size])
        return Version('.'.join(numbers))


@attr.s(slots=True)
class Pythons:
    abstract = attr.ib(type=bool, default=False)
    finder = Finder()

    # PROPERTIES

    @property
    def current(self):
        return Python(
            path=Path(sys.executable),
            name=Path(sys.executable).name,
            version=Version(python_version()),
            implementation=python_implementation(),
        )

    # PUBLIC METHODS

    def get_best(self, prefer: Union[None, Path, Version, RangeSpecifier] = None) -> Python:
        # no preferentions
github sarugaku / virtenv / virtenv_cli.py View on Github external
def __call__(self, value):
        if os.path.isabs(value):
            return str(value)
        full = which(value)
        if full:
            return full
        import pythonfinder
        python = pythonfinder.Finder().find_python_version(value)
        if python:
            return str(python.path)
        raise ValueError(value)