Manages Flavor helper binaries (launchers and builders).
Initialize the helper manager.
Source code in flavor/helpers/manager.py
| def __init__(self) -> None:
"""Initialize the helper manager."""
self.flavor_root = Path(__file__).parent.parent.parent.parent
self.helpers_dir = self.flavor_root / "dist"
self.helpers_bin = self.helpers_dir / "bin"
# Also check XDG cache location for installed helpers
xdg_cache = os.environ.get("XDG_CACHE_HOME", str(Path("~/.cache").expanduser()))
self.installed_helpers_bin = Path(xdg_cache) / "flavor" / "helpers" / "bin"
# Source directories are in src/<language>
self.go_src_dir = self.flavor_root / "src" / "flavor-go"
self.rust_src_dir = self.flavor_root / "src" / "flavor-rs"
# Ensure helpers directories exist
ensure_dir(self.helpers_dir)
ensure_dir(self.helpers_bin)
# Detect current platform using centralized utility
self.current_platform = get_platform_string()
# Binary loader for complex operations
from flavor.helpers.binary_loader import BinaryLoader
self._binary_loader = BinaryLoader(self)
|
Functions
build_helpers
build_helpers(
language: str | None = None, force: bool = False
) -> list[Path]
Build helper binaries from source.
Source code in flavor/helpers/manager.py
| def build_helpers(self, language: str | None = None, force: bool = False) -> list[Path]:
"""Build helper binaries from source."""
return self._binary_loader.build_helpers(language, force)
|
clean_helpers
clean_helpers(language: str | None = None) -> list[Path]
Clean built helper binaries.
Source code in flavor/helpers/manager.py
| def clean_helpers(self, language: str | None = None) -> list[Path]:
"""Clean built helper binaries."""
return self._binary_loader.clean_helpers(language)
|
get_helper
get_helper(name: str) -> Path
Get path to a helper binary.
Source code in flavor/helpers/manager.py
| def get_helper(self, name: str) -> Path:
"""Get path to a helper binary."""
return self._binary_loader.get_helper(name)
|
get_helper_info
get_helper_info(name: str) -> HelperInfo | None
Get detailed information about a specific helper.
Source code in flavor/helpers/manager.py
| def get_helper_info(self, name: str) -> HelperInfo | None:
"""Get detailed information about a specific helper."""
helper_path = self.helpers_bin / name
if helper_path.exists():
return self._get_helper_info(helper_path)
# Try to find by partial name
helpers = self.list_helpers()
for helper_list in [helpers["launchers"], helpers["builders"]]:
for helper in helper_list:
if name in helper.name:
return helper
return None
|
list_helpers
list_helpers(
platform_filter: bool = False,
) -> dict[str, list[HelperInfo]]
List all available helpers.
Parameters:
| Name |
Type |
Description |
Default |
platform_filter
|
bool
|
Only show helpers compatible with current platform
|
False
|
Returns:
| Type |
Description |
dict[str, list[HelperInfo]]
|
Dict with keys 'launchers' and 'builders', each containing HelperInfo lists
|
Source code in flavor/helpers/manager.py
| def list_helpers(self, platform_filter: bool = False) -> dict[str, list[HelperInfo]]: # noqa: C901
"""List all available helpers.
Args:
platform_filter: Only show helpers compatible with current platform
Returns:
Dict with keys 'launchers' and 'builders', each containing HelperInfo lists
"""
helpers: dict[str, list[HelperInfo]] = {"launchers": [], "builders": []}
# Search for helpers in bin directory
if self.helpers_bin.exists():
for helper_path in self.helpers_bin.iterdir():
if helper_path.is_file():
if platform_filter and not self._is_platform_compatible(helper_path.name):
continue
info = self._get_helper_info(helper_path)
if info:
if info.type == "launcher":
helpers["launchers"].append(info)
elif info.type == "builder":
helpers["builders"].append(info)
# Also check embedded helpers from wheel installation
embedded_bin = Path(__file__).parent / "bin"
if embedded_bin.exists():
for helper_path in embedded_bin.iterdir():
if helper_path.is_file():
if platform_filter and not self._is_platform_compatible(helper_path.name):
continue
info = self._get_helper_info(helper_path)
if info:
# Check if we already have this helper from dev build
existing_names = [i.name for sublist in helpers.values() for i in sublist]
if info.name not in existing_names:
if info.type == "launcher":
helpers["launchers"].append(info)
elif info.type == "builder":
helpers["builders"].append(info)
return helpers
|
test_helpers
test_helpers(language: str | None = None) -> dict[str, Any]
Test helper binaries.
Source code in flavor/helpers/manager.py
| def test_helpers(self, language: str | None = None) -> dict[str, Any]:
"""Test helper binaries."""
return self._binary_loader.test_helpers(language)
|