The MinT project uses tox for testing. The requirements.txt specifies a tox version. But the Dockerfile generated by blubber already installs the tox package. Since there is no virtualenvironment isolation in the docker image, both versions conflicts.
Example CI failure: https://integration.wikimedia.org/ci/job/machinetranslation-pipeline-test/280/console
Docker file from blubber .pipeline/blubber.yaml production command:
FROM docker-registry.wikimedia.org/python3-build-bullseye AS production USER 0 ENV HOME="/root" ENV DEBIAN_FRONTEND="noninteractive" RUN apt-get update && apt-get install -y "git" "build-essential" "cmake" "wget" "unzip" "wmf-certificates" "ca-certificates" && rm -rf /var/lib/apt/lists/* RUN python3 "-m" "pip" "install" "-U" "setuptools!=60.9.0" && python3 "-m" "pip" "install" "-U" "wheel" "tox" "pip" ARG LIVES_AS="somebody" ARG LIVES_UID=65533 ARG LIVES_GID=65533 RUN (getent group "$LIVES_GID" || groupadd -o -g "$LIVES_GID" -r "$LIVES_AS") && (getent passwd "$LIVES_UID" || useradd -l -o -m -d "/home/$LIVES_AS" -r -g "$LIVES_GID" -u "$LIVES_UID" "$LIVES_AS") && mkdir -p "/app" && chown "$LIVES_UID":"$LIVES_GID" "/app" && mkdir -p "/opt/lib" && chown "$LIVES_UID":"$LIVES_GID" "/opt/lib" ARG RUNS_AS="runuser" ARG RUNS_UID=900 ARG RUNS_GID=900 RUN (getent group "$RUNS_GID" || groupadd -o -g "$RUNS_GID" -r "$RUNS_AS") && (getent passwd "$RUNS_UID" || useradd -l -o -m -d "/home/$RUNS_AS" -r -g "$RUNS_GID" -u "$RUNS_UID" "$RUNS_AS") USER $LIVES_UID ENV HOME="/home/somebody" WORKDIR "/app" COPY --chown=$LIVES_UID:$LIVES_GID ["requirements.txt", "./"] ENV PIP_FIND_LINKS="file:///opt/lib/python" PIP_WHEEL_DIR="/opt/lib/python" RUN mkdir -p "/opt/lib/python" RUN python3 "-m" "pip" "wheel" "-r" "requirements.txt" && python3 "-m" "pip" "install" "--target" "/opt/lib/python/site-packages" "-r" "requirements.txt" ENV PATH="/opt/lib/python/site-packages/bin:${PATH}" PYTHONPATH="/opt/lib/python/site-packages" COPY --chown=$LIVES_UID:$LIVES_GID [".", "."] ENV PIP_NO_INDEX="1" ENTRYPOINT ["/app/entrypoint.sh"] LABEL blubber.variant="production" blubber.version="0.9.0+2638669"
As you can see in line 6 tox is installed. virtualenv is a dependency to it, so that also get installed. Later when the actual tox runs for tests, we get the following error:
AttributeError: module 'virtualenv.create.via_global_ref.builtin.cpython.mac_os' has no attribute 'CPython3macOsBrew'
As per this question at stackoverlow, the error is due to two virtualenv packages
Is there way we can force virtual environment for the application instead of using the system environment? I saw a mention of that in T346090: Blubber: Add workaround for Bookworm's Python pip restrictions