Team Ai
Apppublic

openenv/coding_env

sourceHugging Faceupdated 3mo agoView on Hugging Face
21likes
__init__.py63 linesDownload Raw Back to openenv
1"""Unified OpenEnv package bundling the CLI and core runtime."""2 3from __future__ import annotations4 5from importlib import import_module, metadata6 7__all__ = [8    "core",9    "cli",10    "AutoEnv",11    "AutoAction",12    "GenericEnvClient",13    "GenericAction",14    "SyncEnvClient",15]16 17 18def _load_package_version() -> str:19    """Resolve the installed distribution version for the OpenEnv package."""20    for distribution_name in ("openenv-core", "openenv"):21        try:22            return metadata.version(distribution_name)23        except metadata.PackageNotFoundError:24            continue25    return "0.0.0"26 27 28__version__ = _load_package_version()29 30 31_LAZY_MODULES = {32    "core": ".core",33    "cli": ".cli",34}35 36_LAZY_ATTRS = {37    "AutoEnv": (".auto", "AutoEnv"),38    "AutoAction": (".auto", "AutoAction"),39    "GenericEnvClient": (".core", "GenericEnvClient"),40    "GenericAction": (".core", "GenericAction"),41    "SyncEnvClient": (".core", "SyncEnvClient"),42}43 44 45def __getattr__(name: str):46    if name in _LAZY_MODULES:47        module = import_module(_LAZY_MODULES[name], __name__)48        globals()[name] = module49        return module50 51    if name in _LAZY_ATTRS:52        module_path, attr_name = _LAZY_ATTRS[name]53        module = import_module(module_path, __name__)54        value = getattr(module, attr_name)55        globals()[name] = value56        return value57 58    raise AttributeError(f"module {__name__!r} has no attribute {name!r}")59 60 61def __dir__() -> list[str]:62    return sorted(set(globals().keys()) | set(__all__))63