Skip to content

environment_builder

flavor.packaging.python.environment_builder

Python environment builder for packaging operations.

Classes

PythonEnvironmentBuilder

PythonEnvironmentBuilder(
    python_version: str = "3.11",
    is_windows: bool = False,
    manylinux_tag: str = "manylinux2014",
)

Manages Python environment setup and distribution packaging.

Initialize environment builder.

Parameters:

Name Type Description Default
python_version str

Python version to use (e.g., "3.11")

'3.11'
is_windows bool

Whether building for Windows

False
manylinux_tag str

Manylinux tag for Linux compatibility

'manylinux2014'
Source code in flavor/packaging/python/environment_builder.py
def __init__(
    self,
    python_version: str = "3.11",
    is_windows: bool = False,
    manylinux_tag: str = "manylinux2014",
) -> None:
    """Initialize environment builder.

    Args:
        python_version: Python version to use (e.g., "3.11")
        is_windows: Whether building for Windows
        manylinux_tag: Manylinux tag for Linux compatibility
    """
    self.python_version = python_version
    self.is_windows = is_windows
    self.manylinux_tag = manylinux_tag
    self.uv_manager = UVManager()
    self.pypapip = PyPaPipManager()
    self.uv_exe = "uv.exe" if is_windows else "uv"
    self._dependency_resolver = DependencyResolver(is_windows)
Functions
create_python_placeholder
create_python_placeholder(python_tgz: Path) -> None

Download and package Python distribution using UV.

Source code in flavor/packaging/python/environment_builder.py
def create_python_placeholder(self, python_tgz: Path) -> None:
    """Download and package Python distribution using UV."""
    logger.debug(
        "💻🔍📋 Platform info",
        system=get_os_name(),
        machine=get_arch_name(),
    )

    with tempfile.TemporaryDirectory() as uv_install_dir:
        python_install_dir = self._install_python_with_uv(uv_install_dir)

        if not python_install_dir:
            self._create_fallback_python_tarball(python_tgz)
            return

        self._create_python_tarball(python_install_dir, python_tgz)
download_uv_wheel
download_uv_wheel(dest_dir: Path) -> Path | None

Download manylinux2014-compatible UV wheel using PIP - NOT UV!

Source code in flavor/packaging/python/environment_builder.py
def download_uv_wheel(self, dest_dir: Path) -> Path | None:
    """Download manylinux2014-compatible UV wheel using PIP - NOT UV!"""
    return self._dependency_resolver.download_uv_wheel(dest_dir)
find_uv_command
find_uv_command(
    raise_if_not_found: bool = True,
) -> str | None

Find the UV command.

Source code in flavor/packaging/python/environment_builder.py
def find_uv_command(self, raise_if_not_found: bool = True) -> str | None:
    """Find the UV command."""
    return self._dependency_resolver.find_uv_command(raise_if_not_found)