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 = "1.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 = "2ef40fdcd797e07f0b6abda446d1d84e2d9570d234fddf8fcd2aa262da852d1c",
strip_prefix = "rules_python-1.2.0",
url = "https://github.com/bazelbuild/rules_python/releases/download/1.2.0/rules_python-1.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 = "2ef40fdcd797e07f0b6abda446d1d84e2d9570d234fddf8fcd2aa262da852d1c",
strip_prefix = "rules_python-1.2.0/gazelle",
url = "https://github.com/bazelbuild/rules_python/releases/download/1.2.0/rules_python-1.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
- docs: Add horizontal spacers around filenames in custom toolchain guide by @nicholasjng in #2563
- fix: Avoid creating URLs with empty path segments from index URLs in environment variables by @WillMorrison in #2557
- docs: update gazelle README.md by @alexeagle in #2567
- fix: Don't fail in override from a non-root module by @mailto-jonas in #2566
- chore: remove internal usage of deprecated py_binary ad py_test by @aignas in #2569
- fix: Fix encoding of runfiles manifest and repository mapping files. by @phst in #2568
- fix: make coverage work with bootstrap=script by @rickeylev in #2574
- doc: point users to our CHANGELOG at the top of the release note by @aignas in #2582
- fix: Enable location expansion for
sh_py_run_test
by @philsc in #2583 - fix(sphinxdocs): do not crash when tag_class does not have doc by @aignas in #2585
- refactor(uv): move around uv implementation files by @aignas in #2580
- revert: Updated pip and packaging versions to work with free-threading packages (#2514) by @aignas in #2584
- docs: using python_version attribute for specifying python version by @JeroenSchmidt in #2589
- fix: make plain zipapp work with bootstrap=script by @rickeylev in #2598
- fix: add flag to use runtime venv creation when using bootstrap=script by @rickeylev in #2590
- docs: Update URL in gazelle example by @hofbi in #2602
- refactor: expose base rule construction via builders to allow customization for testing by @rickeylev in #2600
- feat: Remove and redirect py_proto_library to protobuf by @comius in #2604
- chore: updates for 1.2.0 release by @rickeylev in #2611
New Contributors
- @mailto-jonas made their first contribution in #2566
- @JeroenSchmidt made their first contribution in #2589
- @hofbi made their first contribution in #2602
Full Changelog: 1.1.0...1.2.0