2.0.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 = "2.0.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 = "f4f709b1e354b0089038001854400938962d60d749cd910e12d5883a084510d3",
strip_prefix = "rules_python-2.0.0",
url = "https://github.com/bazel-contrib/rules_python/releases/download/2.0.0/rules_python-2.0.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 = "f4f709b1e354b0089038001854400938962d60d749cd910e12d5883a084510d3",
strip_prefix = "rules_python-2.0.0/gazelle",
url = "https://github.com/bazel-contrib/rules_python/releases/download/2.0.0/rules_python-2.0.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: replace version marker in features.bzl by @rickeylev in #3627
- chore: update changelog with 1.8.5 notes, fix 1.8 links by @rickeylev in #3626
- feat(pypi): make whl_library reproducible under pipstar by @aignas in #3589
- fix(pypi): handle unnormalized package names when extracting sdist version by @aignas in #3635
- fix: replace 2 bare except clauses with except Exception by @haosenwang1018 in #3637
- chore: simplify support policy description by @rickeylev in #3638
- refactor(pypi): factor out a simple implementation of the PyPI cache by @aignas in #3639
- fix(pypi): update pypi tooling deps to setuptools 82, packaging 26 by @Danielkonge in #3593
- build: add flag_alias definition for Starlarkification of python flags by @aranguyen in #3450
- fix: remove flag_aliases to unbreak bazel 9 by @rickeylev in #3649
- chore: cleanup the usage of rctx.getenv by @aignas in #3640
- ci: soft fail for upcoming bazel job by @rickeylev in #3651
- fix: Fix zipapp compression support for new
py_zipapp_binarytarget by @nate-england in #3653 - fix(toolchain): Also set Make variables for local toolchains by @jwnimmer-tri in #3641
- refactor(pypi): move absolute_url to whl_library by @aignas in #3652
- tests: add bazel 9 testing, use latest released (not rc) for bazel by @rickeylev in #3650
- chore: use bazel 9 by default by @rickeylev in #3662
- Link a quickstart screen recording for rules_python beginners into docs by @blockjon in #3658
- chore!: enable --windows_enable_symlinks by default by @rickeylev in #3663
- fix(pypi): return yank reason from SimpleAPI HTML by @aignas in #3656
- feat(pypi): store PyPI results as facts v2 by @aignas in #3654
- chore: remove pip_repository_annotations example by @rickeylev in #3622
- chore: factor release note checking into separate script by @rickeylev in #3628
- fix: prevent stdlib pyc files from invalidating runtime repos by @rickeylev in #3661
- chore: split sphinxdocs into its own module by @rickeylev in #3629
- chore: use term runfiles root instead of module space by @rickeylev in #3664
- chore: clarify type of paths for some system_python variables by @rickeylev in #3665
- feat: Allow files in wheels to be installed to directories by @Ahajha in #3233
- fix(bootstrap): manual runfiles path construction when using submodules by @faximan in #3636
- chore(system_python): use snake_case, add some debugging by @rickeylev in #3667
- fix(pypi): propagate fails if overrides are passed only one index is used by @aignas in #3666
- fix(pypi) Correct likely _BAZEL_REPO_FILE_GLOBS typo by @michaelm-openai in #3670
- refactor!: create full venv for bootstrap=system_python by @rickeylev in #3473
- build(deps): bump the pip group across 2 directories with 1 update by @dependabot[bot] in #3675
- build(deps): bump cryptography from 46.0.5 to 46.0.6 in /tools/publish in the pip group across 1 directory by @dependabot[bot] in #3677
- feat(pypi): first check index contents before downloading metadata about distributions by @aignas in #3657
- fix(uv): drop powerpc64 support to fix latest version downloads by @aignas in #3678
- fix(bootstrap) handle when the runfiles env vars are not correct by @adhoc-bobcat in #3644
- feat(zipapp): support EXTRACT_ROOT env var for main.py invocations by @rickeylev in #3682
- feat(zipapp): add content hash support to main-based invocations by @rickeylev in #3683
- chore: finish removing pip_repository_annotations by @rickeylev in #3684
- feat!: make windows use venvs by @rickeylev in #3680
- feat(wheel): Add support for add_path_prefix by @antoniojkim in #3679
- chore: update changelog, version markers, for 2.0 release by @rickeylev in #3689
- sphinxdoc: move tests and docs to module-root directory by @rickeylev in #3690
- feat!(pypi): enable bazel downloader by default by @aignas in #3691
New Contributors
- @haosenwang1018 made their first contribution in #3637
- @Danielkonge made their first contribution in #3593
- @aranguyen made their first contribution in #3450
- @nate-england made their first contribution in #3653
- @blockjon made their first contribution in #3658
- @faximan made their first contribution in #3636
- @michaelm-openai made their first contribution in #3670
- @adhoc-bobcat made their first contribution in #3644
- @antoniojkim made their first contribution in #3679
Full Changelog: 1.9.0...2.0.0