From bb1731300a837297fdc898cb542390d170804f50 Mon Sep 17 00:00:00 2001 From: Kevin Carter Date: Fri, 24 Jun 2016 14:21:12 -0500 Subject: [PATCH] Updated swift + pypy The current implementation needed a bit of work due to changes in virtualenv pathing and includes. This change bings swift + pypy up-to-date such that its using the latest stable build of pypy and adds skips to redundat operations when pypy is used as the interpreter. Change-Id: I3db0931ad0f35c8abd162191ba36b3f7f8104223 Signed-off-by: Kevin Carter --- defaults/main.yml | 4 +-- tasks/swift_install.yml | 26 ++++++++++++-------- tasks/swift_pypy_setup.yml | 50 +++++++++++++++++++++++++++++++++----- 3 files changed, 62 insertions(+), 18 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 7c414f39..79cd0f85 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -299,8 +299,8 @@ swift_proxy_program_names: # Set this option to enable or disable the pypy interpreter for swift swift_pypy_enabled: false swift_pypy_archive: - url: "https://bitbucket.org/pypy/pypy/downloads/pypy-5.1.1-linux64.tar.bz2" - sha256: "c852622e8bc81618c137da35fcf57b2349b956c07b6fd853300846e3cefa64fc" + url: "https://bitbucket.org/pypy/pypy/downloads/pypy2-v5.3.1-linux64.tar.bz2" + sha256: "6d0e8b14875b76b1e77f06a2ee3f1fb5015a645a951ba7a7586289344d4d9c22" ## Tunable overrides swift_swift_conf_overrides: {} diff --git a/tasks/swift_install.yml b/tasks/swift_install.yml index 255e89a1..36e46cc0 100644 --- a/tasks/swift_install.yml +++ b/tasks/swift_install.yml @@ -82,6 +82,7 @@ path: "/var/cache/{{ swift_venv_download_url | basename }}" get_md5: False when: + - not swift_pypy_enabled | bool - not swift_developer_mode | bool - swift_venv_enabled | bool register: local_venv_stat @@ -94,6 +95,7 @@ url: "{{ swift_venv_download_url | replace('tgz', 'checksum') }}" return_content: True when: + - not swift_pypy_enabled | bool - not swift_developer_mode | bool - swift_venv_enabled | bool register: remote_venv_checksum @@ -114,6 +116,7 @@ ignore_errors: true register: get_venv when: + - not swift_pypy_enabled | bool - not swift_developer_mode | bool - swift_venv_enabled | bool - (local_venv_stat.stat.exists == False or @@ -135,6 +138,7 @@ path: "{{ swift_venv_bin | dirname }}" state: absent when: + - not swift_pypy_enabled | bool - swift_venv_enabled | bool - swift_get_venv | changed tags: @@ -146,6 +150,7 @@ path: "{{ swift_venv_bin | dirname }}" state: directory when: + - not swift_pypy_enabled | bool - not swift_developer_mode | bool - swift_venv_enabled | bool - swift_get_venv | changed @@ -159,6 +164,7 @@ dest: "{{ swift_venv_bin | dirname }}" copy: "no" when: + - not swift_pypy_enabled | bool - not swift_developer_mode | bool - swift_venv_enabled | bool - swift_get_venv | changed @@ -175,6 +181,7 @@ command: > virtualenv-tools --update-path=auto {{ swift_venv_bin | dirname }} when: + - not swift_pypy_enabled | bool - not swift_developer_mode | bool - swift_venv_enabled | bool - swift_get_venv | success @@ -182,16 +189,6 @@ - swift-install - swift-pip-packages -- include: swift_pypy_setup.yml - when: - - swift_venv_enabled | bool - - swift_get_venv | success - - swift_pypy_enabled | bool - tags: - - swift-install - - swift-pip-packages - - swift-pypy - - name: Install pip packages (venv) pip: name: "{{ item }}" @@ -205,6 +202,7 @@ delay: 2 with_items: swift_pip_packages when: + - not swift_pypy_enabled | bool - swift_venv_enabled | bool - swift_get_venv | failed or swift_developer_mode | bool notify: @@ -227,6 +225,7 @@ delay: 2 with_items: swift_pip_packages when: + - not swift_pypy_enabled | bool - not swift_developer_mode | bool - not swift_venv_enabled | bool notify: @@ -237,3 +236,10 @@ tags: - swift-install - swift-pip-packages + +- include: swift_pypy_setup.yml + when: swift_pypy_enabled | bool + tags: + - swift-install + - swift-pip-packages + - swift-pypy diff --git a/tasks/swift_pypy_setup.yml b/tasks/swift_pypy_setup.yml index ae7c0dad..2da90bb4 100644 --- a/tasks/swift_pypy_setup.yml +++ b/tasks/swift_pypy_setup.yml @@ -39,10 +39,48 @@ dest: "/opt/pypy-runtime" copy: "no" creates: "/opt/pypy-runtime/{{ swift_pypy_version }}/bin/pypy" + register: local_pypy -- name: Change virtualenv python to pypy - shell: | - virtualenv --python {{ swift_pypy_env }} "{{ swift_venv_bin | dirname }}" - touch "{{ swift_venv_bin | dirname }}/{{ swift_pypy_version }}-inuse" - args: - creates: "{{ swift_venv_bin | dirname }}/{{ swift_pypy_version }}-inuse" +- name: Setup local pypy + command: "{{ item }}" + with_items: + - "{{ swift_pypy_env }} /opt/get-pip.py" + - "{{ swift_pypy_env | dirname }}/pip install --upgrade virtualenv" + when: + - local_pypy | changed + +- name: Check for pypy venv + stat: + path: "{{ swift_venv_bin | dirname }}/{{ swift_pypy_version }}-inuse" + get_md5: False + register: local_pypy_venv_stat + +- name: Remove existing venv if not pypy setup + file: + path: "{{ swift_venv_bin | dirname }}" + state: absent + when: not local_pypy_venv_stat.stat.exists | bool + +- name: Install pip packages into pypy venv + pip: + name: "{{ item }}" + state: latest + virtualenv: "{{ swift_venv_bin | dirname }}" + virtualenv_site_packages: "no" + virtualenv_command: "{{ swift_pypy_env | dirname }}/virtualenv" + extra_args: "{{ pip_install_options_fact }}" + register: install_packages + until: install_packages|success + retries: 5 + delay: 2 + with_items: "{{ swift_pip_packages }}" + notify: + - Restart swift account services + - Restart swift container services + - Restart swift object services + - Restart swift proxy services + +- name: Mark swift venv for use with pypy + file: + path: "{{ swift_venv_bin | dirname }}/{{ swift_pypy_version }}-inuse" + state: "touch"