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

Đang mở Phù hợp với người mới
#2,042 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
84/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
build-system

Hướng nghiên cứu

Bắt đầu trong hatch_build.py và đọc CFfiBuildHook._build_flatc, tập trung vào các lệnh gọi subprocess của readelf và file. Thử build trong môi trường Debian 13 không có file hoặc binutils, sau đó thử lại khi đã cài đặt cả hai công cụ. Hoàn tất khi build thành công mà không cần một trong hai công cụ chẩn đoán và in các dòng chẩn đoán khi cả hai đều khả dụng.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Python
Star
2.5k
Fork
766
Merge trung bình
4 giờ 24 phút
Pull request đã merge (30 ngày)
20

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của crossbario/autobahn-python

Tất cả issue của crossbario/autobahn-python

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.