Releases: bazelbuild/rules_python
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
0.29.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.29.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 = "d71d2c67e0bce986e1c5a7731b4693226867c45bfe0b7c5e0067228a536fc580",
strip_prefix = "rules_python-0.29.0",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.29.0/rules_python-0.29.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 = "d71d2c67e0bce986e1c5a7731b4693226867c45bfe0b7c5e0067228a536fc580",
strip_prefix = "rules_python-0.29.0/gazelle",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.29.0/rules_python-0.29.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
For a human friendly description, see the changelog at: https://github.com/bazelbuild/rules_python/blob/main/CHANGELOG.md
Below is a list of commits
- fix: Fix per-file config interaction with one py_binary per main by @adzenith in #1664
- refactor(pip_install): make the API surface of deps parsing smaller by @aignas in #1657
- feat(toolchain, pip.parse): introduce a new '_host' toolchain repo by @aignas in #1644
- feat(runfiles): Add static methods to
Runfiles
class to simplify interface by @UebelAndre in #1656 - chore!: remove incompatible_generate_aliases and related flags by @aignas in #1567
- chore/fix!: remove incompatible whl packaging flags by @aignas in #1569
- feat: add interpreter_version_info to py_runtime by @mattem in #1671
- build(deps): bump jinja2 from 3.1.2 to 3.1.3 in /examples/pip_parse by @dependabot in #1686
- build(deps): bump jinja2 from 3.1.2 to 3.1.3 in /docs/sphinx by @dependabot in #1688
- chore: remove MODULE.bazel.lock and ignore it by @aignas in #1680
- build(deps): bump jinja2 from 3.1.2 to 3.1.3 in /examples/bzlmod by @dependabot in #1687
- fix: ignore_root_user_error should be taken from root module only by @shabanzd in #1662
- refactor(internal): simplify and cleanup dependency resolution by @aignas in #1691
- test: don't force bzlmod example to use Bazel 6.0 by @rickeylev in #1695
- feat(config_settings): allow matching minor version of python_version flag by @dizzy57 in #1555
- build(deps): bump certifi from 2022.12.7 to 2023.7.22 in /examples/bzlmod by @dependabot in #1379
- internal(pystar): Only respect RULES_PYTHON_ENABLE_PYSTAR env var for Bazel 7+ by @rickeylev in #1698
- fix(bzlmod): use X.Y select for the hub repo by @aignas in #1696
- internal: update native deps and linkstamp API updates to Bazel rolling APIs by @rickeylev in #1697
- refactor: broaden visibility and use list() instead of keys() by @rickeylev in #1704
- test: workaround cyclic dependency bzlmod bug by disabling lockfiles by @rickeylev in #1705
- docs: Update gazelle/README.md to fix
package_name
formatting by @michael-christen in #1712 - chore: update changelog for 0.29.0 release by @rickeylev in #1714
New Contributors
- @shabanzd made their first contribution in #1662
- @michael-christen made their first contribution in #1712
Full Changelog: 0.28.0...0.29.0
0.28.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.28.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 = "d70cd72a7a4880f0000a6346253414825c19cdd40a28289bdf67b8e6480edff8",
strip_prefix = "rules_python-0.28.0",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.28.0/rules_python-0.28.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 = "d70cd72a7a4880f0000a6346253414825c19cdd40a28289bdf67b8e6480edff8",
strip_prefix = "rules_python-0.28.0/gazelle",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.28.0/rules_python-0.28.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
For a human friendly overview of changes, see https://rules-python.readthedocs.io/en/latest/changelog.html
Below is a list of commits.
- pystar: support builtin providers for compatibility by @rickeylev in #1573
- feat: use rules_python implemented py_runtime, py_runtime_pair, PyRuntimeInfo by @rickeylev in #1574
- feat(pip_repository): Support pip parse cycles by @arrdem in #1166
- cleanup: delete extraneous report.txt file by @rickeylev in #1587
- docs: fix crossrefs and allow function parameters to be referenced by @rickeylev in #1585
- docs(pip_parse): Update docs about
experimental_requirement_cycles
by @mishazharov in #1588 - docs: update docs deps to latest versions by @rickeylev in #1586
- fix(gazelle): ensure that gazelle helper modules are on PYTHONPATH by @aignas in #1590
- doc: add a py_proto_library example with well-known-types by @aignas in #1571
- examples(pip_parse): fix circular deps with sphinx by breaking cycles by @rickeylev in #1596
- ci(example): provide a specific requirements.txt on windows by @aignas in #1605
- feat: Creating one py_binary per main module by @linzhp in #1584
- feat(whl_library): generate platform-specific dependency closures by @aignas in #1593
- feat: keep main module in py_library by @linzhp in #1608
- fix(py_runtime): make py_runtime_pair return builtin PyRuntimeInfo under Bazel 6; make python_bootstrap_template public by @rickeylev in #1611
- fix: use rules_python's py_runtime in generated toolchains by @rickeylev in #1604
- chore: Update Bazel support: drop 5, minimum 6.2, current 7.0 by @rickeylev in #1613
- docs: update pip.parse example in release notes by @keith in #1616
- docs: include changelog and contributing page in generated docs. by @rickeylev in #1617
- fix(pip.parse): allow absolute path for python_interpreter; skip hermetic toolchain lookup when used by @rickeylev in #1619
- fix: trimming deps in py_binary by @linzhp in #1614
- doc: switch to pypi.org by @aignas in #1622
- refactor: extract auth.bzl out of repositories.bzl by @aignas in #1627
- internal: support setting visibility when rendering aliases by @aignas in #1626
- fix(bzlmod pip.parse): allow requirements with duplicate package lines by @rickeylev in #1620
- pycross: Add patching support to py_wheel_library by @philsc in #1436
- test(bzlmod): refactor tests to not depend on implementation details by @aignas in #1628
- docs: use stardoc proto output to generate markdown docs by @rickeylev in #1629
- doc: Updating doc on py_binary generation by @linzhp in #1635
- fix(gazelle): init.py in per-file targets by @siddharthab in #1582
- chore: fix sphinx requirements by @aignas in #1648
- docs: document support policies by @rickeylev in #1640
- fix(whl_library): actually apply patches and warn if RECORD file patch is needed by @aignas in #1637
- fix: missing dependencies of py_binary by @linzhp in #1630
- chore!: remove pip_install macro and cleanup docs by @aignas in #1570
- chore: enable bzlmod by default (for Bazel 6) by @rickeylev in #1632
- build(deps): bump pygments from 2.11.2 to 2.15.0 in /tests/integration/pip_repository_entry_points by @dependabot in #1650
- fix(coverage): add test attributes in transition module by @tanan in #1649
- refactor(whl_library): reimplement wheel platform parsing in starlark by @aignas in #1636
- feat(runfiles): Added type hints to
@rules_python//python/runfiles
by @UebelAndre in #1654 - fix(bzlmod): allow modules to register the same toolchain as rules_python's default by @rickeylev in #1642
- build(deps): bump setuptools from 59.6.0 to 65.5.1 in /tests/integration/pip_repository_entry_points by @dependabot in #1652
- build(deps): bump requests from 2.27.1 to 2.31.0 in /tests/integration/pip_repository_entry_points by @dependabot in #1651
- cleanup(dev): remove remnants of old bazel_integration_test code by @rickeylev in #1668
- chore: Migrate to rules_bazel_integration_test by @philsc in #1598
- fix(toolchains): register py cc toolchain for workspace builds by @rickeylev in #1670
- feat(py_runtime): Allow
py_runtime
to take an executable target as the interpreter by @mishazharov in #1621 - docs: update changelog for 0.28.0 release by @rickeylev in #1672
New Contributors
- @arrdem made their first contribution in #1166
- @mishazharov made their first contribution in #1588
- @siddharthab made their first contribution in #1582
- @tanan made their first contribution in #1649
Full Changelog: 0.27.0...0.28.0
0.22.1
This is a patch release of 0.22.0 that automatically registers the @bazel_tools//tools/python:autodetecting_toolchain
toolchain.
See bazelbuild/bazel#20458 for more information.
Using Bzlmod with Bazel 6
Add to your MODULE.bazel
file:
bazel_dep(name = "rules_python", version = "0.22.1")
pip = use_extension("@rules_python//python:extensions.bzl", "pip")
pip.parse(
name = "pip",
requirements_lock = "//:requirements_lock.txt",
)
use_repo(pip, "pip")
# (Optional) Register a specific python toolchain instead of using the host version
python = use_extension("@rules_python//python:extensions.bzl", "python")
python.toolchain(
name = "python3_9",
python_version = "3.9",
)
use_repo(python, "python3_9_toolchains")
register_toolchains(
"@python3_9_toolchains//:all",
)
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 = "a5640fddd4beb03e8c1fde5ed7160c0ba6bd477e7d048661c30c06936a26fd63",
strip_prefix = "rules_python-0.22.1",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.22.1/rules_python-0.22.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 = "a5640fddd4beb03e8c1fde5ed7160c0ba6bd477e7d048661c30c06936a26fd63",
strip_prefix = "rules_python-0.22.1/gazelle",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.22.1/rules_python-0.22.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()
Full Changelog: 0.22.0...0.22.1