Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Bentoml BentoML Project Configuration

From Leeroopedia
Knowledge Sources
Domains Build System, Configuration, Packaging
Last Updated 2026-02-13 15:00 GMT

Overview

The root pyproject.toml configuration file that defines the BentoML package metadata, dependencies, build system, optional extras, and tool configurations for linting, testing, type checking, and code coverage.

Description

This file is the single source of truth for the BentoML Python package configuration. It is structured into the following major sections:

  1. Project metadata ([project]): Defines the package name (bentoml), description, license (Apache-2.0), authors, Python version requirement (>=3.9), keywords, and PyPI classifiers. The version is dynamic, derived from VCS (Git tags).
  2. Dependencies: Lists approximately 40 core runtime dependencies including pydantic, starlette, uvicorn, httpx, click, numpy, rich, opentelemetry-* instrumentation packages, cloudpickle, PyYAML, Jinja2, prometheus-client, and others.
  3. Optional dependencies ([project.optional-dependencies]): Defines extras groups: all, aws (S3 support), io (image/pandas I/O), triton, unsloth, grpc (with reflection and channelz sub-extras), tracing (Jaeger, Zipkin, OTLP), and monitor-otlp.
  4. Build system ([build-system]): Uses hatchling as the build backend with hatch-vcs for version management from Git tags. Configures version file generation at src/bentoml/_version.py using a post-release versioning scheme.
  5. Package structure: The wheel includes four source packages: src/bentoml, src/bentoml_cli, src/_bentoml_sdk, and src/_bentoml_impl.
  6. Entry points ([project.scripts]): Registers the bentoml CLI command pointing to bentoml_cli.cli:cli.
  7. Tool configurations:
    • Ruff ([tool.ruff]): Linting and formatting with line length 88, Python 3.10 target, isort integration, ignoring E501, and Google-style docstrings.
    • Pytest ([tool.pytest.ini_options]): Test configuration with custom plugin (bentoml.testing.pytest.plugin) and test paths in tests/.
    • Coverage ([tool.coverage]): Branch coverage with specific omissions for generated gRPC code, testing utilities, and other non-critical paths.
    • Pyright ([tool.pyright]): Strict type checking with Python 3.12 target, comprehensive error reporting settings, and exclusions for generated protobuf files.
  8. Dependency groups ([dependency-groups]): Defines docs (Sphinx and related), tooling (pre-commit, nox), and testing (pytest, coverage, scikit-learn) groups.

Usage

This file is consumed by build tools (pip install, hatch build), linters (ruff), type checkers (pyright), test runners (pytest), and CI/CD pipelines. Developers modify it to update dependencies, adjust tool settings, or change package metadata.

Code Reference

Source Location

Signature

[project]
name = "bentoml"
requires-python = ">=3.9"
license = { text = "Apache-2.0" }
dynamic = ["version"]

[build-system]
requires = ['hatchling', "hatch-vcs>=0.3.0"]
build-backend = 'hatchling.build'

[project.scripts]
bentoml = "bentoml_cli.cli:cli"

Import

# Install from source with all extras
pip install -e ".[all]"

# Install with specific extras
pip install "bentoml[grpc,tracing,io]"

# Build the package
hatch build

I/O Contract

Inputs

Name Type Required Description
Git tags VCS tags Yes Used by hatch-vcs to derive the package version dynamically
Source packages Python source Yes src/bentoml, src/bentoml_cli, src/_bentoml_sdk, src/_bentoml_impl

Outputs

Name Type Description
bentoml package Python wheel/sdist Built distribution package with metadata and dependencies
bentoml CLI Console script bentoml command registered as entry point
_version.py Python file Auto-generated version file at src/bentoml/_version.py

Usage Examples

# Install BentoML in development mode
pip install -e ".[all]"

# Run linting
ruff check src/

# Run type checking
pyright

# Run tests
pytest tests/

# Build distribution
hatch build

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment