From 19b9f685b54405a3024caad2ce28fdc3d5170932 Mon Sep 17 00:00:00 2001 From: Riccardo Pittau Date: Tue, 11 Feb 2020 15:40:22 +0100 Subject: [PATCH] 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 --- .../roles/bifrost-ironic-install/defaults/main.yml | 2 +- .../bifrost-ironic-install/tasks/pip_install.yml | 13 ++++++++----- .../bifrost-keystone-install/defaults/main.yml | 2 +- scripts/install-deps.sh | 12 +++++++++++- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/playbooks/roles/bifrost-ironic-install/defaults/main.yml b/playbooks/roles/bifrost-ironic-install/defaults/main.yml index d6c3d89a0..9b05de0ff 100644 --- a/playbooks/roles/bifrost-ironic-install/defaults/main.yml +++ b/playbooks/roles/bifrost-ironic-install/defaults/main.yml @@ -309,7 +309,7 @@ ironic_inspector: # DEPRECATED(TheJulia): Inheritance of ironic_db_password params # should be removed in Queens. -pip_opts: "--upgrade-strategy only-if-needed" +pip_opts: "{{ lookup('env', 'PIP_OPTS') | default('') }}" # Timeout for gathering facts. fact_gather_timeout: "{{ lookup('config', 'DEFAULT_GATHER_TIMEOUT', on_missing='skip') | default(omit, true) }}" diff --git a/playbooks/roles/bifrost-ironic-install/tasks/pip_install.yml b/playbooks/roles/bifrost-ironic-install/tasks/pip_install.yml index 5aa929846..64203ab98 100644 --- a/playbooks/roles/bifrost-ironic-install/tasks/pip_install.yml +++ b/playbooks/roles/bifrost-ironic-install/tasks/pip_install.yml @@ -19,6 +19,11 @@ 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 }}" @@ -57,12 +62,10 @@ delay: 10 when: (source_install is not defined or source_install | bool == false ) and enable_venv | default(false) | bool == false -# NOTE (cinerama): We should be able to use the pip module here - name: "Install requirements from {{ sourcedir }} using pip" - command: | - pip3 install -r {{ sourcedir }}/requirements.txt - {{ extra_args | default('') }} - {% if upper_constraints_file %}-c {{ upper_constraints_file }}{% endif %} + 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 diff --git a/playbooks/roles/bifrost-keystone-install/defaults/main.yml b/playbooks/roles/bifrost-keystone-install/defaults/main.yml index 6b2180679..ff67e518f 100644 --- a/playbooks/roles/bifrost-keystone-install/defaults/main.yml +++ b/playbooks/roles/bifrost-keystone-install/defaults/main.yml @@ -61,4 +61,4 @@ keystone: password: ChangeThisPa55w0rd host: localhost -pip_opts: "--upgrade-strategy only-if-needed" +pip_opts: "{{ lookup('env', 'PIP_OPTS') | default('') }}" diff --git a/scripts/install-deps.sh b/scripts/install-deps.sh index e400ad0b2..977ceb6cd 100644 --- a/scripts/install-deps.sh +++ b/scripts/install-deps.sh @@ -156,7 +156,17 @@ PYTHON=$(which python3) # requests, one of our indirect dependencies (bug 1459947). # ls $PYTHON -sudo -H -E $PYTHON -m pip install -U pip --ignore-installed + +# workaround for PEP517 issue +PYTHON_VER=$($PYTHON -V) +if [[ $PYTHON_VER == "Python 3.6.8" ]]; then + sudo -H -E $PYTHON -m pip install pip==19.0 --ignore-installed + export PIP_OPTS="" +else + sudo -H -E $PYTHON -m pip install -U pip --ignore-installed + export PIP_OPTS="--upgrade-strategy only-if-needed" +fi + if [ "$?" != "0" ]; then wget -O /tmp/get-pip.py https://bootstrap.pypa.io/3.4/get-pip.py sudo -H -E ${PYTHON} /tmp/get-pip.py