Skip to content

Commit

Permalink
Merge pull request #37 from nmusatti/fix-2.7-support
Browse files Browse the repository at this point in the history
Fix Python 2.6 and 2.7 support
  • Loading branch information
nmusatti authored Mar 29, 2021
2 parents e29e733 + 105744b commit 0dcf584
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ python: "{{ ansible_python_interpreter | default( ansible_python.executable | de
pip: "{{ ( ansible_python.version_info[0] == 3 ) | ternary('pip3', 'pip') }}"
pip_proxy: ''

pip_download_url_current: https://bootstrap.pypa.io/pip/3.5/get-pip.py
pip_download_url_py26: https://bootstrap.pypa.io/pip/2.6/get-pip.py
pip_download_url: "{{ ansible_python.version_info[:3]|join('.') is version_compare('2.7', '>=') | ternary( pip_download_url_current, pip_download_url_py26 ) }}"
python_version: "{{ ansible_python.version_info[:3]|join('.') }}"
python_minor: "{{ ansible_python.version_info[:2]|join('.') }}"
pip_download_version: "{{ ( python_version is version_compare('3.0', '<') ) | ternary( python_minor, '3.5') }}"
pip_download_url: "https://bootstrap.pypa.io/pip/{{ pip_download_version }}/get-pip.py"
pip_max_version2: "{{ ( python_minor == '2.6' ) | ternary( '10', '21' ) }}"
pip_max_version: "{{ ( python_version is version_compare('3.0', '<') ) | ternary( pip_max_version2, '' ) }}"
pip_upgrade_contraint: "{{ ( python_version is version_compare('3.0', '<') ) | ternary( '<' + pip_max_version, '' ) }}"
2 changes: 1 addition & 1 deletion tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
when: pip_version and pip_installed_version.stdout is version_compare(pip_version, '!=') and (pip_version | lower) != "latest"

- name: Upgrade to latest version of pip.
command: "{{ pip }} install -U pip {{ '--proxy=' + pip_proxy if pip_proxy else '' }}"
command: "{{ pip }} install -U pip{{ pip_upgrade_contraint }} {{ '--proxy=' + pip_proxy if pip_proxy else '' }}"
register: pip_latest_output
become: true
changed_when: "'stdout' in pip_latest_output and pip_latest_output.stdout.find('Attempting uninstall') != -1"
Expand Down

0 comments on commit 0dcf584

Please sign in to comment.