Brian Haley 84082ed982 Update ensure-twine role
Install twine into a venv and set appropriate environment
variables. Also added tests.

Based on commit adding `ensure-nox` (77b1b24) role.

Related-bug: #2095514
Change-Id: Ibb4e89f79879b4d0ae0294440c9c0b79fc57a7fa
2025-01-31 12:23:08 -05:00

43 lines
1.4 KiB
ReStructuredText

Ensure twine is installed.
Look for ``twine``, and if not found, install it via ``pip`` into a
virtual environment for the current user.
**Role Variables**
.. zuul:rolevar:: ensure_twine_version
:default: ''
Version specifier to select the version of Twine. The default is the
latest version.
.. zuul:rolevar:: ensure_twine_venv_path
:default: {{ ansible_user_dir }}/.local/twine
Directory for the Python venv where Twine will be installed.
.. zuul:rolevar:: ensure_twine_global_symlink
:default: False
Install a symlink to the twine executable into ``/usr/local/bin/twine``.
This can be useful when scripts need to be run that expect to find
Twine in a more standard location and plumbing through the value
of ``pypi_twine_executable`` would be onerous.
Setting this requires root access, so should only be done in
circumstances where root access is available.
**Output Variables**
.. zuul:rolevar:: pypi_twine_executable
:default: twine
After running this role, ``pypi_twine_executable`` will be set as the path
to a valid ``twine``.
At role runtime, look for an existing ``twine`` at this specific
path. Note the default (``twine``) effectively means to find twine in
the current ``$PATH``. For example, if your base image
pre-installs twine in an out-of-path environment, set this so the
role does not attempt to install the user version.