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.7.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 = "f609f341d6e9090b981b3f45324d05a819fd7a5a56434f849c761971ce2c47da",
strip_prefix = "rules_python-1.7.0",
url = "https://github.com/bazel-contrib/rules_python/releases/download/1.7.0/rules_python-1.7.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 = "f609f341d6e9090b981b3f45324d05a819fd7a5a56434f849c761971ce2c47da",
strip_prefix = "rules_python-1.7.0/gazelle",
url = "https://github.com/bazel-contrib/rules_python/releases/download/1.7.0/rules_python-1.7.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(bootstrap): handle when runfiles env vars don't point to current binary's runfiles by @rickeylev in #3192
- docs: fix a couple typos in the changelog by @rickeylev in #3208
- chore: release helper tool by @rickeylev in #3206
- docs: fix changelog header anchors by @rickeylev in #3207
- fix(gazelle): Do not build proto targets with default Gazelle by @dougthor42 in #3216
- chore: create workflow to check the do-not-merge label by @rickeylev in #3213
- docs: Add 1.5.4 release notes to changelog by @rickeylev in #3221
- build(deps): bump requests from 2.32.4 to 2.32.5 in /tools/publish by @dependabot[bot] in #3214
- docs: tell how to push one tag; that rc start with n=0 by @rickeylev in #3222
- build(deps): bump typing-extensions from 4.14.1 to 4.15.0 in /docs by @dependabot[bot] in #3212
- build(deps): bump requests from 2.32.4 to 2.32.5 in /docs by @dependabot[bot] in #3211
- cleanup: remove support for extra actions by @comius in #3210
- build(deps): bump docutils from 0.21.2 to 0.22 in /docs by @dependabot[bot] in #3166
- chore: add AGENTS.md to help AI agents work with rules_python by @rickeylev in #3227
- build(deps): bump rich from 13.9.4 to 14.1.0 in /tools/publish by @dependabot[bot] in #3230
- build(deps): bump charset-normalizer from 3.4.2 to 3.4.3 in /tools/publish by @dependabot[bot] in #3231
- chore: allow release workflow to be manually run and skip pypi upload by @rickeylev in #3232
- chore: make release tool auto detect next version by @rickeylev in #3219
- build(deps): bump cryptography from 44.0.1 to 45.0.7 in /tools/publish by @dependabot[bot] in #3235
- build(deps): bump jeepney from 0.8.0 to 0.9.0 in /tools/publish by @dependabot[bot] in #3234
- build(deps): bump keyring from 25.5.0 to 25.6.0 in /tools/publish by @dependabot[bot] in #3236
- build(deps): bump importlib-metadata from 8.5.0 to 8.7.0 in /tools/publish by @dependabot[bot] in #3237
- refactor(gazelle): report missing BUILD_WORKSPACE_DIRECTORY key more directly by @ctcjab in #3240
- chore(deps): bump rules_cc to 0.1.5 by @aignas in #3238
- fix(sphinxdocs): add retry logic when exit code 2 occurs by @rickeylev in #3241
- fix(system_python): write import paths to generated file instead of using PYTHONPATH by @rickeylev in #3242
- refactor(pypi): split out a hub_builder helper from the extension code by @aignas in #3243
- chore: add GEMINI.md, have it load AGENTS.md by @rickeylev in #3246
- docs: fix pr doc builds by removing external_version_warning plugin by @rickeylev in #3244
- refactor: migrate tests to use hub_builder instead of full integration by @aignas in #3247
- build(deps): bump zipp from 3.20.2 to 3.23.0 in /tools/publish by @dependabot[bot] in #3253
- build(deps): bump more-itertools from 10.7.0 to 10.8.0 in /tools/publish by @dependabot[bot] in #3254
- feat: allow registering arbitrary settings for py_binary transitions by @rickeylev in #3248
- fix: ensure the stage1 bootstrap is executable by @EdSchouten in #3258
- fix: don't call Args.add() with an integer by @EdSchouten in #3259
- docs: update changelog for config_settings attribute by @rickeylev in #3257
- chore: add agents guidance for creating bzl_library targets by @rickeylev in #3264
- docs: improve whl_library documentation by @baxelrod-bdai in #3266
- refactor: use common_labels.bzl for labels used across files by @rickeylev in #3263
- fix(pypi): select the lowest available libc version by default by @aignas in #3255
- tests: add non-blocking ci config for bazel rolling by @rickeylev in #3272
- fix: venv site packages with pkgutil packages by @rickeylev in #3268
- build(deps): bump pycparser from 2.22 to 2.23 in /tools/publish by @dependabot[bot] in #3271
- build(deps): bump cffi from 1.17.1 to 2.0.0 in /tools/publish by @dependabot[bot] in #3270
- build: remove no-op _native_rules_allowlist by @mai93 in #3275
- build(deps): bump pkginfo from 1.10.0 to 1.12.1.2 in /tools/publish by @dependabot[bot] in #3229
- tests: make py_cc_toolchain test of headers/includes work with Bazel 9 by @rickeylev in #3276
- chore(docs): remove duplicate bzlmod guidance by @alexeagle in #3278
- chore: remove non-toolchain runtime resolution logic. by @gregestren in #3280
- feat(toolchains): ABI3 Python headers target by @nicholasjng in #3274
- docs: move 1.6.3 related changelog by @aignas in #3284
- refactor: read migrated native flags through a centralized accessor function by @gregestren in #3290
- build(deps): bump docutils from 0.21.2 to 0.22.2 in /docs by @dependabot[bot] in #3287
- build(deps): bump jaraco-functools from 4.1.0 to 4.3.0 in /tools/publish by @dependabot[bot] in #3288
- docs: add example for a complex multi-platform pypi configuration by @rickeylev in #3292
- feat(runfiles): support for --incompatible_compact_repo_mapping_manifest by @jklukas in #3277
- chore: cleanup bazel flags related to bazel 6 or below by @aignas in #3282
- refactor: rename symbols in re-exports by @aignas in #3300
- chore: use python.defaults to set rules_python default python version by @rickeylev in #3301
- docs: fix spelling of venvs_site_packages flag in changelog by @rickeylev in #3302
- fix(uv): make uv lock rule work with platform python runtime by @rickeylev in #3303
- docs: add config bzlmod extension to docs by @rickeylev in #3305
- fix: handle urls without release id format by @rickeylev in #3306
- build(deps): bump markupsafe from 3.0.2 to 3.0.3 in /docs by @dependabot[bot] in #3307
- build(deps): bump pyyaml from 6.0.2 to 6.0.3 in /docs by @dependabot[bot] in #3308
- build(deps): bump docutils from 0.22 to 0.22.2 in /tools/publish by @dependabot[bot] in #3289
- feat(toolchains): let local toolchains point to a label by @rickeylev in #3304
- fix(toolchains): add musl list of freethreaded runtimes (workspace) by @rickeylev in #3310
- tests: add tests to verify toolchain registration by @rickeylev in #3313
- refactor: remove Google-specific stubs by @oprypin in #3316
- fix: wrong value of
has_py3_only_sourcesin the PyInfo constructor by @oprypin in #3315 - fix(pip): do not use experimental_index_url for publish_deps by @aignas in #3311
- fix(toolchains): correctly register musl/freethreaded toolchains for workspace by @rickeylev in #3314
- chore: reject py2 runtimes and remove usages of ctx.fragments.py.disable_py2 by @mai93 in #3319
- feat(pypi): enable pipstar by default by @aignas in #3225
- docs(pipstar): add more docs to make it ready for release by @aignas in #3323
- build(deps): bump markdown-it-py from 3.0.0 to 4.0.0 in /docs by @dependabot[bot] in #3326
- build(deps): bump certifi from 2025.8.3 to 2025.10.5 in /docs by @dependabot[bot] in #3327
- build(deps): bump certifi from 2025.8.3 to 2025.10.5 in /tools/publish by @dependabot[bot] in #3328
- build(deps): bump markdown-it-py from 3.0.0 to 4.0.0 in /tools/publish by @dependabot[bot] in #3329
- feat(toolchains): Add 3.14.0 by @Ahajha in #3330
- fix(venv): group venv prefixes by path component, not raw path by @rickeylev in #3333
- feat(pypi): support aarch64 windows on pipstar by @aignas in #3226
- feat(toolchains): Add latest Python versions by @Ahajha in #3336
- fix(rules): make
py_console_script_binarycompatible with symbolic macros by @janwinkler1 in #3195 - fix(venv): symlink shared libraries directly by @rickeylev in #3331
- fix(venv): include pth files at the root of the site-packages folder by @aignas in #3340
- internal: make release to chdir before looking for version markers by @rickeylev in #3342
- chore: release 1.7 prep by @rickeylev in #3341
- test(venv): functional test for pth files by @aignas in #3343
- docs: Fix GitHub PR links by @thejcannon in #3346
- build: Starlarkify python flags by @mai93 in #3334
- doc: Fix
pip.defaultarguments in multi-platform example by @hartikainen in #3358 - chore(toolchain): use the last build and add 3.15.0a1 by @aignas in #3357
- fix(doc): fix the release notes for the starlarkification of the flags by @aignas in #3361
- chore: switch to use publish-to-bcr workflow by @rickeylev in #3359
- chore: fix create_archive_and_notes to ignore release tool markers by @rickeylev in #3355
- chore: make gazelle bcr tests compatible with bcr presubmit environment by @rickeylev in #3365
- chore: fix release workflow by @rickeylev in #3366
- Merge main -> release/1.7 by @rickeylev in #3369
New Contributors
- @ctcjab made their first contribution in #3240
- @baxelrod-bdai made their first contribution in #3266
- @mai93 made their first contribution in #3275
- @gregestren made their first contribution in #3280
- @Ahajha made their first contribution in #3330
- @janwinkler1 made their first contribution in #3195
- @thejcannon made their first contribution in #3346
- @hartikainen made their first contribution in #3358
Full Changelog: 1.6.3...1.7.0