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

Abierto Apto para principiantes
#2,042 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
84/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
python
Área
build-system

Línea de trabajo

Empieza en hatch_build.py y lee CFfiBuildHook._build_flatc, centrándote en las llamadas a subprocess de readelf y file. Prueba la compilación en un entorno Debian 13 sin file ni binutils y repítela después con ambas herramientas instaladas. Se considerará terminado cuando la compilación se complete correctamente sin ninguna de las dos herramientas de diagnóstico e imprima las líneas de diagnóstico cuando ambas estén disponibles.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Python
Estrellas
2.5k
Forks
766
Merge medio
4 h 24 min
PR fusionados (30 d)
20

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de crossbario/autobahn-python

Todos los issues de crossbario/autobahn-python

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.