Releases: bazel-contrib/rules_python
0.23.0
Using Bzlmod with Bazel 6
NOTE: bzlmod support is still experimental; apis are still subject to change
This release introduces two notable changes to bzlmod support:
- A default toolchain is automatically registered for you. You no longer need to call
register_toolchains()
yourself. Depending
on rules_python through bazel_dep is sufficient. Note, however, the Python version used for this default toolchain will change
frequently/unexpectedly to track the a recent Python version. - The
name
arg ofpython.toolchain
has been removed. The toolchain repo name format ispython_X_Y
e.g.python_3_11
.
Add to your MODULE.bazel
file:
bazel_dep(name = "rules_python", version = "0.23.0")
pip = use_extension("@rules_python//python:extensions.bzl", "pip")
pip.parse(
name = "pip",
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 = "8272287b125a23bfc79650ecbbc045ebcaee4d632338b1a50aad34357bcbadce",
strip_prefix = "rules_python-0.23.0",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.23.0/rules_python-0.23.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 = "8272287b125a23bfc79650ecbbc045ebcaee4d632338b1a50aad34357bcbadce",
strip_prefix = "rules_python-0.23.0/gazelle",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.23.0/rules_python-0.23.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(bzlmod): Allowing multiple python.toolchain extension calls by @chrislovecnm in #1230
- build: Upgrade Gazelle to v0.31.0 by @linzhp in #1240
- fix: make
import python.runfiles
work with--experimental_python_import_all_repositories=false
by @rickeylev in #1243 - feat(bzlmod): Moving register.toolchains internal by @chrislovecnm in #1238
- docs(compile_pip_requirements): Add note on requirements.txt VC by @boomanaiden154 in #1245
- cleanup: Set toolchain target_setting directly instead of via inline ternary by @rickeylev in #1246
- fix(bzlmod): give precedence to the first seen versioned toolchain by @rickeylev in #1244
- chore: add a pre-commit hook to maintain deleted packages by @aignas in #1208
- chore: auto-publish gazelle module to BCR by @kormide in #1247
- fix(coverage): bump to latest coverage.py and fix import shadowing by @aignas in #1249
- feat: add ppc64le releases and update to 3.10.11, 3.11.3 for python-build-standalone by @clnperez in #1234
- fix(bzlmod)!: Remove ability to specify toolchain repo name. by @rickeylev in #1258
- fix: update correct requirements lock file when using os specific lock files by @Rasrack in #1123
- fix: use
only-binary
fordownload_only
pip download
by @lpulley in #1219 - feat: Adding variable support for distribution in py_wheel by @ns-tkonduri in #1251
- feat(bzlmod): Register a default toolchain by @rickeylev in #1259
New Contributors
- @boomanaiden154 made their first contribution in #1245
- @clnperez made their first contribution in #1234
- @lpulley made their first contribution in #1219
- @ns-tkonduri made their first contribution in #1251
Full Changelog: 0.22.0...0.23.0
0.22.0
Notable and Breaking Changes
Bzlmod extension paths have changed
As part of fixing some fundamental issues with the bzlmod support, we had to change the path to our extensions. Instead of all extensions being in a single extensions.bzl
file, each extension is in its own file. Users must update the file path in their use_repo()
statements as follows:
use_extension("@rules_python//python:extensions.bzl", "python")
->use_extension("@rules_python//python/extensions:python.bzl", "python")
use_extension("@rules_python//python:extensions.bzl", "pip")
->use_extension("@rules_python//python/extensions:pip.bzl", "pip")
The following sed
commands should approximate the necessary changes:
sed 'sXuse_extension("@rules_python//python:extensions.bzl", "python")Xuse_extension("@rules_python//python/extensions:python.bzl", "python")X'`
sed 'sXuse_extension("@rules_python//python:extensions.bzl", "pip")Xuse_extension("@rules_python//python/extensions:pip.bzl", "pip")X'`
See examples/bzlmod_build_file_generation/MODULE.bazel
for an example of the new paths.
Lockfile output churn
The output of lockfiles has slightly changed. Though functionally the same, their integrity hashes will change.
Using Bzlmod with Bazel 6
NOTE: Bzlmod support is still in beta.
Add to your MODULE.bazel
file:
bazel_dep(name = "rules_python", version = "0.22.0")
pip = use_extension("@rules_python//python/extensions:pip.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:python.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 = "863ba0fa944319f7e3d695711427d9ad80ba92c6edd0b7c7443b84e904689539",
strip_prefix = "rules_python-0.22.0",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.22.0/rules_python-0.22.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 = "863ba0fa944319f7e3d695711427d9ad80ba92c6edd0b7c7443b84e904689539",
strip_prefix = "rules_python-0.22.0/gazelle",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.22.0/rules_python-0.22.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 reference to @bazel_tools//tools/python/private:defs.bzl by @comius in #1173
- docs: Tell how to use GitHub to find commits in an upcoming release. by @rickeylev in #1092
- fix: compile_pip_requirements test from external repositories by @Rasrack in #1124
- feat: add Python 3.8.16 by @jml-derek in #1168
- test: Set mac platform for test_mac_requires_darwin_for_execution by @rickeylev in #1179
- fix: Don't reference deleted private bazel_tools bzl file by @rickeylev in #1180
- docs: Add starlark directive to code snippet by @blorente in #1170
- tests: Upgrade rules_testing to 0.0.5 by @rickeylev in #1184
- tests: Set linux platform for test_non_mac_doesnt_require_darwin_for_execution by @rickeylev in #1183
- fix(bzlmod): correctly template repository macros for requirements, etc by @aignas in #1190
- type:docs Update README.md by @yuanweixin in #1186
- fix: Allow passing a tuple to the
tags
attribute. by @rickeylev in #1191 - tests: Add skylib to various test dependencies to fix CI by @chrislovecnm in #1199
- feat: removing bzlmod from example by @chrislovecnm in #1200
- feat: propagate visibility attribute for py_wheel publishing by @chrislovecnm in #1203
- docs: fix typos in pip_repository docs by @martis42 in #1202
- tests: Force analysis test labels to resolve within @rules_python context by @rickeylev in #1187
- fix(update_deleted_packages.sh): allow to run from anywhere in the repo by @aignas in #1206
- feat(bzlmod): expose platform-agnostic repo target for toolchain interpreter by @chrislovecnm in #1155
- fix(update_deleted_packages.sh): wheels example should not be included in .bazelrc by @aignas in #1207
- fix: Strip trailing newline from python output by @illicitonion in #1212
- fix: manually ignore bazel-* directories to make using custom Bazel builds easier by @rickeylev in #1181
- test(bzlmod): explicitly enable bzlmod in the test harness by @aignas in #1204
- feat(bzlmod): Cleaning up interpreter resolution by @chrislovecnm in #1218
- feat(bzlmod)!: Move each bzlmod extension into its own file by @chrislovecnm in #1226
- Adding bzlmod support document by @chrislovecnm in #1214
- test(coverage): add a test to check the sys.path under bzlmod by @aignas in #1223
- fix(toolchain): set correct return attrs to remove non-hermeticity warning by @aignas in #1231
- fix: allow url fragments in requirements file by @mattoberle in #1195
- fix:
example/build_file_generation/README.md
by @ofey404 in #1164 - fix: Using canonical name in requirements.bzl by @linzhp in #1176
- feat(bzlmod): support entry_point macro by @aignas in #1220
New Contributors
- @Rasrack made their first contribution in #1124
- @jml-derek made their first contribution in #1168
- @blorente made their first contribution in #1170
- @yuanweixin made their first contribution in #1186
- @ofey404 made their first contribution in #1164
Full Changelog: 0.21.0...0.22.0
0.21.0
Using Bzlmod with Bazel 6
Add to your MODULE.bazel
file:
bazel_dep(name = "rules_python", version = "0.21.0")
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 = "94750828b18044533e98a129003b6a68001204038dc4749f40b195b24c38f49f",
strip_prefix = "rules_python-0.21.0",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.21.0/rules_python-0.21.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 = "94750828b18044533e98a129003b6a68001204038dc4749f40b195b24c38f49f",
strip_prefix = "rules_python-0.21.0/gazelle",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.21.0/rules_python-0.21.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
- cleanup: factor reexports.bzl into the respective implementation files by @rickeylev in #1137
- fix: bump installer to handle windows better by @f0rmiga in #1138
- build: Fixing buildifier by @chrislovecnm in #1148
- docs: Updating documentation for bzlmod by @chrislovecnm in #1149
- fix: use a consistent buildifier version for CI and pre-commit by @aignas in #1151
- chore: bump buildifier to 6.1.0 by @aignas in #1152
- fix: correct the labels returned by all_requirements lists by @aignas in #1146
- fix: gazelle correctly adds new py_test rules by @amartani in #1143
- fix: respect kind mapping by @OniOni in #1158
- test: cleanup gazelle tests and run them in parallel by @aignas in #1159
- [docs] Fixing rule name in coverage.md docs by @anfelbar in #1162
- feat: Support specifying multiple download URLs in tool_versions. by @quval in #1145
New Contributors
- @amartani made their first contribution in #1143
- @anfelbar made their first contribution in #1162
- @quval made their first contribution in #1145
Full Changelog: 0.20.0...0.21.0
0.20.0
Using Bzlmod with Bazel 6
Add to your MODULE.bazel
file:
bazel_dep(name = "rules_python", version = "0.20.0")
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 = "a644da969b6824cc87f8fe7b18101a8a6c57da5db39caa6566ec6109f37d2141",
strip_prefix = "rules_python-0.20.0",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.20.0/rules_python-0.20.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 = "a644da969b6824cc87f8fe7b18101a8a6c57da5db39caa6566ec6109f37d2141",
strip_prefix = "rules_python-0.20.0/gazelle",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.20.0/rules_python-0.20.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
- chore: fix some lingering GH archive URLs by @alexeagle in #1108
- feat: add bzlmod support for gazelle plugin by @aignas in #1077
- docs: Simplify pull request template by @rickeylev in #1100
- chore: fix syntax that stardoc misunderstands as HTML by @alexeagle in #1110
- fix: update gazelle to properly handle dot in package name. by @OniOni in #1083
- fix(bzlmod): expose ignore_root_user_error attribute from python_register_toolchains by @alexeagle in #1114
- feat: add bzl_library for defs.bzl and its dependencies by @rickeylev in #1115
- fix: docs for ignore_root_user_error at the module level by @stonier in #1112
- fix: generation of toolchain aliases //:defs.bzl file. by @oxidase in #1088
- feat: make variable substitution for py_wheel abi, python_tag args by @stonier in #1113
- feat: add bzl_library for proto.bzl by @rickeylev in #1116
- cleanup: Remove license comment in proto build file by @rickeylev in #1118
- fix: restrict proto package visibility to private by @rickeylev in #1117
- cleanup: rename proto BUILD -> BUILD.bazel by @rickeylev in #1119
- feat: bzl file per rule/provider by @rickeylev in #1122
- cleanup: fix typo: libraries, not libaries by @rickeylev in #1127
- feat: add public entry point for PyCcLinkParamsInfo by @rickeylev in #1128
- cleanup: reformat defs.bzl doc string. by @rickeylev in #1126
- fix: Include filename when parsing imports for gazelle by @jlaxson in #1133
New Contributors
Full Changelog: 0.19.0...0.20.0
0.19.0
Using Bzlmod with Bazel 6
Add to your MODULE.bazel
file:
bazel_dep(name = "rules_python", version = "0.19.0")
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 = "ffc7b877c95413c82bfd5482c017edcf759a6250d8b24e82f41f3c8b8d9e287e",
strip_prefix = "rules_python-0.19.0",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.19.0/rules_python-0.19.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 = "ffc7b877c95413c82bfd5482c017edcf759a6250d8b24e82f41f3c8b8d9e287e",
strip_prefix = "rules_python-0.19.0/gazelle",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.19.0/rules_python-0.19.0.tar.gz",
)
What's Changed
- Making exclusions more strict by @linzhp in #1054
- docs: fix requirement line for runfiles example by @alexeagle in #1052
- fix: make py_proto_library respect PyInfo imports by @aignas in #1046
- Make toolchain acceptance tests work with latest Bazel build CI pipeline by @rickeylev in #1062
- Only set
py_runtime.coverage_tool
for Bazel 6 and higher. by @rickeylev in #1061 - Allow building with unreleased Bazel versions. by @rickeylev in #1063
- Extending server process timeout by @linzhp in #1060
- chore: regenerate gazelle_python.yaml manifest by @aignas in #1066
- feat: wheel publishing by @alexeagle in #1015
- fix: checked-in requirements imports generated requirements by @f0rmiga in #1053
- fix: Propagate testonly et al for wheel
.dist
targets by @rickeylev in #1064 - fix: correctly advertise minimum supported version by @aignas in #1065
- refactor: starlark reimplementation of pip_repository by @aignas in #1043
- Add some docs about how to configure coverage. by @rickeylev in #1074
- Remove empty line between copyright and build file docstring. by @rickeylev in #1084
- cleanup: Remove license type comment; they're no longer required by @rickeylev in #1078
- fix: Use GitHub download URL for BCR URL instead of archive URL. by @rickeylev in #1093
- Add a script to add missing license headers by @rickeylev in #1094
- fix: Update pre-commit dependency versions so isort works. by @rickeylev in #1096
- docs: doc that the Conventional Commit style should be used for merged commits and PRs by @rickeylev in #1099
- test(core): Add analysis tests for base Python rules. by @rickeylev in #1102
Full Changelog: 0.18.0...0.19.0
0.18.1
Using Bzlmod with Bazel 6
Add to your MODULE.bazel
file:
bazel_dep(name = "rules_python", version = "0.18.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 = "29a801171f7ca190c543406f9894abf2d483c206e14d6acbd695623662320097",
strip_prefix = "rules_python-0.18.1",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.18.1/rules_python-0.18.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 = "29a801171f7ca190c543406f9894abf2d483c206e14d6acbd695623662320097",
strip_prefix = "rules_python-0.18.1/gazelle",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.18.1/rules_python-0.18.1.tar.gz",
)
Relevant Changes
- Only set
py_runtime.coverage_tool
for Bazel 6 and higher. (#1061)
Full Changelog: 0.18.0...0.18.1
0.18.0
Using Bzlmod with Bazel 6
Add to your MODULE.bazel
file:
bazel_dep(name = "rules_python", version = "0.18.0")
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 = "36362b4d54fcb17342f9071e4c38d63ce83e2e57d7d5599ebdde4670b9760664",
strip_prefix = "rules_python-0.18.0",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.18.0/rules_python-0.18.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 = "36362b4d54fcb17342f9071e4c38d63ce83e2e57d7d5599ebdde4670b9760664",
strip_prefix = "rules_python-0.18.0/gazelle",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.18.0/rules_python-0.18.0.tar.gz",
)
Relevant Changes
Post-release notes
- bug #1056: This release does not work with Bazel 5. Please upgrade to 0.18.1
Coverage
rules_python
now includes coverage as part of the toolchain as an opt-in feature. To get started, pass register_coverage_tool = True
to python_register_toolchains
or python_register_multi_toolchains
.
runfiles wheel
The bazel-runfiles
wheel is now published to https://pypi.org/project/bazel-runfiles/.
What's Changed
- Using label as id for py targets by @linzhp in #1023
- Handling imports from sibling modules by @linzhp in #1027
- Add missing copyright headers by @rickeylev in #1030
- feat: allow extra dependencies to be passed to pip-compile by @f0rmiga in #1026
- feat(coverage): Register coverage.py to hermetic toolchains by @aignas in #977
- Manually generate distribution archives by @rickeylev in #1032
- fix: use 'repo' as prefix when constructing annotations label by @mattem in #1033
- Resolving sibling modules with absolute imports by @linzhp in #1029
- fix: reorder imports by @f0rmiga in #1034
- Revert "Resolving sibling modules with absolute imports" by @f0rmiga in #1035
- Fix glob includes/exclues by @illicitonion in #1038
- Fixed glob includes for ignore_root_user_error by @linzhp in #1037
- Pass cpp flags through in all cases to repository rule compilations by @shs96c in #1040
- feat: add logic from #1029 back with fix by @f0rmiga in #1039
- clean up UUID by @linzhp in #1028
- Use go_test to verify manifest by @linzhp in #1044
- fix: move coverage pkg to end of sys.path to avoid collisions by @f0rmiga in #1045
- fix(release): minimum needed to run twine to publish by @alexeagle in #1021
- release: publish our runfiles wheel to pypi by @alexeagle in #1048
- Add requires-network to pip requirements update. by @matts1 in #1050
- Document the pypi user and how to manage it. by @rickeylev in #1049
- fix(release): wrong replacement for $(location) during code review by @alexeagle in #1051
New Contributors
Full Changelog: 0.17.3...0.18.0
0.17.3
Note, the prior 0.17 tags (0.17.0, 0.17.1, and 0.17.2) were never published as releases and can be ignored.
Breaking Change
The Gazelle extension for Python has been updated to better integrate with the conventions of Python and Bazel. This includes changes to how test files with the prefix or suffix of "test_" and "*_test" are handled. If a test target is not present, these files will now be added to individual py_test targets. To align your projects with these changes, any test utility files that were previously included in py_library targets and have the aforementioned prefix or suffix, will need to be renamed for consistency.
To use the gazelle extension you must now fetch another external repository, rules_python_gazelle_plugin
, see the snippet below.
Also, change your gazelle binary registration to load from this new repository:
gazelle(
name = "gazelle",
data = GAZELLE_PYTHON_RUNTIME_DEPS,
gazelle = "@rules_python_gazelle_plugin//python:gazelle_binary",
)
Using Bzlmod with Bazel 6
Add to your MODULE.bazel
file:
bazel_dep(name = "rules_python", version = "0.17.3")
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 = "8c15896f6686beb5c631a4459a3aa8392daccaab805ea899c9d14215074b60ef",
strip_prefix = "rules_python-0.17.3",
url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/0.17.3.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 = "8c15896f6686beb5c631a4459a3aa8392daccaab805ea899c9d14215074b60ef",
strip_prefix = "rules_python-0.17.3/gazelle",
url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/0.17.3.tar.gz",
)
What's Changed
- Update runfiles lib by @fmeum in #982
- Refactor poor naming and unused code in wheel_installer by @groodt in #990
- Add new Python versions including 3.11 by @jvolkman in #992
- runfiles: Drop outdated comments about vendoring by @fmeum in #986
- Implement py_proto_library by @comius in #832
- runfiles: Fix usage instructions by @fmeum in #985
- chore: fix red CI - buildifier was broken by #832 by @alexeagle in #996
- runfiles: Import
CurrentRepository
from Bazel by @fmeum in #988 - Fix misleading error message by @suzaku in #927
- runfiles: Apply repo mapping to Rlocation path by @fmeum in #998
- fix(deps): declare our dependency on bazel_skylib by @alexeagle in #1001
- chore: publish a runfiles library as a wheel by @alexeagle in #995
- feat: allow patching the interpreter fetched via toolchains by @mattem in #1004
- Redirect stdout when checking imports. by @aptenodytes-forsteri in #1007
- Fix Python interpreter target labels with @@ prefixes. by @oxidase in #940
- cleanup: remove vendored copy of skylib by @alexeagle in #1003
- generate py_test without test by @linzhp in #999
- Add runtime dependencies to gazelle extension by @linzhp in #993
- fix: allow omitting the
strip_prefix
intool_versions
by @lummax in #975 - refactor(gazelle): Move plugin to a separate directory. by @aignas in #983
- fix: windows
*.lib
interface inpython_headers
by @lummax in #976 - python_repository: Exclude pycache files by @illicitonion in #907
- runfiles: Remove dead code by @fmeum in #1011
- runfiles: Add proper test coverage for an edge case by @fmeum in #1012
- refactor: pull implementations out of packaging.bzl by @alexeagle in #1013
- Fix requirement parser by @tgeng in #1009
- feat(gazelle)!: Move the plugin to a separate workspace by @aignas in #972
- refactor: py_wheel now a macro by @alexeagle in #1014
- fix: ensure 'patches' attr is included for the canonical representation of the toolchain by @mattem in #1018
- feat: produce publishable distribution archives by @alexeagle in #1019
- fix(release): use correct GH workflows syntax by @alexeagle in #1020
- feat: allow absolute urls in
tool_versions
by @lummax in #973 - chore: revert publish wheel on releases by @alexeagle in #1022
New Contributors
- @fmeum made their first contribution in #982
- @comius made their first contribution in #832
- @suzaku made their first contribution in #927
- @oxidase made their first contribution in #940
- @linzhp made their first contribution in #999
- @lummax made their first contribution in #975
- @illicitonion made their first contribution in #907
- @tgeng made their first contribution in #1009
Full Changelog: 0.16.2...0.17.3
0.16.2
Using Bzlmod with Bazel 6
Add to your MODULE.bazel
file:
bazel_dep(name = "rules_python", version = "0.16.2")
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 = "48a838a6e1983e4884b26812b2c748a35ad284fd339eb8e2a6f3adf95307fbcd",
strip_prefix = "rules_python-0.16.2",
url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/0.16.2.tar.gz",
)
What's Changed
- fix: gazelle panics when "# gazelle:ignore" doesn't have a value by @stdll00 in #915
- Remove unused code by @groodt in #933
- Various updates build_file_generation example by @chrislovecnm in #869
- Fix CI after bazel 6.0.0 by @groodt in #938
- Refactor wheel_installer by @groodt in #937
- Updates lockfiles by @groodt in #943
- fix: embed stamped version in py_wheel METADATA by @mattoberle in #935
- chore(gazelle): clarify a particular failure message by @srabraham in #939
- pip: 22.2.1 -> 22.3.1; build: 0.8.0 -> 0.9.0; installer: 0.5.1 -> 0.6.0; pip-tools: 6.8.0 -> 6.12.1 by @groodt in #944
- Update name of
compile_pip_requirements
by @groodt in #945 - Rename
BUILD
->BUILD.bazel
by @groodt in #946 - Add missing .gitignore for //examples/pip_parse_vendored by @groodt in #947
- Removes unused "incremental" property by @groodt in #948
- Disable bytecode optimization during wheel installation by @groodt in #949
- Fix broken link. by @phst in #955
- Don’t use keyword argument for TestEnvironment. by @phst in #954
- Fix hyphen in requirement didn't work with bzlmod (#952) by @acr92 in #957
- chore(docs): fix bad html formatting by @alexeagle in #959
- Fully switch to bazel 6.0.0 in all places by @aignas in #960
- Use 'os' instead of 'ioutil' in gazelle tests by @aignas in #962
- Refactor and separate concerns of external python package handling code by @groodt in #953
New Contributors
- @stdll00 made their first contribution in #915
- @srabraham made their first contribution in #939
- @acr92 made their first contribution in #957
Full Changelog: 0.16.1...0.16.2
0.16.1
Using Bzlmod with Bazel 6
Add to your MODULE.bazel
file:
bazel_dep(name = "rules_python", version = "0.16.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 = "497ca47374f48c8b067d786b512ac10a276211810f4a580178ee9b9ad139323a",
strip_prefix = "rules_python-0.16.1",
url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/0.16.1.tar.gz",
)
What's Changed
- Fail if Python 2 values are specified by @rickeylev in #887
- fix: windows on ci by @f0rmiga in #911
- Add gazelle distribution and enable build_file_generation test by @aignas in #913
- feat: gazelle manifest exclude_patterns by @f0rmiga in #917
- Add f0rmiga as codeowner of build_file_example by @rickeylev in #918
- fix: don't test on release by @f0rmiga in #920
New Contributors
Full Changelog: 0.15.1...0.16.1