twine.settings module

Module containing logic for handling settings.

class twine.settings.Settings[source]

Object that manages the configuration for Twine.

This object can only be instantiated with keyword arguments.

For example,

Settings(True, username='fakeusername')

Will raise a TypeError. Instead, you would want

Settings(sign=True, username='fakeusername')
__init__(*, sign: bool = False, sign_with: str = 'gpg', identity: Optional[str] = None, username: Optional[str] = None, password: Optional[str] = None, non_interactive: bool = False, comment: Optional[str] = None, config_file: str = utils.DEFAULT_CONFIG_FILE, skip_existing: bool = False, cacert: Optional[str] = None, client_cert: Optional[str] = None, repository_name: str = 'pypi', repository_url: Optional[str] = None, verbose: bool = False, disable_progress_bar: bool = False, **ignored_kwargs: Any) None[source]

Initialize our settings instance.

Parameters
  • sign – Configure whether the package file should be signed.

  • sign_with – The name of the executable used to sign the package with.

  • identity – The GPG identity that should be used to sign the package file.

  • username – The username used to authenticate to the repository (package index).

  • password – The password used to authenticate to the repository (package index).

  • non_interactive – Do not interactively prompt for username/password if the required credentials are missing.

  • comment – The comment to include with each distribution file.

  • config_file – The path to the configuration file to use.

  • skip_existing – Specify whether twine should continue uploading files if one of them already exists. This primarily supports PyPI. Other package indexes may not be supported.

  • cacert – The path to the bundle of certificates used to verify the TLS connection to the package index.

  • client_cert – The path to the client certificate used to perform authentication to the index. This must be a single file that contains both the private key and the PEM-encoded certificate.

  • repository_name – The name of the repository (package index) to interact with. This should correspond to a section in the config file.

  • repository_url – The URL of the repository (package index) to interact with. This will override the settings inferred from repository_name.

  • verbose – Show verbose output.

  • disable_progress_bar – Disable the progress bar.

property username: Optional[str]
property password: Optional[str]
_allow_noninteractive() ContextManager[None][source]

Bypass NonInteractive error when client cert is present.

property verbose: bool
static register_argparse_arguments(parser: argparse.ArgumentParser) None[source]

Register the arguments for argparse.

classmethod from_argparse(args: argparse.Namespace) twine.settings.Settings[source]

Generate the Settings from parsed arguments.

_handle_package_signing(sign: bool, sign_with: str, identity: Optional[str]) None[source]
_handle_repository_options(repository_name: str, repository_url: Optional[str]) None[source]
_handle_certificates(cacert: Optional[str], client_cert: Optional[str]) None[source]
check_repository_url() None[source]

Verify we are not using legacy PyPI.

Raises

twine.exceptions.UploadToDeprecatedPyPIDetected – The configured repository URL is for legacy PyPI.

create_repository() twine.repository.Repository[source]

Create a new repository for uploading.