From d292ee658aca88ccb454d5987dbf13f5cc74c160 Mon Sep 17 00:00:00 2001 From: Paul Belanger Date: Wed, 23 Aug 2017 14:43:09 -0400 Subject: [PATCH] Create pypi_twine_executable Like we do for bindep and tox roles. Allow a user to manage the twine binary outside of the upload-pypi role. This allows a user to better control the path of the executable too. Change-Id: I5c757b29e185ab76495abf3cfb2d853aada77a50 Signed-off-by: Paul Belanger --- roles/upload-pypi/README.rst | 5 +++++ roles/upload-pypi/defaults/main.yaml | 1 + roles/upload-pypi/tasks/main.yaml | 13 ++----------- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/roles/upload-pypi/README.rst b/roles/upload-pypi/README.rst index 819a21ceb..8c6f3da79 100644 --- a/roles/upload-pypi/README.rst +++ b/roles/upload-pypi/README.rst @@ -30,3 +30,8 @@ Upload python packages to PyPI :default: src/{{ zuul.project.canonical_name }}/dist Path containing artifacts to upload. + +.. zuul:rolevar:: pypi_twine_executable + :default: twine + + Path to twine executable. diff --git a/roles/upload-pypi/defaults/main.yaml b/roles/upload-pypi/defaults/main.yaml index da44daffa..4e71e83f5 100644 --- a/roles/upload-pypi/defaults/main.yaml +++ b/roles/upload-pypi/defaults/main.yaml @@ -2,3 +2,4 @@ pypi_path: "src/{{ zuul.project.canonical_name }}/dist" pypi_repository: "{{ pypi_info.repository|default('pypi') }}" pypi_repository_url: "{{ pypi_info.repository_url|default('https://pypi.python.org/pypi') }}" +pypi_twine_executable: twine diff --git a/roles/upload-pypi/tasks/main.yaml b/roles/upload-pypi/tasks/main.yaml index 5c433e4b8..68387e0bf 100644 --- a/roles/upload-pypi/tasks/main.yaml +++ b/roles/upload-pypi/tasks/main.yaml @@ -1,12 +1,3 @@ -- name: Check for twine install - command: which twine - ignore_errors: yes - register: twine_command_which - -- name: Ensure twine is installed - command: pip install --user twine - when: not twine_command_which|succeeded - - name: Install .pypirc configuration file template: dest: ~/.pypirc @@ -20,7 +11,7 @@ register: found_wheels - name: Upload wheel with twine before tarballs - command: "twine upload -r {{ pypi_repository }} {{ item.path }}" + command: "{{ pypi_twine_executable }} upload -r {{ pypi_repository }} {{ item.path }}" with_items: "{{ found_wheels.files }}" when: found_wheels.matched|bool @@ -31,6 +22,6 @@ register: found_tarballs - name: Upload tarballs with twine - command: "twine upload -r {{ pypi_repository }} {{ item.path }}" + command: "{{ pypi_twine_executable }} upload -r {{ pypi_repository }} {{ item.path }}" with_items: "{{ found_tarballs.files }}" when: found_tarballs.matched|bool