Using Bzlmod with Bazel 6:
Add to your MODULE.bazel file:
bazel_dep(name = "aspect_rules_py", version = "1.7.0")And also register a Python toolchain, see rules_python. For example:
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(
python_version = "3.13",
)Using WORKSPACE
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "aspect_rules_py",
sha256 = "080a083244bb5307407e8099aabb1e0b8254d3af14c4c662a3841fcce05387f6",
strip_prefix = "rules_py-1.7.0",
url = "https://github.com/aspect-build/rules_py/releases/download/v1.7.0/rules_py-v1.7.0.tar.gz",
)
load("@aspect_rules_py//py:repositories.bzl", "rules_py_dependencies")
rules_py_dependencies()
load("@aspect_rules_py//py:toolchains.bzl", "rules_py_toolchains")
rules_py_toolchains()
# "Installation" for rules_python
load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains")
python_register_toolchains(
name = "python_toolchain",
python_version = "3.9",
)
py_repositories()