From d1fd2e556cf090302263441934b9152124302582 Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Tue, 8 Feb 2022 16:33:40 +1100 Subject: [PATCH] build-wheel-cache: Don't use virtualenv on python3 platforms As noted inline, platforms are starting to decide to deprecate virtualenv for "python3 -m venv". Put in logic to use venv in our Python 3 paths. Change-Id: I46778642647d7be995d476fb567a9943cae66b8f --- roles/build-wheel-cache/files/wheel-build.sh | 11 ++++++++++- roles/build-wheel-cache/tasks/main.yaml | 9 +++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/roles/build-wheel-cache/files/wheel-build.sh b/roles/build-wheel-cache/files/wheel-build.sh index be2f9b47..03caf89b 100755 --- a/roles/build-wheel-cache/files/wheel-build.sh +++ b/roles/build-wheel-cache/files/wheel-build.sh @@ -8,6 +8,15 @@ LOGS=$(pwd)/logs FAIL_LOG=${LOGS}/failed.txt +# NOTE(ianw) : Some Python 3 platforms (>= 9-stream) are deprecating +# virtualenv. When we finally ditch Python 2 platforms, just use +# python3 -m venv everywhere. +if [[ ${PYTHON_VERSION} =~ python2 ]]; then + VIRTUALENV_CMD="virtualenv -p $PYTHON_VERSION" +else + VIRTUALENV_CMD="${PYTHON_VERSION} -m venv" +fi + # preclean logs mkdir -p ${LOGS} rm -rf ${LOGS}/* @@ -44,7 +53,7 @@ for BRANCH in master $BRANCHES; do # setup the building virtualenv. We want to freshen this for each # branch. rm -rf build_env - virtualenv -p $PYTHON_VERSION build_env + ${VIRTUALENV_CMD} build_env build_env/bin/pip install --upgrade pip diff --git a/roles/build-wheel-cache/tasks/main.yaml b/roles/build-wheel-cache/tasks/main.yaml index fbb835ec..f212fe11 100644 --- a/roles/build-wheel-cache/tasks/main.yaml +++ b/roles/build-wheel-cache/tasks/main.yaml @@ -1,6 +1,15 @@ - name: Ensure virtualenv dependency include_role: name: ensure-virtualenv + when: wheel_python == "python2" + +# NOTE(ianw) : 2022-02-08 - on python3 we use -m venv; ensure-pip will +# set this up for us. Remove above and the conditional here when we +# drop python2 platforms. +- name: Ensure pip + include_role: + name: ensure-pip + when: wheel_python == "python3" - name: Ensure wheel dir exists file: