Browse Source

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
Jesse Pretorius 8 months ago
parent
commit
caef3380fe
3 changed files with 12 additions and 39 deletions
  1. 0
    8
      defaults/main.yml
  2. 0
    16
      tasks/repo_build_wheels.yml
  3. 12
    15
      templates/venv-build-script.sh.j2

+ 0
- 8
defaults/main.yml View File

@@ -97,20 +97,12 @@ repo_build_venv_pip_install_options: >-
97 97
   --timeout 120
98 98
   --find-links {{ repo_build_release_path }}
99 99
 
100
-# Rather than allow virtualenv to decide which version
101
-# of pip/setuptools/wheel we use, we create the virtualenv
102
-# without them and use get-pip.py later to install them
103
-# into the venv. This prevents messy upgrade/downgrade
104
-# failures when trying to install the versions we want.
105 100
 # NOTE(odyssey4me):
106 101
 # Not using --always-copy for CentOS/SuSE due to
107 102
 # https://github.com/pypa/virtualenv/issues/565
108 103
 repo_build_venv_command_options: >-
109 104
   {{ virtualenv_bin }}
110 105
   {{ (ansible_pkg_mgr == 'apt') | ternary('--always-copy', '') }}
111
-  --no-pip
112
-  --no-setuptools
113
-  --no-wheel
114 106
 
115 107
 # Path to the repo build venv binaries
116 108
 repo_build_bin: "/openstack/venvs/repo-build-{{ repo_build_release_tag }}/bin"

+ 0
- 16
tasks/repo_build_wheels.yml View File

@@ -128,22 +128,6 @@
128 128
     src: "requirements_absolute_requirements.txt.j2"
129 129
     dest: "{{ repo_build_release_path }}/requirements_absolute_requirements.txt"
130 130
 
131
-- name: Get /opt/get-pip.py if it does not exist
132
-  get_url:
133
-    url: "{{ pip_upstream_url | default('https://bootstrap.pypa.io/3.3/get-pip.py') }}"
134
-    dest: "/opt/get-pip.py"
135
-    force: no
136
-  register: _get_pip
137
-  until: _get_pip  is success
138
-  retries: 10
139
-  delay: 5
140
-
141
-- name: Copy get-pip script into release folder
142
-  copy:
143
-    src: "/opt/get-pip.py"
144
-    dest: "{{ repo_build_release_path }}/"
145
-    remote_src: yes
146
-
147 131
 - name: Clean up temporary build folders to save space
148 132
   file:
149 133
     path: "{{ item }}"

+ 12
- 15
templates/venv-build-script.sh.j2 View File

@@ -73,21 +73,18 @@ pushd "{{ repo_build_venv_dir }}" &>/dev/null
73 73
     # Activate the python virtual environment for good measure
74 74
     source "${ROLE_VENV_PATH}/bin/activate"
75 75
 
76
-    # Install pip, setuptools, wheel into it
77
-    # Rather than allow virtualenv to decide which version
78
-    # of pip/setuptools/wheel we use, we create the virtualenv
79
-    # without them and use get-pip.py later to install them
80
-    # into the venv. This prevents messy upgrade/downgrade
81
-    # failures when trying to install the versions we want.
82
-    # We also inform get-pip.py using the --find-links option
83
-    # that there are local wheels available so that it uses
84
-    # them instead of reaching out to the internet unnecessarily.
85
-    ${ROLE_VENV_PATH}/bin/python {{ repo_build_release_path }}/get-pip.py \
86
-                                 pip setuptools wheel \
87
-                                 --find-links {{ repo_build_release_path }} \
88
-                                 ${PIP_INSTALL_OPTIONS} \
89
-                                 --constraint {{ repo_build_release_path }}/requirements_constraints.txt \
90
-                                 &>${ROLE_VENV_LOG}
76
+    # Upgrade pip, setuptools and wheel to the version we want
77
+    ${ROLE_VENV_PATH}/bin/pip install \
78
+        --disable-pip-version-check \
79
+        --quiet --quiet \
80
+        --build "/tmp/${ROLE_VENV_FILE}" \
81
+        ${PIP_INSTALL_OPTIONS} \
82
+        --constraint {{ repo_build_release_path }}/requirements_constraints.txt \
83
+        --upgrade \
84
+        --index-url {{ repo_build_pip_default_index }} \
85
+        --trusted-host {{ repo_build_pip_default_index | netloc_no_port }} \
86
+        pip setuptools wheel \
87
+        --log "${ROLE_VENV_LOG}"
91 88
 
92 89
     # Install the packages into the venv
93 90
     ${ROLE_VENV_PATH}/bin/pip install \

Loading…
Cancel
Save