Releases: bazelbuild/rules_python
0.35.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.35.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 = "be04b635c7be4604be1ef20542e9870af3c49778ce841ee2d92fcb42f9d9516a",
strip_prefix = "rules_python-0.35.0",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.35.0/rules_python-0.35.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 = "be04b635c7be4604be1ef20542e9870af3c49778ce841ee2d92fcb42f9d9516a",
strip_prefix = "rules_python-0.35.0/gazelle",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.35.0/rules_python-0.35.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()
Changed
- (pypi) A better log message when the wheel is built from an sdist or
when the wheel is downloaded usingdownload_only
feature to aid debugging. - (gazelle): Simplify and make gazelle_python.yaml have only top level package name.
It would work well in cases to reduce merge conflicts and ease the change review. - (toolchains): Change some old toochain versions to use 20240726 release to
include dependency updates3.8.19
,3.9.19
,3.10.14
,3.11.9
- (toolchains): Bump default toolchain versions to:
3.12 -> 3.12.4
- (rules)
PYTHONSAFEPATH
is inherited from the calling environment to allow
disabling it (Requires {obj}--bootstrap_impl=script
)
(#2060).
Fixed
- (pypi)
compile_pip_requirements
now sets theUSERPROFILE
env variable on
Windows to work around an issue wheresetuptools
fails to locate the user's
home directory. - (pypi) correctly handle absolute URLs in
parse_simpleapi_html.bzl
. - (rules) Fixes build targets linking against
@rules_python//python/cc:current_py_cc_libs
in host platform builds on macOS, by editing theLC_ID_DYLIB
field of the hermetic interpreter's
libpython3.x.dylib
usinginstall_name_tool
, setting it to its absolute path under Bazel's
execroot. - (rules) Signals are properly received when using {obj}
--bootstrap_impl=script
(for non-zip builds).
(#2043) - (rules) Fixes Python builds when the
--build_python_zip
is set tofalse
on
Windows. See #1840. - (rules) Fixes Mac +
--build_python_zip
+ {obj}--bootstrap_impl=script
(#2030). - (rules) User dependencies come before runtime site-packages when using
{obj}--bootstrap_impl=script
.
(#2064). - (rules) Version-aware rules now return both
@_builtins
and@rules_python
providers instead of only one.
(#2114). - (pypi) Fixed pypi parse_simpleapi_html function for feeds with package metadata
containing ">" sign - (toolchains) Added missing executable permission to
//python/runtime_env_toolchains
interpreter script so that it is runnable.
(#2085). - (pip) Correctly use the
sdist
downloaded by the bazel downloader when using
experimental_index_url
feature. Fixes
#2091. - (gazelle) Make
gazelle_python_manifest.update
manual to avoid unnecessary
network behavior. - (bzlmod): The conflicting toolchains during
python
extension will no longer
cause warnings by default. In order to see the warnings for diagnostic purposes
set the env varRULES_PYTHON_REPO_DEBUG_VERBOSITY
to one ofINFO
,DEBUG
orTRACE
.
Fixes #1818. - (runfiles) Make runfiles lookups work for the situation of Bazel 7,
Python 3.9 (or earlier, where safepath isn't present), and the Rlocation call
in the same directory as the main file.
Fixes #1631.
Added
- (pypi)
compile_pip_requirements
supports multiple requirements input files assrcs
. - (rules)
PYTHONSAFEPATH
is inherited from the calling environment to allow
disabling it (Requires {obj}--bootstrap_impl=script
)
(#2060). - (gazelle) Added
python_generation_mode_per_package_require_test_entry_point
in order to better accommodate users who use a custom macro,
pytest-bazel
, rules_python_pytest orrules_py
py_test_main in order to integrate withpytest
. Currently the default
flag value is set totrue
for backwards compatible behaviour, but in the
future the flag will be flipped befalse
by default. - (toolchains) New Python versions available:
3.12.4
using the 20240726 release. - (pypi) Support env markers in requirements files. Note, that this means that
if your requirements files contain env markers, the Python interpreter will
need to be run during bzlmod phase to evaluate them. This may incur
downloading an interpreter (for hermetic-based builds) or cause non-hermetic
behavior (if using a system Python).
List of PRs:
- chore: include aignas to PyPI code reviewers by @aignas in #2034
- fix(windows): symlink bootstrap script when not building zip by @KoltesDigital in #2015
- fix: pypi parse_simpleapi_html.bzl is robust to metadata containing ">" sign by @mihaidusmanu in #2031
- build(deps): bump certifi from 2023.7.22 to 2024.7.4 in /tools/publish by @dependabot in #2041
- refactor: use http_archive for the stdlib list by @sitaktif in #2037
- build(deps): bump charset-normalizer from 3.0.1 to 3.3.2 in /tools/publish by @dependabot in #2028
- build(deps): bump certifi from 2024.6.2 to 2024.7.4 in /docs/sphinx by @dependabot in #2046
- fix: use
exec
to invoke the stage-2 bootstrap for non-zip case by @chowder in #2047 - chore: add cxxopt std=c++14 to BCR presubmit config by @rickeylev in #2051
- tests: add integration test for build_python_zip by @rickeylev in #2045
- refactor: don't load repo-phase objects from build-phase by @rickeylev in #2056
- fix(gazelle): Use the correct rules_go label in gazelle/manifest/defs.bzl by @dougthor42 in #2058
- feat: Introduce an experimental
uv
toolchain by @groodt in #1989 - refactor: Address a few improvements on
uv
toolchain by @groodt in #2062 - build(deps): bump setuptools from 65.6.3 to 70.0.0 in /examples/pip_parse by @dependabot in #2065
- build(deps): bump zipp from 3.11.0 to 3.19.2 in /tools/publish by @dependabot in #2066
- fix: make mac zip builds work by @rickeylev in #2052
- internal: repos to create a toolchain from a locally installed Python by @rickeylev in #2000
- refactor(pypi): split out more utils and start passing 'abi_os_arch' around by @aignas in #2069
- refactor(pypi): split out code for env marker evaluation for reuse by @aignas in #2068
- docs: document some environment variables by @rickeylev in #2077
- refactor(internal): move the os/arch detection to repo_utils by @aignas in #2075
- fix(uv): fix UV_BIN usage with current_toolchain by @aignas in #2074
- docs: describe
annotations
attr ofpip_parse
by @bruno-digitbio in #1667 - feat!: Following generation mode when generating test targets by @linzhp in #2044
- feat: inherit PYTHONSAFEPATH env var from outer process by @rickeylev in #207...
0.34.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.34.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 = "778aaeab3e6cfd56d681c89f5c10d7ad6bf8d2f1a72de9de55b23081b2d31618",
strip_prefix = "rules_python-0.34.0",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.34.0/rules_python-0.34.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 = "778aaeab3e6cfd56d681c89f5c10d7ad6bf8d2f1a72de9de55b23081b2d31618",
strip_prefix = "rules_python-0.34.0/gazelle",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.34.0/rules_python-0.34.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: Remove transitive legacy struct provider usage by @fmeum in #1957
- docs: fix doc for how to use new bootstrap impl by @rickeylev in #1959
- chore: various cleanups to make google imports/patching easier by @rickeylev in #1958
- build(deps): bump idna from 3.4 to 3.7 in /tools/publish by @dependabot in #1849
- build(deps): bump cryptography from 41.0.6 to 42.0.4 in /tools/publish by @dependabot in #1772
- ci: add a custom dependabot file by @aignas in #1960
- build(deps): bump pygments from 2.17.2 to 2.18.0 in /docs/sphinx by @dependabot in #1966
- build(deps): bump actions/checkout from 2 to 4 by @dependabot in #1961
- build(deps): bump actions/stale from 3 to 9 by @dependabot in #1962
- build(deps): bump markupsafe from 2.1.3 to 2.1.5 in /docs/sphinx by @dependabot in #1964
- build(deps): bump softprops/action-gh-release from 1 to 2 by @dependabot in #1963
- build(deps): bump typing-extensions from 4.9.0 to 4.12.2 in /docs/sphinx by @dependabot in #1965
- fix(bzlmod): use same target in requirement('foo') and all_requirements by @jvolkman in #1973
- refactor(bzlmod): generate fewer targets for pip_config_settings by @aignas in #1974
- chore: access ctx.version_file to inform Bazel stamping info is needed by @rickeylev in #1952
- build(deps): bump urllib3 from 1.26.18 to 1.26.19 in /tools/publish by @dependabot in #1981
- build(deps): bump babel from 2.13.1 to 2.15.0 in /docs/sphinx by @dependabot in #1983
- docs: Fix a few typos in docs and function names by @rickeylev in #1978
- fix: enable auto exec groups using attribute by @rickeylev in #1986
- docs: Remove proposals by @groodt in #1990
- chore: use
**
globs instead of explcit BUILD.bazel reference in distribution filegroups by @rickeylev in #1991 - refactor(internal): allow setting linking mode for internal cc_details APIs by @rickeylev in #1982
- fix(toolchain): disable exec toolchain by default by @aignas in #1968
- fix: Resolve the test manifest with the runfiles lib. by @lberki in #1993
- fix: allow creating PyRuntimeInfo without specifying interpreter_version_info by @rickeylev in #1992
- doc: Changelog updates for 0.33.2 by @aignas in #1995
- refactor!: Remove entrypoint by @groodt in #1987
- refactor: lookup exec interpreter using toolchain resolution by @rickeylev in #1997
- fix: Add
configure=True
for internal_config_repo by @meteorcloudy in #1998 - chore: remove dead code from whl_target_platforms by @aignas in #2001
- fix(bzlmod): pass only non-default values to whl_library by @aignas in #2002
- refactor: move PyPI related extension and repository_rule setup to its own dir by @aignas in #2003
- docs: Removes dead link after docs were migrated to sphinx by @groodt in #2005
- refactor: Remove unused template substitution by @groodt in #2004
- refactor: move the remaining PyPI related functions to private/pypi by @aignas in #2006
- chore: adjust CODEOWNERS by @aignas in #2008
- fix: make first default output the executable again by @rickeylev in #2010
- refactor: call a function to define internal pypi flags instead of listcomp by @rickeylev in #2011
- chore: bump sphinxdocs deps by @aignas in #2013
- fix(whl_library): correctly handle arch-specific deps in wheels by @aignas in #2007
- fix(multiplatform): Add i386 Linux support by @nicbadiu in #1999
- fix: Fix broken logger statement in parse_requirements.bzl by @mark-thm in #2017
- feat: add runtime_env toolchain suite to replace "autodetecting" toolchain by @rickeylev in #2018
- fix(bzlmod): only expose common packages via the requirements constants by @aignas in #1955
- feat(gazelle): Add directives for label format & normalisation by @wingsofovnia in #1976
- chore: Remove unused renovate.json by @groodt in #2021
- (chore): Remove the extra indirection and
bzlmod
folder by @groodt in #2022
New Contributors
- @lberki made their first contribution in #1993
- @nicbadiu made their first contribution in #1999
- @mark-thm made their first contribution in #2017
- @wingsofovnia made their first contribution in #1976
Full Changelog: 0.33.1...0.34.0
0.33.2
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.33.2")
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 = "e3f1cc7a04d9b09635afb3130731ed82b5f58eadc8233d4efb59944d92ffc06f",
strip_prefix = "rules_python-0.33.2",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.33.2/rules_python-0.33.2.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 = "e3f1cc7a04d9b09635afb3130731ed82b5f58eadc8233d4efb59944d92ffc06f",
strip_prefix = "rules_python-0.33.2/gazelle",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.33.2/rules_python-0.33.2.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()
Full Changelog: 0.33.1...0.33.2
0.33.1
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.33.1")
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 = "5bcfa3852444d084b1d3262714cec151b797648d4d444ea9895c7c7ed79cd715",
strip_prefix = "rules_python-0.33.1",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.33.1/rules_python-0.33.1.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 = "5bcfa3852444d084b1d3262714cec151b797648d4d444ea9895c7c7ed79cd715",
strip_prefix = "rules_python-0.33.1/gazelle",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.33.1/rules_python-0.33.1.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
Full Changelog: 0.33.0...0.33.1
0.33.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.33.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 = "dc6e2756130fafb90273587003659cadd1a2dfef3f6464c227794cdc01ebf70e",
strip_prefix = "rules_python-0.33.0",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.33.0/rules_python-0.33.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 = "dc6e2756130fafb90273587003659cadd1a2dfef3f6464c227794cdc01ebf70e",
strip_prefix = "rules_python-0.33.0/gazelle",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.33.0/rules_python-0.33.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
🎉 0.33.0 of rules_python and the gazelle plugin has just been tagged, notable changes/fixes/additions:
gazelle
plugin is now using tree-sitter instead of Python to parse python files, which makes it 3 times faster on larger monorepos and it does not require a python interpreter anymore. There is a known issue of the plugin being tricky to cross-compile, so please leave comments there if you are seeing issues.- The dependence on the system having a Python interpreter can now be avoided if using a hermetic toolchain. This can be enabled with bootstrap_impl config setting.
- The
MODULE.bazel.lock
file is now the same irrespective of the host platform thatrules_python
is being used on. This required to remove host-platform specific references in@pythons_hub//:interpreters.bzl
, so if you want to use a host python in a repository rule context, use@python_{version}_host//:python
. - The python files can now be compiled to
.pyc
during thebazel build
phase, enable this with@rules_python//python/config_settings:precompile=enabled
config setting, more info in the docs. whl_filegroup
can now be used to extract files from awhl
target. This is useful in cases where one wants to use e.g.numpy
headers or similar. The benefit of this is that users don’t need to modify thepip.parse
whl distributions and can have better performance (no need to refetch the pip packages when the desired file list changes) and ergonomics through build-time rules.experimental_index_url
flag inpip.parse
now enables using the whl filenames to derive the target platform config settings, so you can finally get the right wheel for the right target platform. It is best to use this feature together withrequirements_by_platform
(also added in 0.33.0) to specify requirements files per (os, arch) explicitly. We now also do not ignore yanked packages which mirrors the behaviour ofuv
more closely. The users have a few config settings that they can use to change the behaviour (preference ofuniversal2
wheels on osx, preference ofmusllinux
and the libc version on linux, disablingsdist
). The config settings are documented here.
See the full changelog here.
PRs:
- fix(gazelle): delete invalid py_library and use correct NonEmptyAttrs for py_* by @hunshcn in #1887
- fix(gazelle): generate empty py_library only when need by @hunshcn in #1905
- refactor: Mark internal and
python
extension as reproducible by @fmeum in #1892 - feat: compile source files at build time by @rickeylev in #1902
- docs: doc that precompiling is disabled by default by @rickeylev in #1908
- fix(whl_library): fix the dependency generation for multi-python depenency closures by @aignas in #1875
- fix: gazelle failing on Windows with "panic: runtime error: invalid memory address or nil pointer dereference" by @bartoszpop in #1872
- feat(pip): support specifying requirements per (os, arch) by @aignas in #1885
- feat(toolchains): Add riscv64 linux platform to available toolchain platforms by @JeffreyALaw in #1907
- fix: remove bzlmod pip.parse() annotations attribute by @jbedard in #1808
- feat(gazelle): pure golang helper by @hunshcn in #1895
- doc: fix doc typo in py_wheel.bzl by @tnielens in #1899
- feat: add whl_filegroup by @lalten in #1904
- chore(precompiling): use
PyCompile
as mnemonic to match Google mnemonic by @rickeylev in #1911 - docs: implement Starlark domain plugin for Sphinx by @rickeylev in #1909
- docs: generate Starlark domain markup instead of regular markdown by @rickeylev in #1919
- docs: rename sphinx plugin to sphinx_bzl by @rickeylev in #1922
- docs: document the current_py_cc_headers and libraries targets by @rickeylev in #1927
- build(deps): Update the pip_install dependencies by @JulesDT in #1914
- doc: fix
toolchains.md
mistake by @xinnjie in #1928 - refactor/fix: store dists in parse_requirements output by @aignas in #1917
- fix: don't require system Python to perform bootstrapping by @rickeylev in #1929
- feat(gazelle): Support "$python_root$" placeholder in the "gazelle:python_visibility" directive by @dougthor42 in #1936
- feat: Upgrade to protobuf 27.0 and remove py_proto_library by @comius in #1933
- fix(pip.parse): make the pip extension reproducible if PyPI is not called by @aignas in #1937
- feat(bzlmod): support cross-platform whl setups within the main hub repo by @aignas in #1837
- doc(pip_parse_vendored): fix the example by @aignas in #1942
- fix: make the pythons_hub platform independent by @aignas in #1946
- revert: upgrade to protobuf 27.0 and remove py_proto_library (#1933) by @aignas in #1948
- chore: refer to rules_python toolchain type target instead of bazel_tools by @rickeylev in #1949
- chore: changelog changes for release 0.33.0 by @aignas in #1950
New Contributors
- @hunshcn made their first contribution in #1887
- @bartoszpop made their first contribution in #1872
- @JeffreyALaw made their first contribution in #1907
- @jbedard made their first contribution in #1808
- @tnielens made their first contribution in #1899
- @lalten made their first contribution in #1904
- @JulesDT made their first contribution in #1914
- @xinnjie made their first contribution in #1928
Full Changelog: 0.32.2...0.33.0
0.32.2
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.2")
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 = "4912ced70dc1a2a8e4b86cec233b192ca053e82bc72d877b98e126156e8f228d",
strip_prefix = "rules_python-0.32.2",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.32.2/rules_python-0.32.2.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 = "4912ced70dc1a2a8e4b86cec233b192ca053e82bc72d877b98e126156e8f228d",
strip_prefix = "rules_python-0.32.2/gazelle",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.32.2/rules_python-0.32.2.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
Fixed
- Workaround existence of infinite symlink loops on case insensitive filesystems when targeting linux platforms with recent Python toolchains. Works around an upstream issue. Fixes #1800.
Full Changelog: 0.32.1...0.32.2
0.32.1
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.1")
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 = "b289b0b023c71b80f26d39476e5e2c3cf72d21cb2759bcf02638ba3cc480e9df",
strip_prefix = "rules_python-0.32.1",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.32.1/rules_python-0.32.1.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 = "b289b0b023c71b80f26d39476e5e2c3cf72d21cb2759bcf02638ba3cc480e9df",
strip_prefix = "rules_python-0.32.1/gazelle",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.32.1/rules_python-0.32.1.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.
Full Changelog: 0.32.0...0.32.1
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 @Aigna...
0.31.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.31.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 = "c68bdc4fbec25de5b5493b8819cfc877c4ea299c0dcb15c244c5a00208cde311",
strip_prefix = "rules_python-0.31.0",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.31.0/rules_python-0.31.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 = "c68bdc4fbec25de5b5493b8819cfc877c4ea299c0dcb15c244c5a00208cde311",
strip_prefix = "rules_python-0.31.0/gazelle",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.31.0/rules_python-0.31.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
This release is the same as 0.30.0, except the rules_python implementation of the rules is enabled for Bazel 7. Earlier Bazel versions are unaffected. If you encounter issues, please report them! The rules_python implementation can be disabled by any of the following:
- Setting
RULES_PYTHON_ENABLE_PYSTAR=0
in your environment or using--action_env
- Downgrading to 0.30.0
Below is a list of commits:
- feat: enable rules_python Starlark implemention by default for Bazel 7+ by @rickeylev in #1699
- chore: Update changelog for 0.31.0 by @rickeylev in #1754
Full Changelog: 0.30.0...0.31.0
0.30.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.30.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 = "3b8b4cdc991bc9def8833d118e4c850f1b7498b3d65d5698eea92c3528b8cf2c",
strip_prefix = "rules_python-0.30.0",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.30.0/rules_python-0.30.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 = "3b8b4cdc991bc9def8833d118e4c850f1b7498b3d65d5698eea92c3528b8cf2c",
strip_prefix = "rules_python-0.30.0/gazelle",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.30.0/rules_python-0.30.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
- feat(py_wheel): Added
requires_file
andextra_requires_files
attrs by @UebelAndre in #1710 - refactor: move bzl tests from pip_install to //tests by @aignas in #1716
- fix: make windows ignore pycs in runtime by @rickeylev in #1715
- fix: fix launching Python 3.11 from <3.8 on macOS by @armandomontanez in #1709
- fix(bzlmod): do not fail pip.parse with empty requirements.txt by @aignas in #1718
- fix(py_wheel): Fix parsing errors with
requires_file
attribute. by @UebelAndre in #1719 - feat: expose runtime's shared libraries through toolchain by @rickeylev in #1717
- feat: support parsing whl METADATA on any python version by @aignas in #1693
- refactor: provide more detailed error message when wheel installer fails by @rickeylev in #1724
- chore: add python 3.11.7, 3.12.1 toolchain by @trentontrees in #1725
- feat(toolchain): support specifying x.y versions in transitions by @aignas in #1720
- Ensure regular file bit set in wheel archives by @lamcw in #1731
- feat: Add support for envsubst in extra_pip_args by @vonschultz in #1673
- feat: add debug logging of repo sub processes by @rickeylev in #1735
- test: config_settings matching latest minor versions by @aignas in #1738
- fix(coverage): generating lcov was causing issues by @trentontrees in #1734
- fix(coverage) add coverage support for python 3.12 by @trentontrees in #1727
- build(deps): bump cryptography from 39.0.0 to 41.0.6 in /tools/publish by @dependabot in #1581
- fix(toolchain): symlink all toolchain files for the host toolchain by @aignas in #1745
- feat(gazelle): Remove integrity field from Gazelle manifest by @adzenith in #1666
- fix(PyRuntimeInfo): use builtin PyRuntimeInfo unless pystar is enabled. by @rickeylev in #1748
- tests(cclibs): Basic test that the
current_py_cc_libs
target works by @rickeylev in #1749 - chore: Update changelog for 0.30.0 release by @rickeylev in #1752
- tests(bcr): Set Bazel version in BCR presubmit config. by @rickeylev in #1753
New Contributors
- @armandomontanez made their first contribution in #1709
- @trentontrees made their first contribution in #1725
- @lamcw made their first contribution in #1731
Full Changelog: 0.29.0...0.30.0