Implementation:Mlflow Mlflow Build Packages
| Knowledge Sources | |
|---|---|
| Domains | Build System, Package Distribution |
| Last Updated | 2026-02-13 20:00 GMT |
Overview
Build script that produces MLflow Python distribution packages (wheel and sdist) for the four package variants: dev, release, skinny, and tracing.
Description
This script is the central build orchestrator for all MLflow distribution packages used in CI/CD and PyPI publishing. It defines four Package dataclass configurations:
- DEV - The full development mlflow package built from the repository root
- RELEASE - The release variant of mlflow, built with pyproject.release.toml swapped in for pyproject.toml
- SKINNY - The lightweight mlflow-skinny package built from libs/skinny
- TRACING - The mlflow-tracing package built from libs/tracing
The build process follows these steps:
- Git submodule initialization - Ensures submodules like mlflow/assistant/skills are up to date
- Artifact cleanup - Removes build/, dist/, and .egg_info directories from previous builds
- pyproject.toml swap - For release builds, temporarily replaces the development pyproject.toml with pyproject.release.toml
- Package build - Invokes python -m build on the selected package path
- Distribution consolidation - For skinny and tracing packages, moves artifacts from their subdirectory dist/ to the top-level dist/
- SHA tagging (optional) - Appends a git SHA as a build tag to the wheel filename (format: 0.sha.<commit-sha>)
The restore_changes context manager ensures that README.md and pyproject.toml are always restored to their original state via git restore after the build, even if an error occurs.
Usage
Run this script from the repository root during CI/CD or local development to build MLflow packages. Use the --package-type argument to select which variant to build, and optionally --sha to include a git commit hash in the wheel filename for traceability.
Code Reference
Source Location
- Repository: Mlflow_Mlflow
- File: dev/build.py
- Lines: 1-121
Signature
@dataclass(frozen=True)
class Package:
pypi_name: str
type: str
build_path: str
def parse_args() -> argparse.Namespace: ...
@contextlib.contextmanager
def restore_changes() -> Generator[None, None, None]: ...
def main() -> None: ...
Import
# Run directly as a script
python dev/build.py --package-type dev
python dev/build.py --package-type release --sha abc123
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| --package-type | str | No | Package variant to build: "dev" (default), "release", "skinny", or "tracing" |
| --sha | str | No | Git commit SHA to include as a build tag in the wheel filename |
Outputs
| Name | Type | Description |
|---|---|---|
| dist/*.whl | File | Built wheel distribution for the selected package |
| dist/*.tar.gz | File | Built source distribution (sdist) for the selected package |
Usage Examples
Building the Development Package
# Build the default dev package
# python dev/build.py
# Build the release package with SHA tag
# python dev/build.py --package-type release --sha $(git rev-parse --short HEAD)
# Build the skinny package
# python dev/build.py --package-type skinny
Package Definitions
DEV = Package("mlflow", "dev", ".")
RELEASE = Package("mlflow", "release", ".")
SKINNY = Package("mlflow-skinny", "skinny", "libs/skinny")
TRACING = Package("mlflow-tracing", "tracing", "libs/tracing")