0.32.0
Using Bzlmod with Bazel 6
NOTE: bzlmod support is still beta. APIs subject to change.
Add to your MODULE.bazel
file:
bazel_dep(name = "rules_python", version = "0.32.0")
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
pip.parse(
hub_name = "pip",
python_version = "3.11",
requirements_lock = "//:requirements_lock.txt",
)
use_repo(pip, "pip")
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 = "f4770504f74b9ef87984224a06df35b931d35a2e695ea898102bd9df30ce4fe6",
strip_prefix = "rules_python-0.32.0",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.32.0/rules_python-0.32.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 = "f4770504f74b9ef87984224a06df35b931d35a2e695ea898102bd9df30ce4fe6",
strip_prefix = "rules_python-0.32.0/gazelle",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.32.0/rules_python-0.32.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
Changed
- (bzlmod): The
MODULE.bazel.lock
whl_library
rule attributes are now
sorted in the attributes section. We are also removing values that are not
default in order to reduce the size of the lock file. - (coverage) Bump
coverage.py
to 7.4.3. - (deps): Bumped bazel_features to 1.9.1 to detect optional support
non-blocking downloads. - (deps): Updated
pip_tools
to >= 7.4.0 - (toolchains): Change some old toolchain versions to use 20240224 release to
include security fixes3.8.18
,3.9.18
and3.10.13
- (toolchains): Bump default toolchain versions to:
3.8 -> 3.8.19
3.9 -> 3.9.19
3.10 -> 3.10.14
3.11 -> 3.11.9
3.12 -> 3.12.3
Fixed
- (whl_library): Fix the experimental_target_platforms overriding for platform
specific wheels when the wheels are for any python interpreter version. Fixes
#1810. - (whl_library): Stop generating duplicate dependencies when encountering
duplicates in the METADATA. Fixes
#1873. - (gazelle) In
project
orpackage
generation modes, do not generatepy_test
rules when there are no test files and do not setmain = "__test__.py"
when
that file doesn't exist. - (whl_library) The group redirection is only added when the package is part of
the group potentially fixing aspects that want to traverse apy_library
graph.
Fixes #1760. - (bzlmod) Setting a particular micro version for the interpreter and the
pip.parse
extension is now possible, see the
examples/pip_parse/MODULE.bazel
for how to do it.
See #1371. - (refactor) The pre-commit developer workflow should now pass
isort
andblack
checks (see #1674).
Added
- (toolchains) Added armv7 platform definition for python toolchains.
- (toolchains) New Python versions available:
3.11.8
,3.12.2
using the 20240224 release. - (toolchains) New Python versions available:
3.8.19
,3.9.19
,3.10.14
,3.11.9
,3.12.3
using
the 20240415 release. - (gazelle) Added a new
python_visibility
directive to control visibility
of generated targets by appending additional visibility labels. - (gazelle) Added a new
python_default_visibility
directive to control the
default visibility of generated targets. See the docs
for details. - (gazelle) Added a new
python_test_file_pattern
directive. This directive tells
gazelle which python files should be mapped to thepy_test
rule. See the
original issue and the docs
for details. - (wheel) Add support for
data_files
attributes in py_wheel rule
(#1777) - (py_wheel)
bzlmod
installations now provide atwine
setup for the default
Python toolchain inrules_python
for version 3.11. - (bzlmod) New
experimental_index_url
,experimental_extra_index_urls
and
experimental_index_url_overrides
topip.parse
for using the bazel
downloader. If you see any issues, report in
#1357. The URLs for
the whl and sdist files will be written to the lock file. Controlling whether
the downloading of metadata is done in parallel can be done using
parallel_download
attribute. - (gazelle) Add a new annotation
include_dep
. Also add documentation for
annotations togazelle/README.md
. - (deps):
rules_python
depends now onrules_cc
0.0.9 - (pip_parse): A new flag
use_hub_alias_dependencies
has been added that is going
to become default in the next release. This makes use ofdep_template
flag
in thewhl_library
rule. This also affects the
experimental_requirement_cycles
feature where the dependencies that are in
a group would be only accessible via the hub repo aliases. If you still
depend on legacy labels instead of the hub repo aliases and you use the
experimental_requirement_cycles
, now is a good time to migrate.
Pull Requests
- chore(examples/bzlmod): bump deps to use wheels on linux_x86_64 by @aignas in #1758
- test(bzlmod): make the check for hub repo naming less strict by @aignas in #1757
- internal: support repo prefixes and config settings in alias rendering by @aignas in #1756
- build(deps): bump certifi from 2022.12.7 to 2023.7.22 in /examples/pip_parse by @dependabot in #1374
- build(deps): bump certifi from 2022.12.7 to 2023.7.22 in /examples/bzlmod_build_file_generation by @dependabot in #1378
- build(deps): bump certifi from 2022.12.7 to 2023.7.22 in /tools/publish by @dependabot in #1377
- build(deps): bump jinja2 from 3.0.3 to 3.1.3 in /tests/integration/pip_repository_entry_points by @dependabot in #1684
- docs(getting-started): fix link to python-build-standalone quirks by @mattnworb in #1771
- fix(internal): correctly template error message in repository rules by @jesses-canva in #1779
- docs(gazelle): Add details about python_root directive. by @dougthor42 in #1782
- chore: add python 3.12.2, 3.11.8 toolchain by @trentontrees in #1781
- feat(gazelle): Add "python_visibility" directive that appends additional visibility labels by @dougthor42 in #1784
- build(internal_deps): Update 'maintained by' comments to be correct by @dougthor42 in #1794
- docs: Update notice about rctx.getenv on Bazel 7 by @vonschultz in #1797
- docs(changelog) Update changelog from PR #1784 by @dougthor42 in #1802
- docs: Add some missing attribute docs by @rickeylev in #1805
- chore: update coveragepy to 7.4.3 by @oxidase in #1798
- feat(gazelle): Add "python_default_visibility" directive by @dougthor42 in #1787
- internal(config_settings): make config_setting creation reusable by @aignas in #1750
- fix(whl_library): correctly parse wheel target platforms by @aignas in #1811
- cleanup: Remove uses of legacy struct providers by @comius in #1812
- feat: Make Sphinx integration experimental publicly visible by @castler in #1813
- fix(gazelle): Do not create invalid py_test rules in
project
generation mode by @amartani in #1809 - fix(internal): add WORKSPACE.bzlmod to ensure dependency separation by @aignas in #1806
- feat: Add support for python-wheel data directory by @BradHolmes in #1801
- feat(twine): support 'bzlmod' users out of the box by @aignas in #1572
- fix(whl_library): only add group machinery when it is needed by @aignas in #1822
- feat(toolchains): Add armv7 linux platform to available toolchain platforms by @UebelAndre in #1770
- fix(bzlmod): allow users using X.Y.Z python_version in pip.parse by @aignas in #1830
- feat: Allow additional tools for sphinx_docs by @castler in #1831
- feat(gazelle): Add "python_test_file_pattern" directive by @dougthor42 in #1819
- docs: Add basic docs for using credential helper with Bazel downloader of python packages by @dougthor42 in #1834
- fix(gazelle): Consistent substitution pattern for python_default_visibility directive by @dougthor42 in #1835
- refactor: toolchainize py_proto_library by @thesayyn in #1577
- fix: using thread pool on macOS by @linzhp in #1861
- refactor: Run
isort
andblack
on all python files by @dougthor42 in #1859 - build(deps): Bump pip tools to >= 7.4.0 by @dougthor42 in #1841
- feat(bzlmod): add a flag to control if the parallel downloading is used by @aignas in #1854
- docs: document how to configure MODULE.bazel for different use cases by @rickeylev in #1864
- docs: Fix link to toolchain configuration doc in side bar by @rickeylev in #1866
- refactor: use bazel-skylib for creating hub repo aliases by @aignas in #1855
- deps: load cc symbols from @rules_cc by @martis42 in #1852
- feat(pip_parse): support referencing dependencies to packages via hub by @aignas in #1856
- feat(gazelle): Add "include_dep" Python comment annotation by @dougthor42 in #1863
- Fix typo in changelog text from #1863 by @dougthor42 in #1889
- build(deps): bump jinja2 from 3.1.3 to 3.1.4 in /docs/sphinx by @dependabot in #1884
- build(deps): bump jinja2 from 3.1.3 to 3.1.4 in /examples/pip_parse by @dependabot in #1882
- build(deps): bump idna from 3.4 to 3.7 in /examples/pip_repository_annotations by @dependabot in #1847
- build(deps): bump jinja2 from 3.1.3 to 3.1.4 in /tests/integration/pip_repository_entry_points by @dependabot in #1880
- build(deps): bump idna from 3.3 to 3.7 in /tests/integration/pip_repository_entry_points by @dependabot in #1846
- build(deps): bump idna from 3.6 to 3.7 in /docs/sphinx by @dependabot in #1851
- fix(whl_library): stop duplicating deps in whl_library by @aignas in #1874
- chore: bump toolchain versions by @aignas in #1878
- chore: release notes for 0.32.0 by @rickeylev in #1893
New Contributors
- @mattnworb made their first contribution in #1771
- @jesses-canva made their first contribution in #1779
- @dougthor42 made their first contribution in #1782
- @castler made their first contribution in #1813
- @BradHolmes made their first contribution in #1801
- @thesayyn made their first contribution in #1577
Full Changelog: 0.31.0...0.32.0