bifrost/playbooks/roles/bifrost-ironic-install/tasks/pip_install.yml
Riccardo Pittau 19b9f685b5 Fix for PEP517 issue with Python 3.6.8
When creating a virtualenv with Python 3.6.8 using the
--system-site-packages option and pip>=19.0.0 a bug affects
the virtualenv breaking pep build isolation.
This patch downgrade pip to version 19.0.0 as a
workaround.

Also converts pip3 command to pip.

See [1] for more info.

[1] https://github.com/pypa/pip/issues/6264

Change-Id: I738d7c2e50914a773920e5381305e8c5131ccd5f
2020-03-13 14:24:56 +01:00

82 lines
3.3 KiB
YAML

# Copyright (c) 2015 Hewlett Packard Enterprise Development LP.
#
# 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: set virtualenv_command
set_fact:
venv_command: "python3 -m venv"
when: enable_venv
- name: workaround for PEP517 issue
set_fact:
extra_args: ""
when: ansible_python_version == "3.6.8"
- name: Set extra_args if upper_constraints_file is defined
set_fact:
constraints_extra_args: "{{ extra_args | default('') }} -c {{ upper_constraints_file }}"
when:
- (upper_constraints_file | default('')) != ''
# NOTE(dtantsur): constraining does not work correctly correctly with
# source installation if the package itself is in constraints.
- source_install is not defined or source_install == false
- name: "Install {{ package }} package from pip using virtualenv"
pip:
name: "{{ package }}"
state: "{{ state | default(omit) }}"
version: "{{ version | default(omit) }}"
virtualenv: "{{ bifrost_venv_dir }}"
virtualenv_command: "{{ venv_command | default(omit) }}"
extra_args: "{{ constraints_extra_args | default(extra_args) | default(omit) }}"
requirements: "{{ requirements_file | default(omit) }}"
register: pip_package_install_done
until: pip_package_install_done is succeeded
retries: 5
delay: 10
when: (source_install is not defined or source_install | bool == false ) and enable_venv | default(false) | bool
- name: "Install {{ package }} package from pip without virtualenv"
pip:
name: "{{ package }}"
state: "{{ state | default(omit) }}"
version: "{{ version | default(omit) }}"
extra_args: "{{ constraints_extra_args | default(extra_args) | default(omit) }}"
requirements: "{{ requirements_file | default(omit) }}"
executable: /usr/bin/pip3
register: pip_package_install_done
until: pip_package_install_done is succeeded
retries: 5
delay: 10
when: (source_install is not defined or source_install | bool == false ) and enable_venv | default(false) | bool == false
- name: "Install requirements from {{ sourcedir }} using pip"
pip:
extra_args: "{{ extra_args | default('') }} {% if upper_constraints_file %}-c {{ upper_constraints_file }}{% endif %}"
requirements: "{{ sourcedir }}/requirements.txt"
register: pip_package_install_done
until: pip_package_install_done is succeeded
retries: 5
delay: 10
when: source_install is defined and source_install | default(true) | bool
environment: "{{ bifrost_venv_env if enable_venv else {} }}"
# NOTE(dtantsur): do not use constraints here, it does not work when the
# package itself is constrained.
- name: "Install from {{ sourcedir }} using pip"
command: pip3 install {{ sourcedir }} {{ extra_args | default('') }}
when: source_install is defined and (source_install | bool == true)
environment: "{{ bifrost_venv_env if enable_venv else {} }}"