Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ansible-test - prefer venv over virtualenv on Python 3 #73000

Merged
merged 1 commit into from Dec 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,3 @@
minor_changes:
- ansible-test - virtualenv helper scripts now prefer ``venv`` on Python 3 over ``virtualenv``
- ansible-test - remote macOS instances no longer install ``virtualenv`` during provisioning
8 changes: 7 additions & 1 deletion test/lib/ansible_test/_data/injector/virtualenv-isolated.sh
Expand Up @@ -2,7 +2,13 @@
# Create and activate a fresh virtual environment with `source virtualenv-isolated.sh`.

rm -rf "${OUTPUT_DIR}/venv"
"${ANSIBLE_TEST_PYTHON_INTERPRETER}" -m virtualenv --python "${ANSIBLE_TEST_PYTHON_INTERPRETER}" "${OUTPUT_DIR}/venv"

# Try to use 'venv' if it is available, then fallback to 'virtualenv' since some systems provide 'venv' although it is non-functional.
if [[ "${ANSIBLE_TEST_PYTHON_VERSION}" =~ ^2\. ]] || ! "${ANSIBLE_TEST_PYTHON_INTERPRETER}" -m venv "${OUTPUT_DIR}/venv" > /dev/null 2>&1; then
rm -rf "${OUTPUT_DIR}/venv"
"${ANSIBLE_TEST_PYTHON_INTERPRETER}" -m virtualenv --python "${ANSIBLE_TEST_PYTHON_INTERPRETER}" "${OUTPUT_DIR}/venv"
fi

set +ux
source "${OUTPUT_DIR}/venv/bin/activate"
set -ux
Expand Down
8 changes: 7 additions & 1 deletion test/lib/ansible_test/_data/injector/virtualenv.sh
Expand Up @@ -2,7 +2,13 @@
# Create and activate a fresh virtual environment with `source virtualenv.sh`.

rm -rf "${OUTPUT_DIR}/venv"
"${ANSIBLE_TEST_PYTHON_INTERPRETER}" -m virtualenv --system-site-packages --python "${ANSIBLE_TEST_PYTHON_INTERPRETER}" "${OUTPUT_DIR}/venv"

# Try to use 'venv' if it is available, then fallback to 'virtualenv' since some systems provide 'venv' although it is non-functional.
if [[ "${ANSIBLE_TEST_PYTHON_VERSION}" =~ ^2\. ]] || ! "${ANSIBLE_TEST_PYTHON_INTERPRETER}" -m venv --system-site-packages "${OUTPUT_DIR}/venv" > /dev/null 2>&1; then
rm -rf "${OUTPUT_DIR}/venv"
"${ANSIBLE_TEST_PYTHON_INTERPRETER}" -m virtualenv --system-site-packages --python "${ANSIBLE_TEST_PYTHON_INTERPRETER}" "${OUTPUT_DIR}/venv"
fi

set +ux
source "${OUTPUT_DIR}/venv/bin/activate"
set -ux
10 changes: 1 addition & 9 deletions test/lib/ansible_test/_data/setup/remote.sh
Expand Up @@ -88,18 +88,10 @@ elif [ "${platform}" = "centos" ]; then
done

install_pip
elif [ "${platform}" = "macos" ]; then
while true; do
pip3 install --disable-pip-version-check --quiet \
'virtualenv<20' \
&& break
echo "Failed to install packages. Sleeping before trying again..."
sleep 10
done
elif [ "${platform}" = "osx" ]; then
while true; do
pip install --disable-pip-version-check --quiet \
'virtualenv<20' \
'virtualenv==16.7.10' \
&& break
echo "Failed to install packages. Sleeping before trying again..."
sleep 10
Expand Down