From 05ba49cbba9909086d88afd56f71b9f6abb334f9 Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Thu, 7 Jan 2021 16:29:31 -0800 Subject: [PATCH] ansible-test - No virtualenv install on Python 3 Tests should use the Python built-in ``venv`` module on Python 3 instead of the standalone ``virtualenv`` module. On Python 2 the ``virtualenv`` module continues to be the only option. The version installed is either the OS packaged version or the last release to support Python 2, which is version 16.7.10. --- .../fragments/ansible-test-virtualenv-install.yml | 3 +++ test/lib/ansible_test/_data/setup/remote.sh | 14 +++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/ansible-test-virtualenv-install.yml diff --git a/changelogs/fragments/ansible-test-virtualenv-install.yml b/changelogs/fragments/ansible-test-virtualenv-install.yml new file mode 100644 index 00000000000..b92a0322b51 --- /dev/null +++ b/changelogs/fragments/ansible-test-virtualenv-install.yml @@ -0,0 +1,3 @@ +minor_changes: + - ansible-test - The ``--remote`` option no longer pre-installs the ``virtualenv`` module on Python 3.x instances. The Python built-in ``venv`` module should be used instead. + - ansible-test - Pin the ``virtualenv`` version used for ``--remote`` pip installs to the latest version supported by Python 2.x, which is version 16.7.10. diff --git a/test/lib/ansible_test/_data/setup/remote.sh b/test/lib/ansible_test/_data/setup/remote.sh index 93dead5d7e3..a08b3492294 100644 --- a/test/lib/ansible_test/_data/setup/remote.sh +++ b/test/lib/ansible_test/_data/setup/remote.sh @@ -19,6 +19,14 @@ install_pip () { if [ "${platform}" = "freebsd" ]; then py_version="$(echo "${python_version}" | tr -d '.')" + if [ "${py_version}" = "27" ]; then + # on Python 2.7 our only option is to use virtualenv + virtualenv_pkg="py27-virtualenv" + else + # on Python 3.x we'll use the built-in venv instead + virtualenv_pkg="" + fi + while true; do env ASSUME_ALWAYS_YES=YES pkg bootstrap && \ pkg install -q -y \ @@ -27,8 +35,8 @@ if [ "${platform}" = "freebsd" ]; then gtar \ "python${py_version}" \ "py${py_version}-Jinja2" \ - "py${py_version}-virtualenv" \ "py${py_version}-cryptography" \ + ${virtualenv_pkg} \ sudo \ && break echo "Failed to install packages. Sleeping before trying again..." @@ -49,7 +57,6 @@ elif [ "${platform}" = "rhel" ]; then gcc \ python3-devel \ python3-jinja2 \ - python3-virtualenv \ python3-cryptography \ iptables \ && break @@ -109,7 +116,8 @@ elif [ "${platform}" = "aix" ]; then python-jinja2 \ python-cryptography \ python-pip && \ - pip install --disable-pip-version-check --quiet virtualenv \ + pip install --disable-pip-version-check --quiet \ + 'virtualenv==16.7.10' \ && break echo "Failed to install packages. Sleeping before trying again..." sleep 10