For more detailed setup instructions, see https://rules-python.readthedocs.io/en/latest/getting-started.html
For the user-facing changelog see here
Using Bzlmod
Add to your MODULE.bazel file:
bazel_dep(name = "rules_python", version = "2.2.0")
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(
python_version = "3.13",
)
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
pip.parse(
hub_name = "pypi",
python_version = "3.13",
requirements_lock = "//:requirements_lock.txt",
)
use_repo(pip, "pypi")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 = "e11d2e1efce1589e5bdfa93986712c74fc7467a0f093143d489d2ef5ebb1ed2a",
strip_prefix = "rules_python-2.2.0",
url = "https://github.com/bazel-contrib/rules_python/releases/download/2.2.0/rules_python-2.2.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 = "e11d2e1efce1589e5bdfa93986712c74fc7467a0f093143d489d2ef5ebb1ed2a",
strip_prefix = "rules_python-2.2.0/gazelle",
url = "https://github.com/bazel-contrib/rules_python/releases/download/2.2.0/rules_python-2.2.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
- chore: generate release changelog from news entries by @rickeylev in #3827
- fix(coverage): skip lcov report when no data was collected by @maxbirkner in #3832
- fix(pypi): respect empty envsubst expansion in experimental_index_url by @kriscfoster in #3828
- refactor(pypi): don't use Python to patch wheels by @aignas in #3808
- feat(py_info): expose VenvSymlinkEntry and VenvSymlinkKind as public APIs by @rickeylev in #3835
- doc: merge news into generated changelog by @rickeylev in #3836
- ci: enable bazel-diff by @rickeylev in #3838
- fix: run bazel-diff in cquery mode under bazelci by @rickeylev in #3839
- ci: disable bazel-diff due to platform compatibility conflicts by @rickeylev in #3840
- chore: warn on implicit init.py creation by @rickeylev in #3841
- fix(bootstrap): use retry loop for win32 version lookup in site init template by @rickeylev in #3842
- fix(rules): disambiguate slash target venv outputs by @gleyba in #3845
- chore: automate releases by @rickeylev in #3833
- build(deps): bump actions/checkout from 6 to 7 by @dependabot[bot] in #3843
- chore: remove accidentally committed release automation plan by @rickeylev in #3846
- feat: unified pypi hub repository by @rickeylev in #3837
- feat(pypi): support importing uv.lock file by @aignas in #3785
- chore: add agent rule to base new branches on upstream/main by @rickeylev in #3849
- build(ci): consolidate PR guardrails and block draft files by @rickeylev in #3859
- refactor: use gazelle for bzl_library management by @rickeylev in #3852
- fix(ci): use --repo flag in gh pr diff to avoid checkout by @rickeylev in #3861
- feat: stop using chmod on Bazel 8.6+ by @aignas in #3855
- ci: make pr-metadata-check run on PR body edit by @rickeylev in #3862
- chore(pypi): cleanup unused code by @aignas in #3864
- chore(release): correct version tagging and improve promotion flow by @rickeylev in #3866
- chore(release): add dry-run to release tool prepare command by @rickeylev in #3869
- chore(release): reuse existing PRs and avoid early exit in prep tool by @rickeylev in #3870
- chore(release): use force push and clean up git helpers in prep tool by @rickeylev in #3873
- Prepare release v2.2.0 by @github-actions[bot] in #3874
New Contributors
- @maxbirkner made their first contribution in #3832
- @kriscfoster made their first contribution in #3828
- @github-actions[bot] made their first contribution in #3874
Full Changelog: 2.1.0...2.2.0