Skip to main content

Python SDK

RBS provides first-class Python support with hermetic toolchains, automatic dependency resolution, test coverage enforcement, and linting — all without requiring pip, venv, or any system-installed Python.

Setup

Toolchain

Register a Python toolchain in your WORKSPACE.rbs. RBS automatically downloads and manages the interpreter.

Dependencies

Define external packages using py_repository. RBS resolves and caches them hermetically.

Linting

Register Python linters (Black, isort, Flake8, Ruff) for workspace-wide use:

Rules

py_library

Creates a reusable Python library that other targets can depend on.

py_binary

Creates an executable Python application with all dependencies bundled.

py_test

Runs Python tests with optional coverage thresholds. Pytest is auto-included — no manual dependency needed.

py_lint

Runs linters (Black + isort by default) on Python source files.

Example: Django Blog

A complete Django application with development/production servers, management commands, and linting.

Commands