bazel-contrib / bazel-contrib/rules_python
Thirdparty pip dependencies override root project's pip dependencies
- 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
```
use_extension("@rules_python//python/extensions:pip.bzl", "pip")
```
### Is this a regression?
Between old `WORKSPACE` rules and `bzlmod`, potentially yes - so long as you knew the order you were defining dependencies.
### Description
A third party project called foo uses `rules_python` and `bzlmod` to bring in pip dependencies:
```
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
pip.parse(
hub_name = "foo_pip_deps",
python_version = "3.11",
requirements_lock = "@foo//:requirements_lock.txt",
)
use_repo(pip, "foo_pip_deps")
```
This dependency is implicitly used as part of a library this third party defines. This `requirements_lock.txt` uses a pip module `matplotlib` at v1.
```
load("@foo_pip_deps//:requirements.bzl", "requirement")
py_library(
name = "foo",
srcs = ["foo.py"],
imports = ["."],
visibility = ["//visibility:public"],
deps = [requirement("matplotlib")], #v1
)
```
My root project uses the pip extension and its own `requirements_lock.txt` file to bring in `matplotlib` at v2.
If I depend on the `@foo` project:
```
load("@bar_pip_deps//:requirements.bzl", "requirement")
py_binary(
name = "main",
srcs = ["main.py"],
deps = [
"@foo",
requirement("matplotlib"), #v2
],
)
```
The target will now use `matplotlib` at v1. Even though my root project specifically asks for v2.
## 🔬 Minimal Reproduction
[Follow the examples in here](https://github.com/finn-ball/python_bzlmod_test)
## 🔥 Exception or Error
## 🌍 Your Environment
**Operating System:**
linux
**Output of `bazel version`:**
7.0.2
**Rules_python version:**
0.31.0
**Anything else relevant?**
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu bằng cách tái hiện hành vi phân giải dependency bằng reproduction tối thiểu được liên kết và cấu hình extension pip được hiển thị. Theo dõi cách các tệp requirements_lock.txt của project root và bên thứ ba được kết hợp, sau đó xác minh rằng matplotlib v2 của project root được chọn khi target root phụ thuộc vào @foo. Hoàn tất khi reproduction phân giải dependency root như mô tả.
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ó
- 4/5
- Thời gian dự kiến
- 3-5 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
- 40/100