This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

Py

Python rules

This package owns the repository Python dependency manifest pyproject.toml and native uv.lock. Update it with //tools/py:uv_lock.update; root //:uv_lock.update is an alias. Bazel’s pip.parse reads uv.lock directly, and Gazelle uses that same lock to validate its import manifest. There are no requirements-file exports or separately maintained pip locks.

BUILD files load lock directly from @rules_python//python/uv:lock.bzl with out = "uv.lock", which selects native uv lock. Build uv_lock to regenerate the lock without modifying source. Run uv_lock.update to replace the checked-in file, then review package versions, hashes and platform/Python markers. Extras are declared in pyproject.toml and retained in the native lock.

The same workflow owns component-local manifests and locks in //tools/ansible, //tools/ykman, //projects/autoscroll and //projects/infinitime. Update each through its own uv_lock.update target. Lock generation needs PyPI access, so only the upstream resolution action carries requires-network; it remains sandboxed. All locking targets are manual. Normal consumers use checked-in locks without running resolution, and there is no custom lock freshness test.

include.MODULE.bazel pins uv and Python 3.14.4, the newest stable runtime in rules_python 2.4.2’s bundled version catalog. This updates Bazel-managed Python without changing the host interpreter or adding a custom runtime archive.

The root pyproject.toml contains only shared tool settings. Ruff and other Python tools discover it from source packages, and the repository checker targets use //tools/py:pyproject to select those settings explicitly. The manifest in this package contains only project metadata and dependencies.

The repo-python skill owns the repository Python implementation and review procedure, including mandatory type hints. Its discovery link is generated by //.agents:write_skills.

1 - Bzl

Bazel code

1.1 - al_genrule_with_wheels

al_genrule_with_wheels

load("@com_alwaldend_src//tools/py/rules:al_genrule_with_wheels.bzl", "al_genrule_with_wheels")

al_genrule_with_wheels(name, wheels, srcs, cmd, **kwargs)

Regular genrule with wheels added to ${PYTHONPATH}

PARAMETERS

NameDescriptionDefault Value
namegenrule namenone
wheelslist of wheel labelsnone
srcssrcs for the genrule[]
cmdgenrule cmd[]
kwargsother genrule kwargsnone

1.2 - al_py_binary_shell

al_py_binary_shell

load("@com_alwaldend_src//tools/py/rules:al_py_binary_shell.bzl", "al_py_binary_shell")

al_py_binary_shell(name, deps, srcs, shell_type, shell_label, **kwargs)

Create a py_binary target that allows you to run commands in proper python environment

PARAMETERS

NameDescriptionDefault Value
nametarget namenone
depspy_binary deps[]
srcspy_binary srcs[]
shell_type${BAZEL_PYTHON_SHELL_TYPE}"python"
shell_label

-

"//tools/py/cmd/bazel_python_shell:bazel_python_shell_lib"
kwargsother py_binary kwargsnone

1.3 - al_py_checker

al_py_checker

load("@com_alwaldend_src//tools/py/rules:al_py_checker.bzl", "al_py_checker")

al_py_checker(name, tool, args_bin, args_test, test_size, disable_fix, **kwargs)

Create -fix and -test targets for a python checker

PARAMETERS

NameDescriptionDefault Value
nameName prefixNone
toolTool labelNone
args_binArgs for the binary targetNone
args_testArgs for the testNone
test_size

-

"small"
disable_fixIf set, do not create fix targetFalse
kwargsKwargs for both targetsnone

1.4 - al_py_checkers

al_py_checkers

load("@com_alwaldend_src//tools/py/rules:al_py_checkers.bzl", "al_py_checkers")

al_py_checkers(name, srcs, isort_label, black_label, mypy_label, flake8_label, pyproject_label)

Generate -fix and -test targets for python checkers

PARAMETERS

NameDescriptionDefault Value
name

-

none
srcslist of source file labelsnone
isort_label

-

"//tools/isort"
black_label

-

"//tools/black"
mypy_label

-

"//tools/mypy"
flake8_label

-

"//tools/flake8"
pyproject_label

-

"//tools/py:pyproject"