Skip to main content
Version: 0.4.x

Aspect's Bazel rules for Python

aspect_rules_py is a layer on top of rules_python, the standard Python ruleset hosted at The lower layer of rules_python is currently reused, dealing with the toolchain and dependencies.

However, this ruleset introduces a new implementation of py_library, py_binary, and py_test. Our philosophy is to behave more like idiomatic python ecosystem tools, where rules_python is closely tied to the way Google does Python development in their internal monorepo, google3.

rules: BUILD file UIrules_pythonrules_py
gazelle: generate BUILD filesrules_pythonrules_python [1]
pip_parse: fetch and install deps from pypirules_pythonrules_python
toolchain: fetch hermetic interpreterrules_pythonrules_python

Need help? This ruleset has support provided by

[1] we will likely fork the extension for performance, using TreeSitter to parse Python code rather than a Python program.


We think you'll love rules_py because:

[!NOTE] What about the "starlarkification" effort in rules_python?

We think this is only useful within Google, because the semantics of the rules will remain identical. Even though the code will live in bazelbuild/rules_python rather than bazelbuild/bazel, it still cannot change without breaking Google-internal usage, and has all the ergonomic bugs above due to the way the runtime is stubbed.


Follow instructions from the release you wish to use: