Import wheels build only when necessary
Skipping tasks take time. It's faster not to import things we don't need We also move symlinking to the separate task that can be inlcuded. Change-Id: I20a5cda421910df9aaca3aacb3f3e088a1fd2938
This commit is contained in:
parent
9e7877d55a
commit
ab68e94425
@ -17,10 +17,15 @@
|
||||
tags:
|
||||
- always
|
||||
|
||||
- import_tasks: "python_venv_wheel_build.yml"
|
||||
- include_tasks: "python_venv_wheel_build.yml"
|
||||
args:
|
||||
apply:
|
||||
tags:
|
||||
- build
|
||||
when: venv_wheel_build_enable | bool
|
||||
run_once: yes
|
||||
tags:
|
||||
- build
|
||||
- always
|
||||
|
||||
- import_tasks: "python_venv_install.yml"
|
||||
tags:
|
||||
|
@ -178,37 +178,10 @@
|
||||
located at /var/log/python_venv_build.log for more information.
|
||||
|
||||
- name: Add symlinks from distribution python packages
|
||||
include_tasks: python_venv_install_symlink.yml
|
||||
args:
|
||||
apply:
|
||||
tags:
|
||||
- install
|
||||
when:
|
||||
- venv_packages_to_symlink | length > 0
|
||||
block:
|
||||
- name: Find the venv's python version
|
||||
find:
|
||||
paths: "{{ venv_install_destination_path }}/lib/"
|
||||
patterns: "python*"
|
||||
file_type: directory
|
||||
recurse: no
|
||||
register: _python_venv_details
|
||||
|
||||
- name: Set python venv details
|
||||
set_fact:
|
||||
venv_python_version: "{{ (_python_venv_details.files[0].path | basename) }}"
|
||||
venv_python_major_version: "{{ (_python_venv_details.files[0].path | basename)[:-2] }}"
|
||||
venv_python_lib_folder: "{{ _python_venv_details.files[0].path }}"
|
||||
|
||||
- name: Search for lib files to link
|
||||
shell: >-
|
||||
{{ (ansible_pkg_mgr == 'apt') | ternary('dpkg -L ' ~ (venv_packages_to_symlink | join(' ')), 'rpm -ql ' ~ (venv_packages_to_symlink | join(' ')) ) }}
|
||||
| egrep '^.*{{ venv_python_major_version }}.*/(site|dist)-packages/.*'
|
||||
| egrep -v "__pycache__"
|
||||
args:
|
||||
warn: no
|
||||
changed_when: false
|
||||
register: _python_files
|
||||
|
||||
- name: Link the python host package files into venv
|
||||
file:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ venv_python_lib_folder }}/site-packages/{{ item | basename }}"
|
||||
state: link
|
||||
force: yes
|
||||
with_items: "{{ _python_files.stdout_lines }}"
|
||||
|
46
tasks/python_venv_install_symlink.yml
Normal file
46
tasks/python_venv_install_symlink.yml
Normal file
@ -0,0 +1,46 @@
|
||||
---
|
||||
# Copyright 2021, City Network International AB.
|
||||
#
|
||||
# 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: Find the venv's python version
|
||||
find:
|
||||
paths: "{{ venv_install_destination_path }}/lib/"
|
||||
patterns: "python*"
|
||||
file_type: directory
|
||||
recurse: no
|
||||
register: _python_venv_details
|
||||
|
||||
- name: Set python venv details
|
||||
set_fact:
|
||||
venv_python_version: "{{ (_python_venv_details.files[0].path | basename) }}"
|
||||
venv_python_major_version: "{{ (_python_venv_details.files[0].path | basename)[:-2] }}"
|
||||
venv_python_lib_folder: "{{ _python_venv_details.files[0].path }}"
|
||||
|
||||
- name: Search for lib files to link
|
||||
shell: >-
|
||||
{{ (ansible_pkg_mgr == 'apt') | ternary('dpkg -L ' ~ (venv_packages_to_symlink | join(' ')), 'rpm -ql ' ~ (venv_packages_to_symlink | join(' ')) ) }}
|
||||
| egrep '^.*{{ venv_python_major_version }}.*/(site|dist)-packages/.*'
|
||||
| egrep -v "__pycache__"
|
||||
args:
|
||||
warn: no
|
||||
changed_when: false
|
||||
register: _python_files
|
||||
|
||||
- name: Link the python host package files into venv
|
||||
file:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ venv_python_lib_folder }}/site-packages/{{ item | basename }}"
|
||||
state: link
|
||||
force: yes
|
||||
with_items: "{{ _python_files.stdout_lines }}"
|
@ -23,8 +23,6 @@
|
||||
- name: Build the wheels on the build host
|
||||
delegate_to: "{{ venv_build_host }}"
|
||||
become: "{{ venv_build_host == 'localhost' }}"
|
||||
when:
|
||||
- venv_wheel_build_enable | bool
|
||||
block:
|
||||
- name: Install distro packages for wheel build
|
||||
package:
|
||||
|
Loading…
x
Reference in New Issue
Block a user