Skip to content

Commit 6432149

Browse files
committed
Merge branch 'main' of https://github.com/bazelbuild/rules_python into refactor.attr.builders
2 parents 73c0a55 + effdce8 commit 6432149

File tree

24 files changed

+271
-174
lines changed

24 files changed

+271
-174
lines changed

CHANGELOG.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,13 @@ Unreleased changes template.
5252

5353
{#v0-0-0-changed}
5454
### Changed
55-
* Nothing changed.
55+
* (deps) platforms 0.0.4 -> 0.0.11
5656

5757
{#v0-0-0-fixed}
5858
### Fixed
59-
* Nothing fixed.
59+
* (pypi) The `ppc64le` is now pointing to the right target in the `platforms` package.
60+
* (gazelle) No longer incorrectly merge `py_binary` targets during partial updates in
61+
`file` generation mode. Fixed in [#2619](https://github.com/bazelbuild/rules_python/pull/2619).
6062

6163
{#v0-0-0-added}
6264
### Added

MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module(
77
bazel_dep(name = "bazel_features", version = "1.21.0")
88
bazel_dep(name = "bazel_skylib", version = "1.7.1")
99
bazel_dep(name = "rules_cc", version = "0.0.16")
10-
bazel_dep(name = "platforms", version = "0.0.4")
10+
bazel_dep(name = "platforms", version = "0.0.11")
1111

1212
# Those are loaded only when using py_proto_library
1313
# Use py_proto_library directly from protobuf repository

gazelle/manifest/defs.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ AllSourcesInfo = provider(fields = {"all_srcs": "All sources collected from the
161161
_rules_python_workspace = Label("@rules_python//:WORKSPACE")
162162

163163
def _get_all_sources_impl(target, ctx):
164-
is_rules_python = target.label.workspace_name == _rules_python_workspace.workspace_name
164+
is_rules_python = target.label.repo_name == _rules_python_workspace.repo_name
165165
if not is_rules_python:
166166
# Avoid adding third-party dependency files to the checksum of the srcs.
167167
return AllSourcesInfo(all_srcs = depset())

gazelle/python/kinds.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ func (*Python) Kinds() map[string]rule.KindInfo {
3232

3333
var pyKinds = map[string]rule.KindInfo{
3434
pyBinaryKind: {
35-
MatchAny: true,
35+
MatchAny: false,
36+
MatchAttrs: []string{"srcs"},
3637
NonEmptyAttrs: map[string]bool{
3738
"deps": true,
3839
"main": true,
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
load("@rules_python//python:defs.bzl", "py_binary")
2+
3+
# gazelle:python_generation_mode file
4+
5+
py_binary(
6+
name = "a",
7+
srcs = ["a.py"],
8+
visibility = ["//:__subpackages__"],
9+
)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
load("@rules_python//python:defs.bzl", "py_binary")
2+
3+
# gazelle:python_generation_mode file
4+
5+
py_binary(
6+
name = "a",
7+
srcs = ["a.py"],
8+
visibility = ["//:__subpackages__"],
9+
)
10+
11+
py_binary(
12+
name = "b",
13+
srcs = ["b.py"],
14+
visibility = ["//:__subpackages__"],
15+
)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Partial update with multiple per-file binaries
2+
3+
This test case asserts that when there are multiple binaries in a package, and no __main__.py, and the BUILD file already includes a py_binary for one of the files, a py_binary is generated for the other file.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# This is a Bazel workspace for the Gazelle test data.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
if __name__ == "__main__":
2+
print("Hello, world!")
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
if __name__ == "__main__":
2+
print("Hello, world!")

0 commit comments

Comments
 (0)