Library recipes: run a recipe's steps with a minimal environment, not the build container's

Abierto
#48 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
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
52/100
Tipo de issue
Refactorización
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
github-actions, python

Línea de trabajo

Start with build_env() and the subprocess.run call in build_libraries() in scripts/gap_wheels.py, then check scripts/container_build.sh for the image's PATH. Add a library_env(prefix) for recipe steps only, and leave Windows on the old path with a comment. Done when tests/test_gap_wheels.py shows that CFLAGS, MAKEFLAGS and LD_LIBRARY_PATH set in the test's os.environ never reach a recipe step, and the PyYAML pair still builds to the same sha256.

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

Descripción

enhancement help wanted

A recipe's build steps are fixed argument lists, so that nothing outside the reviewed recipe decides how the library is built. But each step runs with the whole environment of the process that started it:

# scripts/gap_wheels.py
def build_env() -> dict[str, str]:
    env = dict(os.environ, PIP_DISABLE_PIP_VERSION_CHECK="1", PIP_NO_INPUT="1", SOURCE_DATE_EPOCH="1700000000",
               PYTHONHASHSEED="0")
...
# build_libraries()
done = subprocess.run(argv, cwd=src, check=False, env=build_env(), ...)

./configure and make read a lot from the environment: CC, CFLAGS, LDFLAGS, CPPFLAGS, MAKEFLAGS, PKG_CONFIG_PATH, LD_LIBRARY_PATH, LANG, TZ, HOME, USER. Whatever the image, the runner or the workflow sets for any of them goes into the library, and none of it is in the recipe's sha256 (digest() in scripts/library_recipes.py covers the recipe's own fields only). An image update that starts exporting CFLAGS=-g, or a workflow edit that sets MAKEFLAGS, changes the library while the recorded recipe digest stays the same. The two builds of a pair would still match each other, so nothing would notice.

The README promises more than that: "built with the recipe's steps, which are argument lists in this repo (no shell, nothing from the package or from a workflow input)".

Where

scripts/gap_wheels.py: build_env() and the subprocess.run in build_libraries(). The package's own build (run_build()) is a different question and out of scope here.

What to do

  • Add library_env(prefix) and use it for recipe steps only. Start from an empty dict and set a short fixed list:
    • PATH: on Linux the image's standard one, written out (/usr/local/bin:/usr/bin:/bin, plus the manylinux toolchain's folder if the image's compiler lives outside those; check scripts/container_build.sh and the image);
    • HOME and TMPDIR: folders under the build's work folder;
    • LANG=C.UTF-8, LC_ALL=C.UTF-8, TZ=UTC;
    • SOURCE_DATE_EPOCH, as build_env() sets it.
  • On Windows nothing has a recipe yet. MSVC needs its own variables (INCLUDE, LIB, Path from the developer environment), so for now keep build_env() there and say so in a comment, or pass through a named allowlist. Don't break the Windows path for a future recipe.
  • Record the environment's variable names and values in the recipe record or the build's tool provenance, so a change to the list is a visible change. If that touches RECORD_KEYS or the manifest's shape, describe it in the PR first: verification compares these records between builds.
  • A recipe that needs a variable sets it in its own step arguments (CFLAGS=-O2 -fPIC is already an argument to ./configure in the libyaml recipe), which is inside the digest.

Done when:

  • A test in tests/test_gap_wheels.py runs build_libraries() with a recipe whose one step prints its environment to a file under the prefix (the existing build_libraries() tests, around gap_wheels.build_libraries([recipe], tmp / "work", tmp / "root"), show how to give it a small recipe), with CFLAGS, MAKEFLAGS and LD_LIBRARY_PATH set in the test's own os.environ, and shows none of them reach the step.
  • A test pins the exact set of variable names a Linux step gets.
  • The PyYAML pair still builds twice to the same sha256 with the change: the PR links two gap-wheel-build.yml runs from your fork.
  • The README's "In the build" paragraph says the steps get a fixed environment.
  • uvx --python 3.14 [email protected] passes, offline.
Lenguaje dominante
Python
Estrellas
0
Forks
1
Merge medio
5 h 59 min
PR fusionados (30 d)
19

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

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 wheelgap/wheels

Todos los issues de wheelgap/wheels

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.