This is a human-friendly changelog in a keepachangelog.com style format. Because this changelog is for end-user consumption of meaningful changes,only a summary of a release's changes is described. This means every commit is not necessarily mentioned, and internal refactors or code cleanups are omitted unless they're particularly notable.
A brief description of the categories of changes:
Changed
: Some behavior changed. If the change is expected to break a public API or supported behavior, it will be marked as BREAKING. Note that beta APIs will not have breaking API changes called out.Fixed
: A bug, or otherwise incorrect behavior, was fixed.Added
: A new feature, API, or behavior was added in a backwards compatible manner.- Particular sub-systems are identified using parentheses, e.g.
(bzlmod)
or(docs)
.
- (gazelle) Remove
visibility
fromNonEmptyAttr
. Now empty(have nodeps/main/srcs/imports
attr)py_library/test/binary
rules will be automatically deleted correctly. For example, ifpython_generation_mode
is set to package, when__init__.py
is deleted, thepy_library
generated for this package before will be deleted automatically.
0.32.2 - 2024-05-14
- 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.
0.32.0 - 2024-05-12
- (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 fixes
3.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
- (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 a
py_library
graph. Fixes #1760. - (bzlmod) Setting a particular micro version for the interpreter and the
pip.parse
extension is now possible, see theexamples/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).
- (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
andexperimental_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 usingparallel_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 theexperimental_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 theexperimental_requirement_cycles
, now is a good time to migrate.
0.31.0 - 2024-02-12
- For Bazel 7, the core rules and providers are now implemented in rules_python
directly and the rules bundled with Bazel are not used. Bazel 6 and earlier
continue to use the Bazel builtin symbols. Of particular note, this means,
under Bazel 7, the builtin global symbol
PyInfo
is not the same as what is loaded from rules_python. The same is true ofPyRuntimeInfo
.
0.30.0 - 2024-02-12
-
(toolchains) Windows hosts always ignore pyc files in the downloaded runtimes. This fixes issues due to pyc files being created at runtime and affecting the definition of what files were considered part of the runtime.
-
(pip_parse) Added the
envsubst
parameter, which enables environment variable substitutions in theextra_pip_args
attribute. -
(pip_repository) Added the
envsubst
parameter, which enables environment variable substitutions in theextra_pip_args
attribute.
-
(bzlmod) pip.parse now does not fail with an empty
requirements.txt
. -
(py_wheel) Wheels generated by
py_wheel
now preserve executable bits when being extracted byinstaller
and/orpip
. -
(coverage) During the running of lcov, the stdout/stderr was causing test failures. By default, suppress output when generating lcov. This can be overridden by setting 'VERBOSE_COVERAGE'. This change only affect bazel 7.x.x and above.
-
(toolchain) Changed the
host_toolchain
to symlink all files to support Windows host environments without symlink support. -
(PyRuntimeInfo) Switch back to builtin PyRuntimeInfo for Bazel 6.4 and when pystar is disabled. This fixes an error about
target ... does not have ... PyRuntimeInfo
. (#1732)
-
(py_wheel) Added
requires_file
andextra_requires_files
attributes. -
(whl_library) experimental_target_platforms now supports specifying the Python version explicitly and the output
BUILD.bazel
file will be correct irrespective of the python interpreter that is generating the file and extracting thewhl
distribution. Multiple python target version can be specified and the code generation will generate version specific dependency closures but that is not yet ready to be used and may break the build if the default python version is not selected usingcommon --@rules_python//python/config_settings:python_version=X.Y.Z
. -
New Python versions available:
3.11.7
,3.12.1
using https://github.com/indygreg/python-build-standalone/releases/tag/20240107. -
(toolchain) Allow setting
x.y
as thepython_version
parameter in the version-awarepy_binary
andpy_test
rules. This allows users to use the same rule import for testing with specific Python versions and rely on toolchain configuration and how the latest version takes precedence if e.g.3.8
is selected. That also simplifies.bazelrc
for any users that set the defaultpython_version
string flag in that way. -
(toolchain) The runtime's shared libraries (libpython.so et al) can be accessed using
@rules_python//python/cc:current_py_cc_libs
. This uses toolchain resolution, so the files are from the same runtime used to run a target. If you were previously using e.g.@python_3_11//:libpython
, then switch to:current_py_cc_libs
for looser coupling to the underlying runtime repo implementation. -
(repo rules) The environment variable
RULES_PYTHON_REPO_DEBUG=1
can be set to make repository rules log detailed information about what they're up to. -
(coverage) Add support for python 3.12 and bump
coverage.py
to 7.4.1.
0.29.0 - 2024-01-22
- BREAKING The deprecated
incompatible_generate_aliases
feature flags frompip_parse
andgazelle
got removed. They had been flipped toTrue
in 0.27.0 release. - BREAKING (wheel) The
incompatible_normalize_name
andincompatible_normalize_version
flags have been removed. They had been flipped toTrue
in 0.27.0 release. - (bzlmod) The pip hub repository now uses the newly introduced config settings
using the
X.Y
python version notation. This improves cross module interoperability and allows to share wheels built by interpreters using different patch versions.
-
(bzlmod pip.parse) Use a platform-independent reference to the interpreter pip uses. This reduces (but doesn't eliminate) the amount of platform-specific content in
MODULE.bazel.lock
files; Follow #1643 for removing platform-specific content inMODULE.bazel.lock
files. -
(wheel) The stamp variables inside the distribution name are no longer lower-cased when normalizing under PEP440 conventions.
-
(toolchains)
python_register_toolchains
now also generates a repository that is suffixed with_host
, that has a single label:python
that is a symlink to the python interpreter for the host platform. The intended use is mainly inrepository_rule
, which are always run usinghost
platform Python. This means thatWORKSPACE
users can now copy therequirements.bzl
file for vendoring as seen in the updatedpip_parse_vendored
example. -
(runfiles)
rules_python.python.runfiles.Runfiles
now has a staticCreate
method to make imports more ergonomic. Users should only need to import theRunfiles
object to locate runfiles. -
(toolchains)
PyRuntimeInfo
now includes ainterpreter_version_info
field that contains the static version information for the given interpreter. This can be set viapy_runtime
when registering an interpreter toolchain, and will done automatically for the builtin interpreter versions registered viapython_register_toolchains
. Note that this only available on the Starlark implementation of the provider. -
(config_settings) Added
//python/config_settings:is_python_X.Y
config settings to match on minor Python version. These settings match anyX.Y
version instead of just an exactX.Y.Z
version.
0.28.0 - 2024-01-07
-
BREAKING (pip_install) the deprecated
pip_install
macro and related items have been removed. -
BREAKING Support for Bazel 5 has been officially dropped. This release was only partially tested with Bazel 5 and may or may not work with Bazel 5. Subequent versions will no longer be tested under Bazel 5.
-
(runfiles)
rules_python.python.runfiles
now directly implements type hints and drops support for python2 as a result. -
(toolchains)
py_runtime
,py_runtime_pair
, andPyRuntimeInfo
now use the rules_python Starlark implementation, not the one built into Bazel. NOTE: This only applies to Bazel 6+; Bazel 5 still uses the builtin implementation. -
(pip_parse) The parameter
experimental_requirement_cycles
may be provided a map of names to lists of requirements which form a dependency cycle.pip_parse
will break the cycle for you transparently. This behavior is also available under bzlmod aspip.parse(experimental_requirement_cycles={})
. -
(toolchains)
py_runtime
can now take an executable target. Note: runfiles from the target are not supported yet. (#1612) -
(gazelle) When
python_generation_mode
is set tofile
, create onepy_binary
target for each file withif __name__ == "__main__"
instead of just onepy_binary
for the whole module. -
(gazelle) the Gazelle manifest integrity field is now optional. If the
requirements
argument togazelle_python_manifest
is unset, no integrity field will be generated.
-
(gazelle) The gazelle plugin helper was not working with Python toolchains 3.11 and above due to a bug in the helper components not being on PYTHONPATH.
-
(pip_parse) The repositories created by
whl_library
can now parse thewhl
METADATA and generate dependency closures irrespective of the host platform the generation is executed on. This can be turned on by supplyingexperimental_target_platforms = ["all"]
to thepip_parse
or thebzlmod
equivalent. This may help in cases where fetching wheels for a different platform usingdownload_only = True
feature. -
(bzlmod pip.parse) The
pip.parse(python_interpreter)
arg now works for specifying a local system interpreter. -
(bzlmod pip.parse) Requirements files with duplicate entries for the same package (e.g. one for the package, one for an extra) now work.
-
(bzlmod python.toolchain) Submodules can now (re)register the Python version that rules_python has set as the default. (#1638)
-
(whl_library) Actually use the provided patches to patch the whl_library. On Windows the patching may result in files with CRLF line endings, as a result the RECORD file consistency requirement is lifted and now a warning is emitted instead with a location to the patch that could be used to silence the warning. Copy the patch to your workspace and add it to the list if patches for the wheel file if you decide to do so.
-
(coverage): coverage reports are now created when the version-aware rules are used. (#1600)
-
(toolchains) Workspace builds register the py cc toolchain (bzlmod already was). This makes e.g.
//python/cc:current_py_cc_headers
Just Work. (#1669) -
(bzlmod python.toolchain) The value of
ignore_root_user_error
is now decided by the root module only. (#1658)
- (docs) bzlmod extensions are now documented on rules-python.readthedocs.io
- (docs) Support and backwards compatibility policies have been documented. See https://rules-python.readthedocs.io/en/latest/support.html
- (gazelle)
file
generation mode can now also add__init__.py
to the srcs attribute for every target in the package. This is enabled through a separate directivepython_generation_mode_per_file_include_init
.
0.27.0 - 2023-11-16
-
Make
//python/pip_install:pip_repository_bzl
bzl_library
target internal as all of the publicly available symbols (etc.package_annotation
) are re-exported via//python:pip_bzl
bzl_library
. -
(gazelle) Gazelle Python extension no longer has runtime dependencies. Using
GAZELLE_PYTHON_RUNTIME_DEPS
from@rules_python_gazelle_plugin//:def.bzl
is no longer necessary. -
(pip_parse) The installation of
pip_parse
repository rule toolchain dependencies is now done as part ofpy_repositories
call. -
(pip_parse) The generated
requirements.bzl
file now has an additional symbolall_whl_requirements_by_package
which provides a map from the normalized PyPI package name to the target that provides the built wheel file. Usepip_utils.normalize_name
function from@rules_python//python:pip.bzl
to convert a PyPI package name to a key in theall_whl_requirements_by_package
map. -
(pip_parse) The flag
incompatible_generate_aliases
has been flipped toTrue
by default onnon-bzlmod
setups allowing users to use the same label strings during the transition period. For example, instead of@pypi_foo//:pkg
, you can now use@pypi//foo
or@pypi//foo:pkg
. Other labels that are present in thefoo
package aredist_info
,whl
anddata
. Note, that the@pypi_foo//:pkg
labels are still present for backwards compatibility. -
(gazelle) The flag
use_pip_repository_aliases
is now set toTrue
by default, which will causegazelle
to change third-party dependency labels from@pip_foo//:pkg
to@pip//foo
by default. -
The
compile_pip_requirements
now defaults topyproject.toml
if thesrc
orrequirements_in
attributes are unspecified, matching the upstreampip-compile
behaviour more closely. -
(gazelle) Use relative paths if possible for dependencies added through the use of the
resolve
directive. -
(gazelle) When using
python_generation_mode file
, onepy_test
target is made per test file even if a target named__test__
or a file named__test__.py
exists in the same package. Previously in these cases there would only be one test target made.
Breaking changes:
-
(pip)
pip_install
repository rule in this release has been disabled and will fail by default. The API symbol is going to be removed in the next version, please migrate topip_parse
as a replacement. Thepip_parse
rule no longer supportsrequirements
attribute, please userequirements_lock
instead. -
(py_wheel) switch
incompatible_normalize_name
andincompatible_normalize_version
toTrue
by default to enforcePEP440
for wheel names built byrules_python
. -
(tools/wheelmaker.py) drop support for Python 2 as only Python 3 is tested.
-
Skip aliases for unloaded toolchains. Some Python versions that don't have full platform support, and referencing their undefined repositories can break operations like
bazel query rdeps(...)
. -
Python code generated from
proto_library
withstrip_import_prefix
can be imported now. -
(py_wheel) Produce deterministic wheel files and make
RECORD
file entries follow the order of files written to the.whl
archive. -
(gazelle) Generate a single
py_test
target whengazelle:python_generation_mode project
is used. -
(gazelle) Move waiting for the Python interpreter process to exit to the shutdown hook to make the usage of the
exec.Command
more idiomatic. -
(toolchains) Keep tcl subdirectory in Windows build of hermetic interpreter.
-
(bzlmod) sub-modules now don't have the
//conditions:default
clause in the hub repos created bypip.parse
. This should fix confusing error messages in case there is a misconfiguration of toolchains or a bug inrules_python
.
-
(bzlmod) Added
.whl
patching support viapatches
andpatch_strip
arguments to the newpip.override
tag class. -
(pip) Support for using PEP621 compliant
pyproject.toml
for creating a resolvedrequirements.txt
file. -
(utils) Added a
pip_utils
struct with anormalize_name
function to allow users to find out howrules_python
would normalize a PyPI distribution name.
0.26.0 - 2023-10-06
-
Python version patch level bumps:
- 3.8.15 -> 3.8.18
- 3.9.17 -> 3.9.18
- 3.10.12 -> 3.10.13
- 3.11.4 -> 3.11.6
-
(deps) Upgrade rules_go 0.39.1 -> 0.41.0; this is so gazelle integration works with upcoming Bazel versions
-
(multi-version) The
distribs
attribute is no longer propagated. This attribute has been long deprecated by Bazel and shouldn't be used. -
Calling
//python:repositories.bzl#py_repositories()
is required. It has always been documented as necessary, but it was possible to omit it in certain cases. An error about@rules_python_internal
means thepy_repositories()
call is missing inWORKSPACE
. -
(bzlmod) The
pip.parse
extension will generate os/arch specific lock file entries onbazel>=6.4
.
-
(bzlmod, entry_point) Added
py_console_script_binary
, which allows adding custom dependencies to a package's entry points and customizing thepy_binary
rule used to build it. -
New Python versions available:
3.8.17
,3.11.5
using https://github.com/indygreg/python-build-standalone/releases/tag/20230826. -
(gazelle) New
# gazelle:python_generation_mode file
directive to support generating onepy_library
per file. -
(python_repository) Support
netrc
andauth_patterns
attributes to enable authentication against private HTTP hosts serving Python toolchain binaries. -
//python:packaging_bzl
added, abzl_library
for the Starlark files//python:packaging.bzl
requires. -
(py_wheel) Added the
incompatible_normalize_name
feature flag to normalize the package distribution name according to latest Python packaging standards. Defaults toFalse
for the time being. -
(py_wheel) Added the
incompatible_normalize_version
feature flag to normalize the package version according to PEP440 standard. This also adds support for local version specifiers (versions with a+
in them), in accordance with PEP440. Defaults toFalse
for the time being. -
New Python versions available:
3.8.18
,3.9.18
,3.10.13
,3.11.6
,3.12.0
using https://github.com/indygreg/python-build-standalone/releases/tag/20231002.3.12.0
support is considered beta and may have issues.
-
(bzlmod) The
entry_point
macro is no longer supported and has been removed in favour of thepy_console_script_binary
macro forbzlmod
users. -
(bzlmod) The
pip.parse
no longer generates{hub_name}_{py_version}
hub repos as theentry_point
macro has been superseded bypy_console_script_binary
. -
(bzlmod) The
pip.parse
no longer generates{hub_name}_{distribution}
hub repos.
-
(whl_library) No longer restarts repository rule when fetching external dependencies improving initial build times involving external dependency fetching.
-
(gazelle) Improve runfiles lookup hermeticity.
0.25.0 - 2023-08-22
- Python version patch level bumps:
- 3.9.16 -> 3.9.17
- 3.10.9 -> 3.10.12
- 3.11.1 -> 3.11.4
- (bzlmod)
pip.parse
can no longer automatically use the default Python version; this was an unreliable and unsafe behavior. Thepython_version
arg must always be explicitly specified.
- (docs) Update docs to use correct bzlmod APIs and clarify how and when to use various APIs.
- (multi-version) The
main
arg is now correctly computed and usually optional. - (bzlmod)
pip.parse
no longer requires a call for whatever the configured default Python version is.
- Created a changelog.
- (gazelle) Stop generating unnecessary imports.
- (toolchains) s390x supported for Python 3.9.17, 3.10.12, and 3.11.4.
0.24.0 - 2023-07-11
- BREAKING (gazelle) Gazelle 0.30.0 or higher is required
- (bzlmod)
@python_aliases
renamed to `@python_versions - (bzlmod)
pip.parse
argname
renamed tohub_name
- (bzlmod)
pip.parse
argincompatible_generate_aliases
removed and always true.
- (bzlmod) Fixing Windows Python Interpreter symlink issues
- (py_wheel) Allow twine tags and args
- (toolchain, bzlmod) Restrict coverage tool visibility under bzlmod
- (pip) Ignore temporary pyc.NNN files in wheels
- (pip) Add format() calls to glob_exclude templates
- plugin_output in py_proto_library rule
- Using Gazelle's lifecycle manager to manage external processes
- (bzlmod)
pip.parse
can be called multiple times with different Python versions - (bzlmod) Allow bzlmod
pip.parse
to reference the default python toolchain and interpreter - (bzlmod) Implementing wheel annotations via
whl_mods
- (gazelle) support multiple requirements files in manifest generation
- (py_wheel) Support for specifying
Description-Content-Type
andSummary
in METADATA - (py_wheel) Support for specifying
Project-URL
- (compile_pip_requirements) Added
generate_hashes
arg (default True) to control generating hashes - (pip) Create all_data_requirements alias
- Expose Python C headers through the toolchain.