bazel-contrib / bazel-contrib/rules_python

gazelle_python.yaml can only use one pip_repository

未關閉
#1,971 3 則留言 3 個 reaction 已指派 0 人 在 GitHub 檢視
gazelle help wanted type: feature request
主要語言
Starlark
星號
688
分支
721
平均合併
15 小時 7 分鐘
30 天內合併 PR
76

描述

The `modules_mapping` rule accepts a list of wheels, but then the [manifest generator](https://github.com/bazelbuild/rules_python/blob/7a437cc94ff722d8c088ab6140b0cd940d28c4d7/gazelle/manifest/manifest.go#L150) assumes that all those modules come from a single `pip.parse` call.

Since many Python projects separate dependencies, i.e. https://pip-tools.readthedocs.io/en/stable/#workflow-for-layered-requirements
it's often the case that some users have different requirements repositories, even for the same folder.

For example, in https://github.com/alexeagle/bazel_python_repro/blob/18f4504adcdef9187f68397ea20a4f6672badcc2/app/BUILD.bazel gazelle has generated line 28 as `@pip//python_dotenv`. However that wheel came from [test.in](https://github.com/alexeagle/bazel_python_repro/blob/18f4504adcdef9187f68397ea20a4f6672badcc2/requirements/test.in#L4) installed at [pip.test](https://github.com/alexeagle/bazel_python_repro/blob/18f4504adcdef9187f68397ea20a4f6672badcc2/MODULE.bazel#L28) - so it should have generated `@pip.test//python_dotenv`.
Of course since the wheels were combined in the [modules_mapping]( https://github.com/alexeagle/bazel_python_repro/blob/18f4504adcdef9187f68397ea20a4f6672badcc2/BUILD.bazel#L31) this information is lost and the `gazelle_python.yaml` can't indicate which repo should be used for a given import (no matter what folder the gazelle_python.yaml were to appear in)

貢獻指南

開啟貢獻指南

研究方向

從 modules_mapping 規則和 gazelle/manifest/manifest.go 中的 manifest 產生器開始,重點關注 wheel 來源如何與產生的標籤建立關聯。使用分層 requirements 範例追蹤遺失的 repository 資訊;當來自不同 pip repository 的匯入產生例如 @pip.test//python_dotenv 的標籤,而不是一律使用 @pip// 時,即表示完成。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
build-system
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
38/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。