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).
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
PyInfois 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
envsubstparameter, which enables environment variable substitutions in theextra_pip_argsattribute. -
(pip_repository) Added the
envsubstparameter, which enables environment variable substitutions in theextra_pip_argsattribute.
-
(bzlmod) pip.parse now does not fail with an empty
requirements.txt. -
(py_wheel) Wheels generated by
py_wheelnow preserve executable bits when being extracted byinstallerand/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_toolchainto 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_fileandextra_requires_filesattributes. -
(whl_library) experimental_target_platforms now supports specifying the Python version explicitly and the output
BUILD.bazelfile will be correct irrespective of the python interpreter that is generating the file and extracting thewhldistribution. 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.1using https://github.com/indygreg/python-build-standalone/releases/tag/20240107. -
(toolchain) Allow setting
x.yas thepython_versionparameter in the version-awarepy_binaryandpy_testrules. 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.8is selected. That also simplifies.bazelrcfor any users that set the defaultpython_versionstring 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_libsfor looser coupling to the underlying runtime repo implementation. -
(repo rules) The environment variable
RULES_PYTHON_REPO_DEBUG=1can 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.pyto 7.4.1.
0.29.0 - 2024-01-22
- BREAKING The deprecated
incompatible_generate_aliasesfeature flags frompip_parseandgazellegot removed. They had been flipped toTruein 0.27.0 release. - BREAKING (wheel) The
incompatible_normalize_nameandincompatible_normalize_versionflags have been removed. They had been flipped toTruein 0.27.0 release. - (bzlmod) The pip hub repository now uses the newly introduced config settings
using the
X.Ypython 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.lockfiles; Follow #1643 for removing platform-specific content inMODULE.bazel.lockfiles. -
(wheel) The stamp variables inside the distribution name are no longer lower-cased when normalizing under PEP440 conventions.
-
(toolchains)
python_register_toolchainsnow also generates a repository that is suffixed with_host, that has a single label:pythonthat is a symlink to the python interpreter for the host platform. The intended use is mainly inrepository_rule, which are always run usinghostplatform Python. This means thatWORKSPACEusers can now copy therequirements.bzlfile for vendoring as seen in the updatedpip_parse_vendoredexample. -
(runfiles)
rules_python.python.runfiles.Runfilesnow has a staticCreatemethod to make imports more ergonomic. Users should only need to import theRunfilesobject to locate runfiles. -
(toolchains)
PyRuntimeInfonow includes ainterpreter_version_infofield that contains the static version information for the given interpreter. This can be set viapy_runtimewhen 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.Yconfig settings to match on minor Python version. These settings match anyX.Yversion instead of just an exactX.Y.Zversion.
0.28.0 - 2024-01-07
-
BREAKING (pip_install) the deprecated
pip_installmacro 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.runfilesnow directly implements type hints and drops support for python2 as a result. -
(toolchains)
py_runtime,py_runtime_pair, andPyRuntimeInfonow 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_cyclesmay be provided a map of names to lists of requirements which form a dependency cycle.pip_parsewill break the cycle for you transparently. This behavior is also available under bzlmod aspip.parse(experimental_requirement_cycles={}). -
(toolchains)
py_runtimecan now take an executable target. Note: runfiles from the target are not supported yet. (#1612) -
(gazelle) When
python_generation_modeis set tofile, create onepy_binarytarget for each file withif __name__ == "__main__"instead of just onepy_binaryfor the whole module. -
(gazelle) the Gazelle manifest integrity field is now optional. If the
requirementsargument togazelle_python_manifestis 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_librarycan now parse thewhlMETADATA 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_parseor thebzlmodequivalent. This may help in cases where fetching wheels for a different platform usingdownload_only = Truefeature. -
(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_headersJust Work. (#1669) -
(bzlmod python.toolchain) The value of
ignore_root_user_erroris 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)
filegeneration mode can now also add__init__.pyto 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_bzlbzl_librarytarget internal as all of the publicly available symbols (etc.package_annotation) are re-exported via//python:pip_bzlbzl_library. -
(gazelle) Gazelle Python extension no longer has runtime dependencies. Using
GAZELLE_PYTHON_RUNTIME_DEPSfrom@rules_python_gazelle_plugin//:def.bzlis no longer necessary. -
(pip_parse) The installation of
pip_parserepository rule toolchain dependencies is now done as part ofpy_repositoriescall. -
(pip_parse) The generated
requirements.bzlfile now has an additional symbolall_whl_requirements_by_packagewhich provides a map from the normalized PyPI package name to the target that provides the built wheel file. Usepip_utils.normalize_namefunction from@rules_python//python:pip.bzlto convert a PyPI package name to a key in theall_whl_requirements_by_packagemap. -
(pip_parse) The flag
incompatible_generate_aliaseshas been flipped toTrueby default onnon-bzlmodsetups allowing users to use the same label strings during the transition period. For example, instead of@pypi_foo//:pkg, you can now use@pypi//fooor@pypi//foo:pkg. Other labels that are present in thefoopackage aredist_info,whlanddata. Note, that the@pypi_foo//:pkglabels are still present for backwards compatibility. -
(gazelle) The flag
use_pip_repository_aliasesis now set toTrueby default, which will causegazelleto change third-party dependency labels from@pip_foo//:pkgto@pip//fooby default. -
The
compile_pip_requirementsnow defaults topyproject.tomlif thesrcorrequirements_inattributes are unspecified, matching the upstreampip-compilebehaviour more closely. -
(gazelle) Use relative paths if possible for dependencies added through the use of the
resolvedirective. -
(gazelle) When using
python_generation_mode file, onepy_testtarget is made per test file even if a target named__test__or a file named__test__.pyexists in the same package. Previously in these cases there would only be one test target made.
Breaking changes:
-
(pip)
pip_installrepository 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_parseas a replacement. Thepip_parserule no longer supportsrequirementsattribute, please userequirements_lockinstead. -
(py_wheel) switch
incompatible_normalize_nameandincompatible_normalize_versiontoTrueby default to enforcePEP440for 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_librarywithstrip_import_prefixcan be imported now. -
(py_wheel) Produce deterministic wheel files and make
RECORDfile entries follow the order of files written to the.whlarchive. -
(gazelle) Generate a single
py_testtarget whengazelle:python_generation_mode projectis used. -
(gazelle) Move waiting for the Python interpreter process to exit to the shutdown hook to make the usage of the
exec.Commandmore idiomatic. -
(toolchains) Keep tcl subdirectory in Windows build of hermetic interpreter.
-
(bzlmod) sub-modules now don't have the
//conditions:defaultclause 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
.whlpatching support viapatchesandpatch_striparguments to the newpip.overridetag class. -
(pip) Support for using PEP621 compliant
pyproject.tomlfor creating a resolvedrequirements.txtfile. -
(utils) Added a
pip_utilsstruct with anormalize_namefunction to allow users to find out howrules_pythonwould 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
distribsattribute 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_internalmeans thepy_repositories()call is missing inWORKSPACE. -
(bzlmod) The
pip.parseextension 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_binaryrule used to build it. -
New Python versions available:
3.8.17,3.11.5using https://github.com/indygreg/python-build-standalone/releases/tag/20230826. -
(gazelle) New
# gazelle:python_generation_mode filedirective to support generating onepy_libraryper file. -
(python_repository) Support
netrcandauth_patternsattributes to enable authentication against private HTTP hosts serving Python toolchain binaries. -
//python:packaging_bzladded, abzl_libraryfor the Starlark files//python:packaging.bzlrequires. -
(py_wheel) Added the
incompatible_normalize_namefeature flag to normalize the package distribution name according to latest Python packaging standards. Defaults toFalsefor the time being. -
(py_wheel) Added the
incompatible_normalize_versionfeature 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 toFalsefor the time being. -
New Python versions available:
3.8.18,3.9.18,3.10.13,3.11.6,3.12.0using https://github.com/indygreg/python-build-standalone/releases/tag/20231002.3.12.0support is considered beta and may have issues.
-
(bzlmod) The
entry_pointmacro is no longer supported and has been removed in favour of thepy_console_script_binarymacro forbzlmodusers. -
(bzlmod) The
pip.parseno longer generates{hub_name}_{py_version}hub repos as theentry_pointmacro has been superseded bypy_console_script_binary. -
(bzlmod) The
pip.parseno 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.parsecan no longer automatically use the default Python version; this was an unreliable and unsafe behavior. Thepython_versionarg 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
mainarg is now correctly computed and usually optional. - (bzlmod)
pip.parseno 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_aliasesrenamed to `@python_versions - (bzlmod)
pip.parseargnamerenamed tohub_name - (bzlmod)
pip.parseargincompatible_generate_aliasesremoved 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.parsecan be called multiple times with different Python versions - (bzlmod) Allow bzlmod
pip.parseto 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-TypeandSummaryin METADATA - (py_wheel) Support for specifying
Project-URL - (compile_pip_requirements) Added
generate_hashesarg (default True) to control generating hashes - (pip) Create all_data_requirements alias
- Expose Python C headers through the toolchain.