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:

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