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

Open Beginner friendly
#2,042 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
84/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
build-system

Research direction

Start in hatch_build.py and read CFfiBuildHook._build_flatc, focusing on the readelf and file subprocess calls. Try the build in a Debian 13 environment without file or binutils, then repeat with both tools installed. Done when the build succeeds without either diagnostic tool and prints the diagnostic lines when both are available.

Written by the indexing model from the issue text.

Description

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.

Dominant language
Python
Stars
2.5k
Forks
766
Avg merge
4h 24m
Merged PRs (30d)
20

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from crossbario/autobahn-python

All issues in crossbario/autobahn-python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.