From 9c1021ee37125f09d26b1ea9818eae7099d7c75c Mon Sep 17 00:00:00 2001 From: Egor Tiuvaev Date: Mon, 11 Nov 2024 16:30:25 +0100 Subject: [PATCH 1/2] fix ubuntu20 for python39 --- templates/ubuntu20/common/base.dockerfile.j2 | 10 +++++++--- .../{python38.dockerfile.j2 => python39.dockerfile.j2} | 2 +- utils/arg_parser.py | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) rename templates/ubuntu20/python/{python38.dockerfile.j2 => python39.dockerfile.j2} (71%) diff --git a/templates/ubuntu20/common/base.dockerfile.j2 b/templates/ubuntu20/common/base.dockerfile.j2 index d6308672..d1ca1c4c 100644 --- a/templates/ubuntu20/common/base.dockerfile.j2 +++ b/templates/ubuntu20/common/base.dockerfile.j2 @@ -35,7 +35,7 @@ SHELL ["/bin/bash", "-xo", "pipefail", "-c"] RUN apt-get update; \ apt-get install -y --no-install-recommends \ git \ - python3-dev \ + python3.9-dev \ python3-pip \ build-essential \ cmake \ @@ -192,12 +192,16 @@ ARG INSTALL_PACKAGES="-c=python -c=core" {% elif 'dev' == distribution or 'dev_no_samples' == distribution %} ARG LGPL_DEPS="g++ \ gcc \ - libc6-dev" + libc6-dev \ + python3.9-venv \ + python3-pip" ARG INSTALL_PACKAGES="-c=python -c=core -c=dev" {% else %} ARG LGPL_DEPS="g++ \ gcc \ - libc6-dev" + libc6-dev \ + python3.9-venv \ + python3-pip" ARG INSTALL_PACKAGES="-c=python" {% endif %} diff --git a/templates/ubuntu20/python/python38.dockerfile.j2 b/templates/ubuntu20/python/python39.dockerfile.j2 similarity index 71% rename from templates/ubuntu20/python/python38.dockerfile.j2 rename to templates/ubuntu20/python/python39.dockerfile.j2 index 74c59635..b2473807 100644 --- a/templates/ubuntu20/python/python38.dockerfile.j2 +++ b/templates/ubuntu20/python/python39.dockerfile.j2 @@ -1,4 +1,4 @@ # setup Python -ENV PYTHON_VER python3.8 +ENV PYTHON_VER python3.9 RUN ${PYTHON_VER} -m pip install --upgrade pip \ No newline at end of file diff --git a/utils/arg_parser.py b/utils/arg_parser.py index 4566e11a..b752abdb 100644 --- a/utils/arg_parser.py +++ b/utils/arg_parser.py @@ -519,7 +519,7 @@ def parse_args(name: str, description: str): # noqa if args.os in "ubuntu22": args.python = "python310" else: - args.python = "python38" + args.python = "python39" if args.python == "python38" and "win" in args.os: if not hasattr(args, "pre_stage_msbuild") or not args.pre_stage_msbuild: From 26d00c8ed541d9a86c3b43745534dc19c287a39f Mon Sep 17 00:00:00 2001 From: Egor Tiuvaev Date: Tue, 12 Nov 2024 10:39:54 +0100 Subject: [PATCH 2/2] Add venv to ubuntu20 to mitigate python version mixup --- templates/ubuntu20/common/base.dockerfile.j2 | 2 +- templates/ubuntu20/dist/dev.dockerfile.j2 | 18 +++++++++--------- .../ubuntu20/dist/dev_no_samples.dockerfile.j2 | 10 +++++----- templates/ubuntu20/dist/runtime.dockerfile.j2 | 2 +- .../ubuntu20/python/python39.dockerfile.j2 | 7 ++++--- 5 files changed, 20 insertions(+), 19 deletions(-) diff --git a/templates/ubuntu20/common/base.dockerfile.j2 b/templates/ubuntu20/common/base.dockerfile.j2 index d1ca1c4c..79d5ebb9 100644 --- a/templates/ubuntu20/common/base.dockerfile.j2 +++ b/templates/ubuntu20/common/base.dockerfile.j2 @@ -187,7 +187,7 @@ ARG INSTALL_SOURCES="no" ARG DEPS="tzdata \ curl" {% if 'runtime' == distribution %} -ARG LGPL_DEPS="" +ARG LGPL_DEPS="python3.9-venv python3-pip" ARG INSTALL_PACKAGES="-c=python -c=core" {% elif 'dev' == distribution or 'dev_no_samples' == distribution %} ARG LGPL_DEPS="g++ \ diff --git a/templates/ubuntu20/dist/dev.dockerfile.j2 b/templates/ubuntu20/dist/dev.dockerfile.j2 index 5a5e5d72..fa8c9834 100644 --- a/templates/ubuntu20/dist/dev.dockerfile.j2 +++ b/templates/ubuntu20/dist/dev.dockerfile.j2 @@ -5,15 +5,15 @@ ARG OPENVINO_WHEELS_URL # hadolint ignore=SC2102 RUN apt-get update && apt-get install -y --no-install-recommends cmake make git && rm -rf /var/lib/apt/lists/* && \ if [ -z "$OPENVINO_WHEELS_URL" ]; then \ - ${PYTHON_VER} -m pip install --no-cache-dir openvino=="${OPENVINO_WHEELS_VERSION}" && \ - ${PYTHON_VER} -m pip install --no-cache-dir openvino-tokenizers=="${OPENVINO_WHEELS_VERSION}" && \ - ${PYTHON_VER} -m pip install --no-cache-dir openvino-genai=="${OPENVINO_WHEELS_VERSION}" && \ - ${PYTHON_VER} -m pip install --no-cache-dir openvino_dev[caffe,kaldi,mxnet,onnx,pytorch,tensorflow2]=="${OPENVINO_WHEELS_VERSION}" --extra-index-url https://download.pytorch.org/whl/cpu; \ + python3 -m pip install --no-cache-dir openvino=="${OPENVINO_WHEELS_VERSION}" && \ + python3 -m pip install --no-cache-dir openvino-tokenizers=="${OPENVINO_WHEELS_VERSION}" && \ + python3 -m pip install --no-cache-dir openvino-genai=="${OPENVINO_WHEELS_VERSION}" && \ + python3 -m pip install --no-cache-dir openvino_dev[caffe,kaldi,mxnet,onnx,pytorch,tensorflow2]=="${OPENVINO_WHEELS_VERSION}" --extra-index-url https://download.pytorch.org/whl/cpu; \ else \ - ${PYTHON_VER} -m pip install --no-cache-dir --pre openvino=="${OPENVINO_WHEELS_VERSION}" --trusted-host=* --find-links "$OPENVINO_WHEELS_URL" && \ - ${PYTHON_VER} -m pip install --no-cache-dir --pre openvino-tokenizers=="${OPENVINO_WHEELS_VERSION}" --trusted-host=* --find-links "$OPENVINO_WHEELS_URL" && \ - ${PYTHON_VER} -m pip install --no-cache-dir --pre openvino-genai=="${OPENVINO_WHEELS_VERSION}" --trusted-host=* --find-links "$OPENVINO_WHEELS_URL" && \ - ${PYTHON_VER} -m pip install --no-cache-dir --pre openvino_dev[caffe,kaldi,mxnet,onnx,pytorch,tensorflow2]=="${OPENVINO_WHEELS_VERSION}" --trusted-host=* --find-links "$OPENVINO_WHEELS_URL" --extra-index-url https://download.pytorch.org/whl/cpu; \ + python3 -m pip install --no-cache-dir --pre openvino=="${OPENVINO_WHEELS_VERSION}" --trusted-host=* --find-links "$OPENVINO_WHEELS_URL" && \ + python3 -m pip install --no-cache-dir --pre openvino-tokenizers=="${OPENVINO_WHEELS_VERSION}" --trusted-host=* --find-links "$OPENVINO_WHEELS_URL" && \ + python3 -m pip install --no-cache-dir --pre openvino-genai=="${OPENVINO_WHEELS_VERSION}" --trusted-host=* --find-links "$OPENVINO_WHEELS_URL" && \ + python3 -m pip install --no-cache-dir --pre openvino_dev[caffe,kaldi,mxnet,onnx,pytorch,tensorflow2]=="${OPENVINO_WHEELS_VERSION}" --trusted-host=* --find-links "$OPENVINO_WHEELS_URL" --extra-index-url https://download.pytorch.org/whl/cpu; \ fi WORKDIR ${INTEL_OPENVINO_DIR}/licensing @@ -37,6 +37,6 @@ RUN ./build_samples.sh -b /tmp/build -i ${INTEL_OPENVINO_DIR}/samples/cpp/sample # hadolint ignore=DL3013 RUN git clone https://github.com/openvinotoolkit/open_model_zoo && \ sed -i '/opencv-python/d' open_model_zoo/demos/common/python/requirements.txt && \ - pip3 --no-cache-dir install open_model_zoo/demos/common/python/ && \ + python3 -m pip --no-cache-dir install open_model_zoo/demos/common/python/ && \ rm -Rf open_model_zoo && \ python3 -c "from model_zoo import model_api" diff --git a/templates/ubuntu20/dist/dev_no_samples.dockerfile.j2 b/templates/ubuntu20/dist/dev_no_samples.dockerfile.j2 index 2dcd3f4b..37cdb8bb 100644 --- a/templates/ubuntu20/dist/dev_no_samples.dockerfile.j2 +++ b/templates/ubuntu20/dist/dev_no_samples.dockerfile.j2 @@ -3,13 +3,13 @@ WORKDIR ${INTEL_OPENVINO_DIR} ARG OPENVINO_WHEELS_VERSION={{ product_version }} ARG OPENVINO_WHEELS_URL # hadolint ignore=SC2102 -RUN ${PYTHON_VER} -m pip install --no-cache-dir cmake && \ +RUN python3 -m pip install --no-cache-dir cmake && \ if [ -z "$OPENVINO_WHEELS_URL" ]; then \ - ${PYTHON_VER} -m pip install --no-cache-dir openvino=="$OPENVINO_WHEELS_VERSION" && \ - ${PYTHON_VER} -m pip install --no-cache-dir openvino_dev[caffe,kaldi,mxnet,onnx,pytorch,tensorflow2]=="$OPENVINO_WHEELS_VERSION" ; \ + python3 -m pip install --no-cache-dir openvino=="$OPENVINO_WHEELS_VERSION" && \ + python3 -m pip install --no-cache-dir openvino_dev[caffe,kaldi,mxnet,onnx,pytorch,tensorflow2]=="$OPENVINO_WHEELS_VERSION" ; \ else \ - ${PYTHON_VER} -m pip install --no-cache-dir --pre openvino=="$OPENVINO_WHEELS_VERSION" --trusted-host=* --find-links "$OPENVINO_WHEELS_URL" && \ - ${PYTHON_VER} -m pip install --no-cache-dir --pre openvino_dev[caffe,kaldi,mxnet,onnx,pytorch,tensorflow2]=="$OPENVINO_WHEELS_VERSION" --trusted-host=* --find-links "$OPENVINO_WHEELS_URL" ; \ + python3 -m pip install --no-cache-dir --pre openvino=="$OPENVINO_WHEELS_VERSION" --trusted-host=* --find-links "$OPENVINO_WHEELS_URL" && \ + python3 -m pip install --no-cache-dir --pre openvino_dev[caffe,kaldi,mxnet,onnx,pytorch,tensorflow2]=="$OPENVINO_WHEELS_VERSION" --trusted-host=* --find-links "$OPENVINO_WHEELS_URL" ; \ fi WORKDIR ${INTEL_OPENVINO_DIR}/licensing diff --git a/templates/ubuntu20/dist/runtime.dockerfile.j2 b/templates/ubuntu20/dist/runtime.dockerfile.j2 index d7e9780e..81e04cd9 100644 --- a/templates/ubuntu20/dist/runtime.dockerfile.j2 +++ b/templates/ubuntu20/dist/runtime.dockerfile.j2 @@ -1,5 +1,5 @@ # Install OpenVINO python API dependency -RUN ${PYTHON_VER} -m pip install --no-cache-dir numpy==1.24.4 +RUN python3 -m pip install --no-cache-dir numpy==1.24.4 WORKDIR ${INTEL_OPENVINO_DIR}/licensing # Please use `third-party-programs-docker-runtime.txt` short path to 3d party file if you use the Dockerfile directly from docker_ci/dockerfiles repo folder diff --git a/templates/ubuntu20/python/python39.dockerfile.j2 b/templates/ubuntu20/python/python39.dockerfile.j2 index b2473807..0e5e68a8 100644 --- a/templates/ubuntu20/python/python39.dockerfile.j2 +++ b/templates/ubuntu20/python/python39.dockerfile.j2 @@ -1,4 +1,5 @@ # setup Python -ENV PYTHON_VER python3.9 - -RUN ${PYTHON_VER} -m pip install --upgrade pip \ No newline at end of file +ENV VIRTUAL_ENV=/opt/venv +RUN python3.9 -m venv $VIRTUAL_ENV +ENV PATH=$VIRTUAL_ENV/bin:$PATH +RUN python3 -m pip install --no-cache-dir --upgrade pip setuptools \ No newline at end of file