diff --git a/tasks/main.yml b/tasks/main.yml index 69ef048..604d453 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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: diff --git a/tasks/python_venv_install.yml b/tasks/python_venv_install.yml index 649fe69..60dcca5 100644 --- a/tasks/python_venv_install.yml +++ b/tasks/python_venv_install.yml @@ -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 }}" diff --git a/tasks/python_venv_install_symlink.yml b/tasks/python_venv_install_symlink.yml new file mode 100644 index 0000000..98ea76f --- /dev/null +++ b/tasks/python_venv_install_symlink.yml @@ -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 }}" diff --git a/tasks/python_venv_wheel_build.yml b/tasks/python_venv_wheel_build.yml index ffee36b..599eeef 100644 --- a/tasks/python_venv_wheel_build.yml +++ b/tasks/python_venv_wheel_build.yml @@ -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: