Skip to content

0.22.1

Compare
Choose a tag to compare
@github-actions github-actions released this 19 Dec 21:38
· 645 commits to main since this release

This is a patch release of 0.22.0 that automatically registers the @bazel_tools//tools/python:autodetecting_toolchain toolchain.

See bazelbuild/bazel#20458 for more information.

Using Bzlmod with Bazel 6

Add to your MODULE.bazel file:

bazel_dep(name = "rules_python", version = "0.22.1")

pip = use_extension("@rules_python//python:extensions.bzl", "pip")

pip.parse(
    name = "pip",
    requirements_lock = "//:requirements_lock.txt",
)

use_repo(pip, "pip")

# (Optional) Register a specific python toolchain instead of using the host version
python = use_extension("@rules_python//python:extensions.bzl", "python")

python.toolchain(
    name = "python3_9",
    python_version = "3.9",
)

use_repo(python, "python3_9_toolchains")

register_toolchains(
    "@python3_9_toolchains//:all",
)

Using WORKSPACE

Paste this snippet into your WORKSPACE file:

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "rules_python",
    sha256 = "a5640fddd4beb03e8c1fde5ed7160c0ba6bd477e7d048661c30c06936a26fd63",
    strip_prefix = "rules_python-0.22.1",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.22.1/rules_python-0.22.1.tar.gz",
)

load("@rules_python//python:repositories.bzl", "py_repositories")

py_repositories()

Gazelle plugin

Paste this snippet into your WORKSPACE file:

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
    name = "rules_python_gazelle_plugin",
    sha256 = "a5640fddd4beb03e8c1fde5ed7160c0ba6bd477e7d048661c30c06936a26fd63",
    strip_prefix = "rules_python-0.22.1/gazelle",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.22.1/rules_python-0.22.1.tar.gz",
)

# To compile the rules_python gazelle extension from source,
# we must fetch some third-party go dependencies that it uses.

load("@rules_python_gazelle_plugin//:deps.bzl", _py_gazelle_deps = "gazelle_deps")

_py_gazelle_deps()

Full Changelog: 0.22.0...0.22.1