From ead9bc82b037a93b777d190437dd3e0d2a7a6939 Mon Sep 17 00:00:00 2001 From: Jesse Pretorius Date: Wed, 2 Nov 2016 18:07:36 +0000 Subject: [PATCH] Simplify pip options/constraints mechanism The current constraints generation for the installation involves multiple tasks and multiple variables. Using multiple tasks extends the installation time unnecessarily and the additional variables are unnecessary. This patch aims to simplify the mechanism and hopes to speed it up a little. Change-Id: Icdd5d053346e7d31dcfd4331c7b7b0f184bf376b --- defaults/main.yml | 2 -- ...ove-requirements-git-0c8e83081b435229.yaml | 7 +++++ tasks/swift_install.yml | 31 +++++-------------- tasks/swift_pypy_setup.yml | 5 ++- 4 files changed, 18 insertions(+), 27 deletions(-) create mode 100644 releasenotes/notes/remove-requirements-git-0c8e83081b435229.yaml diff --git a/defaults/main.yml b/defaults/main.yml index 4fed52b4..2e832cea 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -27,8 +27,6 @@ swift_pip_package_state: "latest" swift_git_repo: https://git.openstack.org/openstack/swift swift_git_install_branch: master -swift_requirements_git_repo: https://git.openstack.org/openstack/requirements -swift_requirements_git_install_branch: master swift_developer_mode: false swift_developer_constraints: - "git+{{ swift_git_repo }}@{{ swift_git_install_branch }}#egg=swift" diff --git a/releasenotes/notes/remove-requirements-git-0c8e83081b435229.yaml b/releasenotes/notes/remove-requirements-git-0c8e83081b435229.yaml new file mode 100644 index 00000000..51494789 --- /dev/null +++ b/releasenotes/notes/remove-requirements-git-0c8e83081b435229.yaml @@ -0,0 +1,7 @@ +--- +upgrade: + - The variables ``swift_requirements_git_repo`` and + ``swift_requirements_git_install_branch`` have been + removed in favour of using the URL/path to the + upper-constraints file using the + variable ``pip_install_upper_constraints`` instead. diff --git a/tasks/swift_install.yml b/tasks/swift_install.yml index d4972206..00e21a37 100644 --- a/tasks/swift_install.yml +++ b/tasks/swift_install.yml @@ -27,33 +27,13 @@ when: - swift_developer_mode | bool -- name: Clone requirements git repository - git: - repo: "{{ swift_requirements_git_repo }}" - dest: "/opt/requirements" - clone: yes - update: yes - version: "{{ swift_requirements_git_install_branch }}" - when: - - swift_developer_mode | bool - -- name: Add constraints to pip_install_options fact for developer mode - set_fact: - pip_install_options_fact: "{{ pip_install_options|default('') }} --constraint /opt/developer-pip-constraints.txt --constraint /opt/requirements/upper-constraints.txt" - when: - - swift_developer_mode | bool - -- name: Set pip_install_options_fact when not in developer mode - set_fact: - pip_install_options_fact: "{{ pip_install_options|default('') }}" - when: - - not swift_developer_mode | bool - - name: Install requires pip packages pip: name: "{{ swift_requires_pip_packages | join(' ') }}" state: "{{ swift_pip_package_state }}" - extra_args: "{{ pip_install_options_fact }}" + extra_args: >- + {{ (pip_install_upper_constraints is defined) | ternary('--constraint ' + pip_install_upper_constraints | default(''),'') }} + {{ pip_install_options | default('') }} register: install_packages until: install_packages|success retries: 5 @@ -131,7 +111,10 @@ state: "{{ swift_pip_package_state }}" virtualenv: "{{ swift_bin | dirname }}" virtualenv_site_packages: "no" - extra_args: "{{ pip_install_options_fact }}" + extra_args: >- + {{ swift_developer_mode | ternary('--constraint /opt/developer-pip-constraints.txt', '') }} + {{ (pip_install_upper_constraints is defined) | ternary('--constraint ' + pip_install_upper_constraints | default(''),'') }} + {{ pip_install_options | default('') }} register: install_packages until: install_packages|success retries: 5 diff --git a/tasks/swift_pypy_setup.yml b/tasks/swift_pypy_setup.yml index 9b0c9611..b9a91648 100644 --- a/tasks/swift_pypy_setup.yml +++ b/tasks/swift_pypy_setup.yml @@ -60,7 +60,10 @@ virtualenv: "{{ swift_bin | dirname }}" virtualenv_site_packages: "no" virtualenv_command: "{{ swift_pypy_env | dirname }}/virtualenv" - extra_args: "{{ pip_install_options_fact }}" + extra_args: >- + {{ swift_developer_mode | ternary('--constraint /opt/developer-pip-constraints.txt', '') }} + {{ (pip_install_upper_constraints is defined) | ternary('--constraint ' + pip_install_upper_constraints | default(''),'') }} + {{ pip_install_options | default('') }} register: install_packages until: install_packages|success retries: 5