hatch_build.py: the package cannot be built where `file(1)` is not installed

オープン 初心者向け
#2,042 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
84/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
build-system

調査の方向性

hatch_build.pyから始めてCFfiBuildHook._build_flatcを読み、readelfとfileを呼び出すsubprocessに注目してください。fileもbinutilsもないDebian 13環境でビルドを試し、その後、両方のツールをインストールした状態でもう一度試してください。どちらの診断ツールもなくてもビルドが成功し、両方が利用可能な場合は診断行が出力されれば完了です。

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

説明

What happens

On a Debian 13 host without the file package, every install or build of autobahn
from source fails: pip install -e ., uv pip install, and just install,
install-tools, install-docs, install-build-tools, build. At master 7d6978d,
CPython 3.11 to 3.14 and PyPy 3.11 all fail the same way:

FileNotFoundError: [Errno 2] No such file or directory: 'file'
...
error: metadata-generation-failed

flatc builds successfully first; the build fails only after that.

Why

CFfiBuildHook._build_flatc prints diagnostics about the built flatc, and finishes
with:

file_result = subprocess.run(
    ["file", str(flatc_dest)],
    capture_output=True,
    text=True,
)
if file_result.returncode == 0:
    print(f"     {file_result.stdout.strip()}")

The code checks the return code, but subprocess.run raises before returning one
when the executable itself is missing. The output is only diagnostic, yet a missing
diagnostic tool fails the whole build. GitHub's runners have file, so CI never hits
this. Minimal containers and build hosts often lack it.

Fix

Catch FileNotFoundError around this call and skip the line, and do the same for the
readelf call just above it, which has the same shape. Alternatively, look the tool
up with shutil.which() first.

Acceptance

  • In a debian:trixie container without file (and without binutils), pip install . builds and installs autobahn.
  • Where both tools are present, the diagnostic lines are printed as before.

Found by running the GH CI steps on a local build node.

主要言語
Python
スター
2.5k
フォーク
766
平均マージ
3時間 25分
マージ済み PR(30日)
19

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

crossbario/autobahn-python のほかの issue

crossbario/autobahn-python の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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