Drop empty pip packages from the list

This patch aims to remove empty records from venv_pip_packages list
to avoid pip error due to that.

This also brings _venv_pip_packages variable, which optimize process by
doing union and sort only once.

Change-Id: Ic94f5a00346e47c394bd2cefc1cfca4ed8c3bdef
(cherry picked from commit 6b3d95e13b)
This commit is contained in:
Dmitriy Rabotyagov 2020-08-10 20:12:54 +03:00 committed by Jonathan Rosser
parent e7a165b1d0
commit e3bcafaeae
3 changed files with 5 additions and 3 deletions

View File

@ -68,7 +68,7 @@
copy:
dest: "{{ venv_install_destination_path }}/requirements.txt"
content: |
{% for item in (venv_default_pip_packages | union(venv_pip_packages)) | sort %}
{% for item in _venv_pip_packages %}
{{ item }}
{% endfor %}
register: _requirement_file
@ -124,7 +124,7 @@
block:
- name: Install python packages into the venv
pip:
name: "{{ (venv_default_pip_packages | union(venv_pip_packages)) | sort }}"
name: "{{ _venv_pip_packages }}"
state: "{{ venv_pip_package_state }}"
virtualenv: "{{ venv_install_destination_path }}"
extra_args: >-

View File

@ -80,7 +80,7 @@
copy:
dest: "{{ venv_build_host_requirements_path }}/{{ venv_install_destination_path | basename }}-requirements.txt"
content: |
{% for item in (venv_default_pip_packages | union(venv_pip_packages)) | sort %}
{% for item in _venv_pip_packages %}
{{ item }}
{% endfor %}
register: _requirement_file

View File

@ -76,3 +76,5 @@ venv_build_targets: |-
{% set _ = targets.__setitem__(distro, target_item) %}
{% endfor %}
{{ targets }}
_venv_pip_packages: "{{ (venv_default_pip_packages | union(venv_pip_packages)) | sort | select | list }}"