bazel-contrib / bazel-contrib/rules_python
Custom platform from `pip.default` can't be used by consumers
- 主要语言
- Starlark
- 星标
- 688
- 派生
- 721
- 平均合并
- 15 小时 7 分钟
- 30 天内合并 PR
- 76
描述
# 🐞 bug report
## Affected Rule
The issue is caused by the bzlmod module extension pip in the pip.default / pip.parse tag handling in:
- python/private/pypi/extension.bzl (`build_config()`)
- python/private/pypi/parse_requirements.bzl (MacOS, `_package_srcs()`)
- python/private/pypi/hub_builder.bzl (Ubuntu, `_evaluate_markers()`)
### Is this a regression?
No.
### Description
When pip.default() is called from a non-root Bazel module (a dependency module), it is ignored while building the pip extension config. At the same time, pip.parse() in that dependency module is still processed and can create a hub repo that the consumer can use transitively.
This makes it impossible (or very confusing) for a dependency module to ship a reusable pip.parse() hub that relies on custom platforms defined by that same module’s pip.default().
#### Expected behavior
pip.default() platform definitions from a dependency module are applied at least for that module’s own pip.parse() tags.
#### Actual behavior
- pip.default() from dependency modules is ignored.
- pip.parse() from dependency modules is processed.
- If pip.parse() needs a custom platform, evaluation will fail with an error.
- Workaround today: the root module must re-declare the same platforms in its own pip.default().
## 🔬 Minimal Reproduction
Reproduction repository:
## 🔥 Exception or Error
- MacOS: `The target platform 'cp312.12_plat_a' could not be found in ["cp312.12_linux_x86_64", "cp312.12_linux_aarch64", "cp312.12_osx_aarch64", "cp312.12_osx_x86_64", "cp312.12_windows_x86_64", "cp312.12_windows_aarch64"]`
- Linux: `Error: key "cp312.12_plat_a" not found in dictionary`
## 🌍 Your Environment
### Operating System
```text
MacOS 26.1, Ubuntu 24.04
```
### Output of `bazel version`
```text
7.5.0
```
### Rules_python version
```text
1.7.0
```
### Anything else relevant
None.
## References
None.
贡献指南
调研方向
从 python/private/pypi/extension.bzl 及其对 build_config() 的处理开始,然后跟踪 parse_requirements.bzl(MacOS 的 _package_srcs())和 hub_builder.bzl(Ubuntu 的 _evaluate_markers())中的相关逻辑。使用链接的最小复现来验证,依赖模块的 pip.default() 平台会应用于其 pip.parse() hub,而不要求根模块重新声明这些平台。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- build-system
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100