From caef3380fec9dd8c2e91e6c6ef1ffdb63d23f462 Mon Sep 17 00:00:00 2001 From: Jesse Pretorius Date: Tue, 7 Aug 2018 22:16:18 +0100 Subject: [PATCH] Simplify pip/setuptools/wheel prep for venvs Similarly to I7204c09ed0e2dbc03aab5ce74684d88d985ce411 we can simply stop using get-pip.py any more and just use the pip that is already in the virtualenv. This cuts down on yet another reliance on get-pip.py and makes offline installs simpler. Depends-On: https://review.openstack.org/587835 Change-Id: Ia58554d222f27eac772df7d8dfb2394c1881fc82 --- defaults/main.yml | 8 -------- tasks/repo_build_wheels.yml | 16 ---------------- templates/venv-build-script.sh.j2 | 27 ++++++++++++--------------- 3 files changed, 12 insertions(+), 39 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index b2b7cef..9a627d9 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -97,20 +97,12 @@ repo_build_venv_pip_install_options: >- --timeout 120 --find-links {{ repo_build_release_path }} -# Rather than allow virtualenv to decide which version -# of pip/setuptools/wheel we use, we create the virtualenv -# without them and use get-pip.py later to install them -# into the venv. This prevents messy upgrade/downgrade -# failures when trying to install the versions we want. # NOTE(odyssey4me): # Not using --always-copy for CentOS/SuSE due to # https://github.com/pypa/virtualenv/issues/565 repo_build_venv_command_options: >- {{ virtualenv_bin }} {{ (ansible_pkg_mgr == 'apt') | ternary('--always-copy', '') }} - --no-pip - --no-setuptools - --no-wheel # Path to the repo build venv binaries repo_build_bin: "/openstack/venvs/repo-build-{{ repo_build_release_tag }}/bin" diff --git a/tasks/repo_build_wheels.yml b/tasks/repo_build_wheels.yml index 81f4cfe..1968459 100644 --- a/tasks/repo_build_wheels.yml +++ b/tasks/repo_build_wheels.yml @@ -128,22 +128,6 @@ src: "requirements_absolute_requirements.txt.j2" dest: "{{ repo_build_release_path }}/requirements_absolute_requirements.txt" -- name: Get /opt/get-pip.py if it does not exist - get_url: - url: "{{ pip_upstream_url | default('https://bootstrap.pypa.io/3.3/get-pip.py') }}" - dest: "/opt/get-pip.py" - force: no - register: _get_pip - until: _get_pip is success - retries: 10 - delay: 5 - -- name: Copy get-pip script into release folder - copy: - src: "/opt/get-pip.py" - dest: "{{ repo_build_release_path }}/" - remote_src: yes - - name: Clean up temporary build folders to save space file: path: "{{ item }}" diff --git a/templates/venv-build-script.sh.j2 b/templates/venv-build-script.sh.j2 index 39272f0..d07db96 100644 --- a/templates/venv-build-script.sh.j2 +++ b/templates/venv-build-script.sh.j2 @@ -73,21 +73,18 @@ pushd "{{ repo_build_venv_dir }}" &>/dev/null # Activate the python virtual environment for good measure source "${ROLE_VENV_PATH}/bin/activate" - # Install pip, setuptools, wheel into it - # Rather than allow virtualenv to decide which version - # of pip/setuptools/wheel we use, we create the virtualenv - # without them and use get-pip.py later to install them - # into the venv. This prevents messy upgrade/downgrade - # failures when trying to install the versions we want. - # We also inform get-pip.py using the --find-links option - # that there are local wheels available so that it uses - # them instead of reaching out to the internet unnecessarily. - ${ROLE_VENV_PATH}/bin/python {{ repo_build_release_path }}/get-pip.py \ - pip setuptools wheel \ - --find-links {{ repo_build_release_path }} \ - ${PIP_INSTALL_OPTIONS} \ - --constraint {{ repo_build_release_path }}/requirements_constraints.txt \ - &>${ROLE_VENV_LOG} + # Upgrade pip, setuptools and wheel to the version we want + ${ROLE_VENV_PATH}/bin/pip install \ + --disable-pip-version-check \ + --quiet --quiet \ + --build "/tmp/${ROLE_VENV_FILE}" \ + ${PIP_INSTALL_OPTIONS} \ + --constraint {{ repo_build_release_path }}/requirements_constraints.txt \ + --upgrade \ + --index-url {{ repo_build_pip_default_index }} \ + --trusted-host {{ repo_build_pip_default_index | netloc_no_port }} \ + pip setuptools wheel \ + --log "${ROLE_VENV_LOG}" # Install the packages into the venv ${ROLE_VENV_PATH}/bin/pip install \