bazel-contrib / bazel-contrib/rules_python

`py_binary` targets added to `py_wheel.deps` end up including the binary in the wheel. Sounds like WAI but it was surprising to me

Đang mở
#2,923 9 bình luận 0 reaction 0 người được giao Xem trên GitHub
Good first issue packaging
Ngôn ngữ chính
Starlark
Star
688
Fork
721
Merge trung bình
15 giờ 7 phút
Pull request đã merge (30 ngày)
76

Mô tả

# 🐞 bug report

### Affected Rule

+ `py_wheel`

### Is this a regression?

Nope, not that I can tell at least.

### Description

Adding a `py_binary` target as a dep to `py_wheel` results in both the binary's `srcs` being added to the wheel _and the binary itself_. It's this latter part that is unexpected (at least to me, haha).

Maybe I'm missing an option that causes the bazel binaries to be excluded?

## 🔬 Minimal Reproduction

```starlark
py_binary(
name = "foo",
srcs = ["foo.py"],
)

py_wheel(
...,
distribution = "our_tables",
deps = [":foo"],
)
```

```shell
$ less bazel-bin/path/to/foo/foo-0.0.1-py3-none-any.whl | cat
Metadata-Version: 2.1
Name: our_tables
Version: 0.0.1

Archive: bazel-bin/path/to/foo/our_tables-0.0.1-py3-none-any.whl
Length Method Size Cmpr Date Time CRC-32 Name
-------- ------ ------- ---- ---------- ----- -------- ----
24451 Defl:N 7964 67% 1980-01-01 00:00 2d00cf53 our_tables/foo
5124 Defl:N 1787 65% 1980-01-01 00:00 4846e197 our_tables/foo.py
91 Defl:N 86 6% 1980-01-01 00:00 4f1122ec our_tables-0.0.3.dist-info/WHEEL
9031 Defl:N 3390 63% 1980-01-01 00:00 e00f51c6 our_tables-0.0.3.dist-info/METADATA
698 Defl:N 445 36% 1980-01-01 00:00 8c16618f our_tables-0.0.3.dist-info/RECORD
-------- ------- --- -------
47408 16577 65% 5 files
```

It's that `our_tables/foo` that's strange to me. IMO it should not be included by default.

## 🔥 Exception or Error

N/A

## 🌍 Your Environment

**Operating System:**

gLinux

**Output of `bazel version`:**

```
$ bazel version
Bazelisk version: v1.20.0
Build label: 7.6.1
Build target: @@//src/main/java/com/google/devtools/build/lib/bazel:BazelServer
Build time: Mon Mar 31 17:08:56 2025 (1743440936)
Build timestamp: 1743440936
Build timestamp as int: 1743440936
```

**Rules_python version:**

```
1.4.1
```

**Anything else relevant?**

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu bằng cách chạy bản tái hiện Bazel tối thiểu với `py_binary` và `py_wheel`, sau đó kiểm tra danh sách wheel được tạo cho binary và mã nguồn của nó. Đọc cách `py_wheel` xử lý dependency và so sánh hành vi quan sát được với ngữ nghĩa dự kiến; được xem là hoàn thành khi một hành vi đã thống nhất được ghi lại bằng một regression test hoặc một tùy chọn được tài liệu hóa.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python
Lĩnh vực
build-system
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
45/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.