Execution
Date
15 Dec 2025 10:16:58 +0000
Duration
00:02:05.54
Controller
aio1.openstack.local
User
root
Versions
Ansible
2.18.6
ara
1.7.4 / 1.7.4
Python
3.12.3
Summary
17
Hosts
64
Tasks
194
Results
13
Plays
46
Files
0
Records
File: /home/zuul/src/opendev.org/openstack/ansible-role-python_venv_build/tasks/python_venv_wheel_build.yml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | --- # Copyright 2018, Rackspace US, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - name: Build the wheels on the build host delegate_to: "{{ venv_build_host }}" block: # NOTE(jrosser) remove the use: parameter when https://github.com/ansible/ansible/issues/82598 is fixed - name: Install distro packages for wheel build vars: _python_wheel_build_package_list: "{{ venv_build_base_distro_package_list | union(venv_build_distro_package_list) }}" ansible.builtin.package: name: "{{ _python_wheel_build_package_list }}" state: "{{ venv_distro_package_state }}" update_cache: "{{ (ansible_facts['pkg_mgr'] == 'apt') | ternary('yes', omit) }}" cache_valid_time: "{{ (ansible_facts['pkg_mgr'] == 'apt') | ternary(venv_distro_cache_valid_time, omit) }}" use: "{{ ansible_facts['pkg_mgr'] }}" when: - _python_wheel_build_package_list | length > 0 register: _install_build_distro_packages until: _install_build_distro_packages is success retries: 5 delay: 2 - name: Clean up paths and files if venv_wheels_rebuild is enabled ansible.builtin.file: path: "{{ item }}" state: absent with_items: - "{{ _venv_build_requirements_prefix }}-requirements.txt" - "{{ _venv_build_requirements_prefix }}-global-constraints.txt" - "{{ _venv_build_requirements_prefix }}-source-constraints.txt" - "{{ _venv_build_requirements_prefix }}-constraints.txt" when: - venv_wheels_rebuild | bool - name: Ensure a fresh venv_build_host_venv_path if venv_rebuild is enabled ansible.builtin.file: path: "{{ venv_build_host_venv_path }}" state: absent when: - venv_rebuild | bool - venv_wheels_rebuild | bool - name: Create wheel directory on the build host ansible.builtin.file: path: "{{ item }}" state: directory owner: "{{ venv_build_host_user_name | default(omit) }}" group: "{{ venv_build_host_group_name | default(omit) }}" mode: "0755" with_items: - "{{ venv_build_host_wheel_path }}" - "{{ venv_build_host_requirements_path }}" - "{{ venv_build_host_venv_path }}" - name: Build requirement and constraint files for the venv ansible.builtin.copy: dest: "{{ item.dest }}" content: "{{ item.content }}" owner: "{{ venv_build_host_user_name | default(omit) }}" group: "{{ venv_build_host_group_name | default(omit) }}" mode: "0644" loop: - dest: "{{ _venv_build_requirements_prefix }}-requirements.txt" content: |- {% for item in _venv_pip_packages | select() %} {{ item }} {% endfor %} - dest: "{{ _venv_build_requirements_prefix }}-global-constraints.txt" content: |- {% for item in venv_build_global_constraints | select() %} {{ item }} {% endfor %} - dest: "{{ _venv_build_requirements_prefix }}-source-constraints.txt" content: |- {% for item in venv_build_constraints | select() %} {{ item }} {% endfor %} loop_control: label: "{{ item.dest }}" register: _requirements_contraints - name: Upgrade the wheel build virtualenv pip/setuptools/wheel to the versions we want ansible.builtin.pip: name: - pip - setuptools - wheel state: "{{ venv_pip_package_state }}" virtualenv: "{{ venv_build_host_venv_path }}" virtualenv_command: "{{ venv_python_executable }} -m venv" extra_args: >- --constraint {{ _venv_build_requirements_prefix }}-global-constraints.txt --constraint {{ _venv_build_requirements_prefix }}-source-constraints.txt --find-links {{ venv_build_host_wheel_path }}/ --trusted-host {{ (openstack_repo_url | default('http://localhost')) | urlsplit('hostname') }} --log /var/log/python_venv_build.log {{ venv_pip_build_args }} environment: "{{ venv_pip_build_env | combine(_pip_upgrade_noconf) }}" vars: _pip_upgrade_noconf: PIP_CONFIG_FILE: "{{ (venv_pip_upgrade_noconf | bool) | ternary('/dev/null', '') }}" register: _update_virtualenv_packages until: _update_virtualenv_packages is success retries: 5 delay: 2 - name: Build wheels and constraints file when: _requirements_contraints.results | selectattr('changed') | length > 0 block: - name: Clean up temporary wheel build path ansible.builtin.file: path: "/tmp/{{ venv_install_destination_path | basename }}" state: absent - name: Build wheels for the packages to be installed into the venv # noqa: no-changed-when ansible.builtin.command: >- {{ venv_build_host_venv_path }}/bin/pip wheel --requirement {{ _venv_build_requirements_prefix }}-requirements.txt --constraint {{ _venv_build_requirements_prefix }}-global-constraints.txt --constraint {{ _venv_build_requirements_prefix }}-source-constraints.txt --wheel-dir /tmp/{{ venv_install_destination_path | basename }}/ --find-links {{ venv_build_host_wheel_path }}/ --trusted-host {{ (openstack_repo_url | default('http://localhost')) | urlsplit('hostname') }} --log /var/log/python_wheel_build.log {{ venv_pip_build_args }} {{ venv_wheels_rebuild | ternary('--no-cache-dir', '') }} environment: "{{ venv_pip_build_env }}" register: _build_python_wheels until: _build_python_wheels is success retries: 5 delay: 2 - name: Index built wheels ansible.builtin.find: paths: "/tmp/{{ venv_install_destination_path | basename }}" file_type: file register: _built_wheels - name: Set wheel permissions ansible.builtin.file: path: "/tmp/{{ venv_install_destination_path | basename }}" owner: "{{ venv_build_host_user_name | default(omit) }}" group: "{{ venv_build_host_group_name | default(omit) }}" state: directory recurse: true when: - (venv_build_host_user_name is defined) or (venv_build_host_group_name is defined) - name: Move built wheels to common wheel path ansible.builtin.shell: >- mv /tmp/{{ venv_install_destination_path | basename }}/* {{ venv_build_host_wheel_path }}/ changed_when: false args: executable: /bin/bash - name: Build constraints file for installation purposes ansible.builtin.copy: content: |- {% for file_data in _built_wheels['files'] %} {% set file_name = file_data['path'] | basename %} {{ file_name.split('-')[0] | lower }}=={{ (file_name.split('-')[1].split('_')) | join('.post') | lower }} {% endfor %} dest: "{{ _venv_build_requirements_prefix }}-constraints.txt" owner: "{{ venv_build_host_user_name | default(omit) }}" group: "{{ venv_build_host_group_name | default(omit) }}" mode: "0644" |