Repository URL to install this package:
Version:
0.1.16-1 ▾
|
odigos-demo-inventory
/
opt
/
odigos-demo-inventory
/
site-packages
/
findpython
/
providers
/
path.py
|
---|
from __future__ import annotations
import os
import typing as t
from dataclasses import dataclass
from pathlib import Path
from findpython.providers.base import BaseProvider
from findpython.python import PythonVersion
@dataclass
class PathProvider(BaseProvider):
"""A provider that finds Python from PATH env."""
paths: list[Path]
@classmethod
def create(cls) -> t.Self | None:
paths = [Path(path) for path in os.getenv("PATH", "").split(os.pathsep) if path]
return cls(paths)
def find_pythons(self) -> t.Iterable[PythonVersion]:
for path in self.paths:
yield from self.find_pythons_from_path(path)