1.5.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.5.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 = "7b9039c31e909cf59eeaea8ccbdc54f09f7ebaeb9609b94371c7de45e802977c",
strip_prefix = "rules_python-1.5.0",
url = "https://github.com/bazel-contrib/rules_python/releases/download/1.5.0/rules_python-1.5.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 = "7b9039c31e909cf59eeaea8ccbdc54f09f7ebaeb9609b94371c7de45e802977c",
strip_prefix = "rules_python-1.5.0/gazelle",
url = "https://github.com/bazel-contrib/rules_python/releases/download/1.5.0/rules_python-1.5.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: declare PyInfo as provided by test/binary/library by @layus in #2777
- fix: load target_platforms through the hub by @aignas in #2781
- chore: remove a stray file by @aignas in #2795
- build(deps): bump sphinx-rtd-theme from 3.0.1 to 3.0.2 in /docs by @dependabot in #2802
- build(deps): bump astroid from 3.3.6 to 3.3.9 in /docs by @dependabot in #2803
- build(deps): bump packaging from 24.2 to 25.0 in /docs by @dependabot in #2804
- fix: fixes to prepare for making bootstrap=script the default for Linux by @rickeylev in #2760
- fix: escape more invalid repo string characters by @keith in #2801
- fix: parsing metadata with inline licenses by @keith in #2806
- test(pypi): add a test case for simpleapi html parsing with % by @aignas in #2811
- build: Run pre-commit everywhere by @brandonchinn178 in #2808
- refactor/docs: improve compile_pip_requirements error message and docs by @brandonchinn178 in #2792
- feat: Have
pip_compile
generate a*.test
target; deprecate*_test
by @dougthor42 in #2812 - fix: try multiple times to get win32 version to handle flakes by @rickeylev in #2814
- refactor: Add log_std(out|err) bools to repo_utils that execute a subprocess by @dougthor42 in #2817
- fix: use the python micro version to parse whl metadata in bzlmod by @aignas in #2793
- fix(pypi): call python --version before marker eval by @aignas in #2819
- docs: add xrefs for local toolchains rules by @rickeylev in #2823
- docs: Improve bazel-runfiles docs by @fmeum in #2824
- revert(pypi): bring back Python PEP508 code with tests by @aignas in #2831
- fix(pypi) backport python_full_version fix to Python by @aignas in #2833
- revert(pypi): use Python for marker eval and METADATA parsing by @aignas in #2834
- feat: implement less/greater operators for string for env marker evaluation by @rickeylev in #2827
- docs: doc version when RULES_PYTHON_ENABLE_PYSTAR was introduced by @rickeylev in #2838
- fix(pypi): handle more URL patterns for requirement sources by @aignas in #2843
- docs: document some of our project styles/conventions by @rickeylev in #2816
- fix: requires_file preserves extras that package depends on by @skongum02 in #2807
- refactor: add rule to do analysis time evaluation of environment markers by @rickeylev in #2832
- py_wheel: always generate zip64-capable wheels by @devtbi in #2711
- feat: allow specifying arbitrary constraints for local toolchains by @rickeylev in #2829
- feat: add an env variable to toggle pipstar by @aignas in #2855
- fix: add target platform to extra exec platforms in analysis tests by @fmeum in #2861
- fix: configure coverage helpers for test exec group by @fmeum in #2857
- fix: fix test analysis error on macOS arm64 by @fmeum in #2860
- refactor: make env marker config available through target and flag by @rickeylev in #2853
- feat: default to bootstrap script for non-windows by @rickeylev in #2858
- fix(pypi): fix a typo in parse_simpleapi_html by @aignas in #2866
- build(deps): bump more-itertools from 10.5.0 to 10.7.0 in /tools/publish by @dependabot in #2841
- fix(pypi): finish PEP508/PEP440 impl for version matching by @aignas in #2856
- tests: make some analysis tests work for when test's exec platform is required by @fmeum in #2869
- fix(pypi): make the URL/filename extraction from requirement more robust by @aignas in #2871
- feat(pypi): actually start using env_marker_setting by @aignas in #2873
- refactor: make python extension generate platform toolchains by @rickeylev in #2875
- Fix whl_library file path inference by @gholms in #2876
- refactor: consolidate version parsing by @aignas in #2874
- feat: Add support for REPLs by @philsc in #2723
- cleanup: remove unused sanitize_platform_name function by @rickeylev in #2887
- refactor: move inline code strings to top-level constants by @rickeylev in #2886
- dev: add .python-version file so pyenv isn't user/system specific by @rickeylev in #2883
- refactor: have bzlmod pass platforms to python_register_toolchains by @rickeylev in #2884
- sphinxdocs: close repo rule directives by @rickeylev in #2892
- sphinxdocs: make xrefs to bzl:obj in inventories work by @rickeylev in #2894
- sphinxdocs: make xrefs to tag class attributes using attr role work by @rickeylev in #2895
- sphinxdocs: allow unqualified arg/attr name for xref by @rickeylev in #2896
- docs: fix xref to toolchain docs from getting starting by @rickeylev in #2899
- sphinxdocs: allow files to be xref by @rickeylev in #2897
- docs: move devguide to sphinx for more powerful markup by @rickeylev in #2898
- sphinxdocs: make bazel package xrefs work by @rickeylev in #2903
- docs: fix most broken xrefs in changelog by @rickeylev in #2902
- tests: move py_reconfig rules to their own file by @rickeylev in #2900
- docs: fix link to py_reconfig and sh_py_run_test files by @rickeylev in #2901
- sphinxdocs: make Any and object types no-ops to avoid missing xrefs by @rickeylev in #2905
- docs: correct some xrefs, add various missing Bazel external xrefs by @rickeylev in #2907
- docs: ignore warnings about missing external py xrefs by @rickeylev in #2904
- refactor: make bzlmod directly aware of created toolchain repo names by @rickeylev in #2885
- fix: Allow PYTHONSTARTUP to define variables by @philsc in #2911
- docs: fix some more bad xrefs by @rickeylev in #2910
- refactor: make bzlmod create host repos for toolchains by @rickeylev in #2888
- refactor: remove unused target_platforms hub_repository attr by @aignas in #2912
- build(deps): bump setuptools from 65.6.3 to 78.1.1 in /examples/bzlmod by @dependabot in #2914
- refactor: make bzlmod pass platform mapping to host repo creation by @rickeylev in #2889
- docs: fix xrefs in by @rickeylev in #2917
- refactor: explicitly define host platform ordering by @rickeylev in #2890
- docs: generate docs for py_common, PyInfoBuilder APIs by @rickeylev in #2920
- refactor: rename host_toolchain rule to host_compatible_python_repo by @rickeylev in #2926
- docs/refactor: Use python.defaults, not is_default by @vonschultz in #2924
- fix: Normalize main script path in Python bootstrap by @mering in #2925
- refactor: also rename host toolchain impl function name by @rickeylev in #2930
- tests: refactor py_reconfig rules so less boilerplate is needed to add attrs by @rickeylev in #2933
- feat: add shebang attribute on py_console_script_binary by @chrisirhc in #2867
- fix: update the stub type alias names by @kaycebasques in #2929
- refactor: reimplement writing namespace pkgs in Starlark by @aignas in #2882
- cleanup(pycross): remove the partially migrated code by @aignas in #2906
- refactor(pypi): return a list from parse_requirements by @aignas in #2931
- fix: symlink root-level python files to the venv by @aignas in #2908
- docs: split PyPI docs up and add more by @aignas in #2935
- refactor: change site_packages_symlinks to venv_symlinks by @rickeylev in #2939
- docs: fix sphinxdocs mis-redirect by @rickeylev in #2940
- feat: allow custom platform when overriding by @rickeylev in #2880
- feat: Support constraints in pip_compile by @vihangm in #2916
- fix(pypi): allow pip_compile to work with read-only sources by @rbeasley-avgo in #2712
- feat(uv): handle credential helpers and .netrc by @aignas in #2872
- fix(pypi): correctly aggregate the requirements files by @aignas in #2932
- fix(pypi): inherit proxy env variables in compile_pip_requirements test by @herewasmike in #2941
- feat: add persistent worker for sphinxdocs by @kaycebasques in #2938
- fix: Updating setuptools to patch CVE-2025-47273 by @aaronmaxlevy in #2955
- feat: data and pyi files in the venv by @aignas in #2936
- fix(pypi): Only show index_url_overrides warnings when they are needed by @thirtyseven in #2967
- revert: change default bootstrap back to system_python by @rickeylev in #2968
- fix: grammar in an error message by @benjaminp in #2971
- refactor: Add missing uses of DefaultInfo by @keith in #2972
- docs: fix typo in toolchains.md example code by @honglooker in #2970
- chore: prepare for 1.5 release by @rickeylev in #2973
- fix: support pre-release versions and add new toolchain versions by @aignas in #2969
New Contributors
- @kxxt made their first contribution in #2694
- @Yanpei-Wang made their first contribution in #2695
- @asa made their first contribution in #2769
- @FrankPortman made their first contribution in #2772
- @dws made their first contribution in #2788
- @layus made their first contribution in #2777
- @brandonchinn178 made their first contribution in #2808
- @skongum02 made their first contribution in #2807
- @devtbi made their first contribution in #2711
- @mering made their first contribution in #2925
- @kaycebasques made their first contribution in #2929
- @vihangm made their first contribution in #2916
- @rbeasley-avgo made their first contribution in #2712
- @herewasmike made their first contribution in #2941
- @aaronmaxlevy made their first contribution in #2955
- @thirtyseven made their first contribution in #2967
- @benjaminp made their first contribution in #2971
- @honglooker made their first contribution in #2970
Full Changelog: 1.4.0...1.5.0