bazel-contrib / bazel-contrib/rules_python
[gazelle] Adjust how `imports` is auto-generated
- 主要言語
- Starlark
- スター
- 688
- フォーク
- 721
- 平均マージ
- 15時間 7分
- マージ済み PR(30日)
- 76
説明
Discussion moved from an internal doc and discussion with @rickeylev:
> Externally, the Bazel Python rules have an attribute named `imports`. This is a string list of repo-relative paths that should be added to `sys.path`.
@dougthor42 writes in a comment:
> FYI: With gazelle's `python_root` directive, these are autogenerated as package-relative paths, eg `["../../.."]`.
>
> Now that I see [that `imports` is repo-relative], I might submit a PR to change Gazelle to generate repo-relative paths.
@rickeylev replies:
> Hm. Is package-relative better than repo-relative? Quick thought is: they both have pros and cons.
> Which makes me think: is there something that has all pros and no cons?
> To which I think: maybe we can change the logic to more directly express what we're after.
> When src/my_package says "add .. to path", what it really means is: make sure sys.path has a directory with "my_package" as a sub directory.
> So maybe instead we add a top_level_package_name attribute? Under the hood, a quick implementation would be to just do "compute the correct imports attr value automatically". A better impl for the future would be to ensure that some directory with the desired name ends up in sys.path, however that may come to be.
>
> Thanks for the inspiration :)
コントリビューションガイド
調査の方向性
Issue では Gazelle の Python ルールと生成される `imports` 属性が示されていますが、ファイル、テスト、エントリーポイントは示されていません。まず、`imports` を生成する Gazelle のロジックと関連するテストを見つけてください。関連する `python_root` のケースについて、想定されるパスの動作について合意され、テストでカバーされれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- build-system, tooling
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 25/100