Skip to content

yggdrasil.environ.modules

modules

Module path / distribution lookup helpers.

packages_distributions_cached

packages_distributions_cached() -> Dict[str, List[str]]

Memoized :func:importlib.metadata.packages_distributions.

Walks every installed distribution exactly once per process and caches the mapping {top_level_module: [dist_name, ...]}. Used by the jobs introspection and workspace-PyPI publishing paths, both of which call this on every staged task and would otherwise re-scan site-packages for every module they touch.

module_name_to_project_name

module_name_to_project_name(module_name: str) -> str

Map module import names to PyPI project names when they differ.

resolve_local_lib_path

resolve_local_lib_path(lib: Union[str, ModuleType]) -> Path

Resolve a lib spec (path string, module name, or module object) into a concrete filesystem path.

Package-walk rule: - If the resolved path is inside a Python package (dir containing init.py), walk upward and return the top-most directory that still contains init.py. - If not in a package context, return the resolved file/dir.