aspect-build / rules_py

More compatible Bazel rules for running Python tools and building Python projects
Apache License 2.0
86 stars 29 forks source link

fix: add toolchain setup to bzlmod release snippet #332

Closed mattem closed 7 months ago

mattem commented 7 months ago

Adds the bzlmod use_extension to the release instructions snippet. Will look something like:

Using Bzlmod with Bazel 6:

Add to your MODULE.bazel file:

bazel_dep(name = "aspect_rules_py", version = "")

tools = use_extension("@aspect_rules_py//py:extensions.bzl", "py_tools")
tools.rules_py_tools()
use_repo(tools, "rules_py_tools")

And also register a Python toolchain, see rules_python. For example:

# Minimum version needs:
# feat: add interpreter_version_info to py_runtime by @mattem in #1671
bazel_dep(name = "rules_python", dev_dependency = True, version = "0.29.0")

python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(
    configure_coverage_tool = True,
    python_version = "3.11",
)
alexeagle commented 7 months ago

Also the error in #331 is about rules_rust being absent, so I don't think this is the fix for it. Maybe we should repro first and figure out if we do have a bug and why CI is green?

mattem commented 7 months ago

Also the error in #331 is about rules_rust being absent, so I don't think this is the fix for it. Maybe we should repro first and figure out if we do have a bug and why CI is green?

Right, because the toolchain isn't registered, so it's attempting to build from source, which it can't.

alexeagle commented 7 months ago

Ah okay I will look again. I was not able to repro yet.

alexeagle commented 7 months ago

We register the toolchain for users here: https://github.com/aspect-build/rules_py/blob/main/MODULE.bazel#L21 so that explains why the existing test is green, there's no additional install snippet needed for users.