Skip to content

0.22.0

Compare
Choose a tag to compare
@github-actions github-actions released this 25 May 20:09
· 726 commits to main since this release
693a158

Notable and Breaking Changes

Bzlmod extension paths have changed

As part of fixing some fundamental issues with the bzlmod support, we had to change the path to our extensions. Instead of all extensions being in a single extensions.bzl file, each extension is in its own file. Users must update the file path in their use_repo() statements as follows:

  • use_extension("@rules_python//python:extensions.bzl", "python") -> use_extension("@rules_python//python/extensions:python.bzl", "python")
  • use_extension("@rules_python//python:extensions.bzl", "pip") -> use_extension("@rules_python//python/extensions:pip.bzl", "pip")

The following sed commands should approximate the necessary changes:

sed 'sXuse_extension("@rules_python//python:extensions.bzl", "python")Xuse_extension("@rules_python//python/extensions:python.bzl", "python")X'`
sed 'sXuse_extension("@rules_python//python:extensions.bzl", "pip")Xuse_extension("@rules_python//python/extensions:pip.bzl", "pip")X'`

See examples/bzlmod_build_file_generation/MODULE.bazel for an example of the new paths.

Lockfile output churn

The output of lockfiles has slightly changed. Though functionally the same, their integrity hashes will change.


Using Bzlmod with Bazel 6

NOTE: Bzlmod support is still in beta.

Add to your MODULE.bazel file:

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

pip = use_extension("@rules_python//python/extensions:pip.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:python.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 = "863ba0fa944319f7e3d695711427d9ad80ba92c6edd0b7c7443b84e904689539",
    strip_prefix = "rules_python-0.22.0",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.22.0/rules_python-0.22.0.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 = "863ba0fa944319f7e3d695711427d9ad80ba92c6edd0b7c7443b84e904689539",
    strip_prefix = "rules_python-0.22.0/gazelle",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.22.0/rules_python-0.22.0.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()

What's Changed

  • fix: remove reference to @bazel_tools//tools/python/private:defs.bzl by @comius in #1173
  • docs: Tell how to use GitHub to find commits in an upcoming release. by @rickeylev in #1092
  • fix: compile_pip_requirements test from external repositories by @Rasrack in #1124
  • feat: add Python 3.8.16 by @jml-derek in #1168
  • test: Set mac platform for test_mac_requires_darwin_for_execution by @rickeylev in #1179
  • fix: Don't reference deleted private bazel_tools bzl file by @rickeylev in #1180
  • docs: Add starlark directive to code snippet by @blorente in #1170
  • tests: Upgrade rules_testing to 0.0.5 by @rickeylev in #1184
  • tests: Set linux platform for test_non_mac_doesnt_require_darwin_for_execution by @rickeylev in #1183
  • fix(bzlmod): correctly template repository macros for requirements, etc by @aignas in #1190
  • type:docs Update README.md by @yuanweixin in #1186
  • fix: Allow passing a tuple to the tags attribute. by @rickeylev in #1191
  • tests: Add skylib to various test dependencies to fix CI by @chrislovecnm in #1199
  • feat: removing bzlmod from example by @chrislovecnm in #1200
  • feat: propagate visibility attribute for py_wheel publishing by @chrislovecnm in #1203
  • docs: fix typos in pip_repository docs by @martis42 in #1202
  • tests: Force analysis test labels to resolve within @rules_python context by @rickeylev in #1187
  • fix(update_deleted_packages.sh): allow to run from anywhere in the repo by @aignas in #1206
  • feat(bzlmod): expose platform-agnostic repo target for toolchain interpreter by @chrislovecnm in #1155
  • fix(update_deleted_packages.sh): wheels example should not be included in .bazelrc by @aignas in #1207
  • fix: Strip trailing newline from python output by @illicitonion in #1212
  • fix: manually ignore bazel-* directories to make using custom Bazel builds easier by @rickeylev in #1181
  • test(bzlmod): explicitly enable bzlmod in the test harness by @aignas in #1204
  • feat(bzlmod): Cleaning up interpreter resolution by @chrislovecnm in #1218
  • feat(bzlmod)!: Move each bzlmod extension into its own file by @chrislovecnm in #1226
  • Adding bzlmod support document by @chrislovecnm in #1214
  • test(coverage): add a test to check the sys.path under bzlmod by @aignas in #1223
  • fix(toolchain): set correct return attrs to remove non-hermeticity warning by @aignas in #1231
  • fix: allow url fragments in requirements file by @mattoberle in #1195
  • fix: example/build_file_generation/README.md by @ofey404 in #1164
  • fix: Using canonical name in requirements.bzl by @linzhp in #1176
  • feat(bzlmod): support entry_point macro by @aignas in #1220

New Contributors

Full Changelog: 0.21.0...0.22.0