Improve import error when extension module is an incompatible build
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 35.9k
- PR マージ指標
- PR 指標を取得中
説明
Feature or enhancement
Proposal:
Relatively regularly we get issues e.g. in NumPy because of incompatible extension module builds. (NumPy is often the first C-extension module someone loads.)
We have a long spammy message, but it includes the original error from Python:
Original error was: No module named 'numpy._core._multiarray_umath'
In this case, I had renamed the module to make it an incorrect build:
mv <snip>/lib/python3.11/site-packages/numpy/_core/_multiarray_umath.cpython-311-darwin.so <snip>/lib/python3.11/site-packages/numpy/_core/_multiarray_umath.cpython-312-darwin.so
I think it would be great if the error could include something like:
Binary module was build for a different Python version/system: Python version is cpython-312 rather than cpython-311) or (architecture x86 but expected arm64)
That way it is far more obvious that the build (or Python version) is wrong.
(Even just listing the files found and the expected file name would be good.)
I am not sure that is desirable for Python, since you would have to see if any file looks similar to the expected module when formatting the error. So in that case I may think about doing this in NumPy (since we know for a fact the file must be there somewhere).
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
I didn't find a discussion, this seems very slightly in a similar direction, but not about an incompatible build https://github.com/python/cpython/issues/69841.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
この issue にはソースファイル、テスト、エントリーポイントが記載されていません。まず、その診断が Python の拡張モジュールのインポート処理に属するのか、NumPy に属するのかを判断し、次に互換性のないファイル名やアーキテクチャをどのように識別するかを定義してください。互換性のない拡張モジュールが、関連する期待された build の詳細と検出された build の詳細を示す、簡潔で対応可能なメッセージを生成すれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- backend
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100