bazel-contrib / bazel-contrib/rules_python

importlib.metadata.files() doesn't work because RECORD is missing

オープン
#3,024 コメント 9 件 リアクション 0 件 担当者 0 名 GitHub で見る
type: bug type: pip
主要言語
Starlark
スター
688
フォーク
721
平均マージ
15時間 7分
マージ済み PR(30日)
76

説明

It appears that `importlib.metadata.files()` is broken with the pypi integration because the RECORD file gets ommited.

Per docs at https://docs.python.org/3/library/importlib.metadata.html#distribution-files

> In the case where the metadata file listing files (RECORD or SOURCES.txt) is missing, files() will return

This came to my attention via @mering trying to use the rtree package, which tries to use its distribution metadata to find some C libraries to load.

Excluding RECORD seems somewhat intentional, though? The code has this comment:

https://github.com/bazel-contrib/rules_python/blob/main/python/private/pypi/whl_library_targets.bzl#L315-L318

> RECORD is known to contain sha256 checksums of files which might include the checksums
> of generated files produced when wheels are installed. The file is ignored to avoid
> Bazel caching issues.

What's the caching issue, exactly? For a downloaded whl, what generated files is it referring to? If a whl is built at repo time from an sdist, then files shouldn't be changing, and the hash should be stable, so how does a cache issue come up?

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

python/private/pypi/whl_library_targets.bzl の 315~318 行付近にある RECORD の省略に関するコメントから始め、importlib.metadata.files() のドキュメントおよびここで説明されている rtree のユースケースと比較してください。キャッシュに関する懸念点と、files() が機能するように PyPI 統合で RECORD を保持すべきかどうかを判断してください。動作と解決策が文書化されるか、検証付きで実装されれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
build-system
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
静か
明瞭さ
説明が足りない
初心者へのやさしさ
42/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。