Environment-consistent builds

When building/installing Python dependencies in Docker/CI for multiple Python versions, keep the environment deterministic and aligned across interpreters: use the same dependency constraint/lock inputs everywhere and ensure the packaging toolchain is consistent per interpreter.

copy reviewer prompt

Prompt

Reviewer Prompt

When building/installing Python dependencies in Docker/CI for multiple Python versions, keep the environment deterministic and aligned across interpreters: use the same dependency constraint/lock inputs everywhere and ensure the packaging toolchain is consistent per interpreter.

Apply this by:

  • Always pass the shared constraints/lock file to pip installs (for every supported Python/PyPy build).
  • Before installing requirements, upgrade pip, setuptools, and wheel using the target interpreter.
  • Keep configuration formatting consistent (e.g., Docker ENV KEY=VALUE style) to avoid lint/tooling drift.

Example (adapted):

RUN pyenv exec python3.11 -m pip install --upgrade pip setuptools wheel \
 && --mount=type=cache,target=/home/$CELERY_USER/.cache/pip \
    pyenv exec python3.11 -m pip install -r requirements/test.txt \
      --build-constraint requirements/constraints.txt

# Prefer consistent ENV syntax
ENV PYTHONUNBUFFERED=1
ENV PYTHONIOENCODING=UTF-8

Source discussions