1.6.0
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.6.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 = "fa7dd2c6b7d63b3585028dd8a90a6cf9db83c33b250959c2ee7b583a6c130e12",
strip_prefix = "rules_python-1.6.0",
url = "https://github.com/bazel-contrib/rules_python/releases/download/1.6.0/rules_python-1.6.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 = "fa7dd2c6b7d63b3585028dd8a90a6cf9db83c33b250959c2ee7b583a6c130e12",
strip_prefix = "rules_python-1.6.0/gazelle",
url = "https://github.com/bazel-contrib/rules_python/releases/download/1.6.0/rules_python-1.6.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: Fixup some typos in BuildKite job names by @dougthor42 in #2977
- refactor: Remove unused CC_TOOLCHAIN definition by @katre in #2981
- Fix argument name typo by @keith in #2984
- build(deps): bump certifi from 2025.1.31 to 2025.6.15 in /tools/publish by @dependabot[bot] in #2999
- build(deps): bump certifi from 2025.1.31 to 2025.6.15 in /docs by @dependabot[bot] in #3000
- build(deps): bump requests from 2.32.3 to 2.32.4 in /docs by @dependabot[bot] in #2965
- fix: use platform_info.target_settings in toolchain aliases by @aignas in #3001
- refactor(gazelle) Types for exposed members of
python.ParserOutput
are now all public by @yushan26 in #2959 - feat(pypi): pip.defaults API for customizing pipstar 1/n by @aignas in #2987
- feat(pypi): pip.defaults API for customizing repo selection 2/n by @aignas in #2988
- fix(toolchains): use posix-compatible exec -a alternative by @rickeylev in #3010
- build(deps): bump urllib3 from 2.4.0 to 2.5.0 in /tools/publish by @dependabot[bot] in #3008
- feat: support arbitrary target_settings in our platforms 3/n by @aignas in #2990
- docs: fix various typos and improve grammar by @rickeylev in #3015
- feat(gazelle): For package mode, resolve dependencies when imports are relative to the package path by @yushan26 in #2865
- fix: Fix bazel vendor support for requirements with environment markers by @armandomontanez in #2997
- fix(pypi): namespace_pkgs should pass correct arguments by @aignas in #3026
- fix: work around version parsing by only parsing if site-packages is enabled by @rickeylev in #3031
- docs,tests: Clarify how py_wheel.strip_path_prefixes works; add test case by @dougthor42 in #3027
- feat(gazelle): Add type-checking only dependencies to pyi_deps by @amartani in #3014
- fix: delete BUILD et al files from pypi sourced dependencies by @rickeylev in #3029
- fix(gazelle) Fix dependency added as both deps and pyi_deps by @amartani in #3036
- fix(gazelle) Register pyi_deps as ResolveAttrs by @amartani in #3037
- docs: Typo in gazelle/README.md by @jklukas in #3040
- feat(gazelle) Remove entry point file requirements when generating rules by @yushan26 in #2998
- fix: Don't let deprecated test targets get matched by '...' by @robinlinden in #3045
- fix: add py.typed to runfiles py_wheel so it gets packaged by @aaronsky in #3041
- docs: Add note about Python 3.9 to CHANGELOG.md by @thirtyseven in #3052
- fix: Updating Python toolchains to patch CVE-2025-47273 by @aaronmaxlevy in #3053
- docs: doc expectations of ai-assisted contributions by @rickeylev in #3051
- fix(local-toolchains): don't watch non-existent include directory by @rickeylev in #3048
- build(deps): bump urllib3 from 2.4.0 to 2.5.0 in /docs by @dependabot[bot] in #3042
- fix(pypi): only generate namespace package shims if implicit namespaces are disabled by @rickeylev in #3059
- feat: Add windows arm64 python toolchains by @AustinSchuh in #3062
- refactor(toolchains): better sha256 printing helper by @aignas in #3028
- refactor(pypi): move the platform config to MODULE.bazel by @aignas in #3064
- fix(pypi): correctly handle custom names in pipstar platforms by @aignas in #3054
- tests(pypi): add tests for namespace shims generation by @rickeylev in #3066
- build(deps): bump pygments from 2.19.1 to 2.19.2 in /docs by @dependabot[bot] in #3019
- build(deps): bump charset-normalizer from 3.4.1 to 3.4.2 in /docs by @dependabot[bot] in #3018
- fix: parsing local version with digit followed by non-digits by @rickeylev in #3032
- feat(pypi): generate filegroup with all extracted wheel files by @rickeylev in #3011
- docs: add whl_from_dir to dev guide docs by @rickeylev in #3067
- fix(toolchains): fix the URLs and sha256 values by @aignas in #3070
- chore: Switch back to smacker/go-tree-sitter by @dougthor42 in #3069
- build(deps): bump charset-normalizer from 3.4.1 to 3.4.2 in /tools/publish by @dependabot[bot] in #3020
- build(deps): bump pygments from 2.18.0 to 2.19.2 in /tools/publish by @dependabot[bot] in #3021
- ci: use Ubuntu 22.04 by @aignas in #3083
- fix(gazelle) Update gazelle to properly process multi-line python imports by @yushan26 in #3077
- feat(gazelle): Gazelle plugin generates py_proto_library by @shaldengeki in #3057
- feat(gazelle): Add
include_pytest_conftest
annotation by @dougthor42 in #3080 - docs: tell how to emulate dependency groups with pip-compile by @rickeylev in #3089
- chore: update python toolchains by @aignas in #3074
- feat: replace /bin/bash with /usr/bin/env bash by @fionera in #3087
- build(deps): bump certifi from 2025.6.15 to 2025.7.14 in /docs by @dependabot[bot] in #3092
- build(deps): bump certifi from 2025.6.15 to 2025.7.14 in /tools/publish by @dependabot[bot] in #3095
- fix: support debian multiarch with local toolchains by @rickeylev in #3100
- refactor(gazelle_manifest): print the wrong hash when encountered by @alexeagle in #3103
- feat(gazelle):
python_proto_naming_convention
directive controlspy_proto_library
naming by @shaldengeki in #3093 - fix(pypi): expose pypi packages only common to all python versions by @dotoleeoak in #3107
- fix: normalize stub_path in repl.bzl by @jpwoodbu in #3104
- build(deps): bump typing-extensions from 4.13.2 to 4.14.1 in /docs by @dependabot[bot] in #3094
- fix(gazelle): Do not resolve absolute imports to sibling modules by @amartani in #3106
- fix(pypi): show overridden index urls in pypi download error by @dotoleeoak in #3130
- chore: Remove aliases in //docs by @dougthor42 in #3125
- fix(gazelle): Rename experimental_allow_relative_imports directive to follow convention by @dougthor42 in #3128
- test: Print REPL error message during test failures by @philsc in #3124
- docs(gazelle): Start migrating Gazelle docs to ReadTheDocs, part 1 of ~5 by @dougthor42 in #3129
- feat(repl): add tab completion on platforms with readline support by @jpwoodbu in #3114
- docs(gazelle): Migrate Gazelle docs to ReadTheDocs, part 2/5: installation and usage by @dougthor42 in #3132
- docs(gazelle): Migrate Gazelle docs to ReadTheDocs, part 3/5: annotations by @dougthor42 in #3137
- docs(gazelle): Migrate Gazelle docs to ReadTheDocs, part 4/5: directives by @dougthor42 in #3139
- docs(gazelle): Migrate Gazelle docs to ReadTheDocs, part 5/5: target types by @dougthor42 in #3147
- docs(gazelle): Migrate Gazelle docs to ReadTheDocs, part 6/5: development by @dougthor42 in #3149
- fix: use "command -v" to find interpreter in $PATH by @malt3 in #3150
- docs(pypi): clarify when extra_hub_aliases was added to workspace by @rickeylev in #3152
- build(deps): bump nh3 from 0.2.18 to 0.3.0 in /tools/publish by @dependabot[bot] in #3141
- build(deps): bump certifi from 2025.7.14 to 2025.8.3 in /docs by @dependabot[bot] in #3143
- build(deps): bump certifi from 2025.7.14 to 2025.8.3 in /tools/publish by @dependabot[bot] in #3145
- fix: Fix whl_library in bazel vendor mode by @omar-droubi in #3096
- docs(gazelle): Use definition lists instead of bullets for Gazelle docs by @dougthor42 in #3154
- chore(toolchains): start pulling toolchains from 20250808 release by @aignas in #3116
- build(deps): bump snowballstemmer from 2.2.0 to 3.0.1 in /docs by @dependabot[bot] in #3144
- fix(core): do not assume rules_python runtime by @aignas in #3134
- chore(deps): upgrade bazel-skylib to 1.8.1 by @aignas in #3118
- fix(pypi): reuse select dicts for constructing the env by @aignas in #3108
- fix(pypi): support properly installing sdists via pypi without index by @aignas in #3115
- feat(pypi): add a standards compliant python_tag creator by @aignas in #3110
- doc: changelog cherry-picks for 1.5.2 by @aignas in #3158
- docs(toolchains): set dev_dependency=True on repo rule invocation by @honglooker in #3127
- docs: various howto guides by @rickeylev in #3157
- docs: move changelog note to 1.5.3 section by @rickeylev in #3163
- docs: link to PyRuntimeInfo and mention it has more than example shows by @rickeylev in #3170
- build(deps): bump absl-py from 2.2.2 to 2.3.1 in /docs by @dependabot[bot] in #3167
- build(deps): bump requests from 2.32.3 to 2.32.4 in /tools/publish in the pip group across 1 directory by @dependabot[bot] in #3169
- build(deps): bump docutils from 0.21.2 to 0.22 in /tools/publish by @dependabot[bot] in #3168
- build(deps): bump actions/checkout from 4 to 5 by @dependabot[bot] in #3165
- build(deps): bump astroid from 3.3.9 to 3.3.11 in /docs by @dependabot[bot] in #3164
- feat(pypi): implement a new whl selection algorithm by @aignas in #3111
- fix: bootstrapping script to not use multiline f-strings by @jacky8hyf in #3175
- docs: add 1.4.2 changelog by @honglooker in #3173
- fix(local_runtime): Improve local_runtime usability in macos / windows by @laramiel in #3148
- docs: Fix docs for gazelle usage by @brandonchinn178 in #3182
- feat(pypi): incrementally build platform configuration by @aignas in #3112
- fix(local_runtime): Search for libs in sys._base_executable when available. by @laramiel in #3178
- docs: tell how to do and request patch releases/backports by @rickeylev in #3185
- fix(pypi): pull fewer wheels with experimental_index_url by @aignas in #3058
- feat(pypi): builder for netrc and auth_patterns by @aignas in #3136
- refactor: Use the linkstamps from linker_inputs instead of from cc_linking_context for to support upcoming CcInfo changes by @comius in #3075
- chore(pypi): remove unused config setting code by @aignas in #3065
- deps(gazelle): upgrade rules_go to remove patching of tree-sitter by @jbedard in #3179
- fix(pypi): correctly handle different package versions by @aignas in #3186
- style: Print coverage return codes in verbose mode by @phst in #3190
- fix(py_wheel): add directories in deterministic order by @jwnimmer-tri in #3194
- feat: freethreaded support for the builder API by @aignas in #3063
- docs: correctly spell release in devguide by @honglooker in #3201
- fix(toolchains): Add Xcode repo env vars to local_runtime_repo for better cache invalidation by @pennig in #3203
- docs: update for 1.6 release by @rickeylev in #3205
New Contributors
- @katre made their first contribution in #2981
- @yushan26 made their first contribution in #2959
- @jklukas made their first contribution in #3040
- @robinlinden made their first contribution in #3045
- @aaronsky made their first contribution in #3041
- @shaldengeki made their first contribution in #3057
- @fionera made their first contribution in #3087
- @dotoleeoak made their first contribution in #3107
- @jpwoodbu made their first contribution in #3104
- @malt3 made their first contribution in #3150
- @omar-droubi made their first contribution in #3096
- @jacky8hyf made their first contribution in #3175
- @laramiel made their first contribution in #3148
- @jwnimmer-tri made their first contribution in #3194
- @pennig made their first contribution in #3203
Full Changelog: 1.5.0...1.6.0