TWINE(3)

NAME
twine - twine Documentation

This project follows the semantic versioning <https://packaging.python.org/en/latest/discussions/versioning/#semantic-versioning-vs-calendar-versioning> and pre-release versioning <https://packaging.python.org/en/latest/discussions/versioning/> schemes recommended by the Python Packaging Authority.

TWINE 6.2.0 (2025-09-04)

  Features

    •   Automatically refresh short-lived PyPI token in long running Trusted Publishing uploads.

        In the event that a trusted publishing upload job is taking longer than the validity period of a trusted publishing token (15 minutes at the time of this writing), and we are already 10 minutes into that validity period, we will begin to attempt to replace the token on each subsequent request. (#1246 <https://github.com/pypa/twine/issues/1246>)

  Bugfixes

    •   Fix compatibility kludge for invalid License-File metadata entries emitted by build backends to work also with packaging version 24.0. (#1217 <https://github.com/pypa/twine/issues/1217>)

    •   Fix a couple of incorrectly rendered error messages. (#1224 <https://github.com/pypa/twine/issues/1224>)

    •   twine now enforces keyring >= 21.2.0, which was previously implicitly required by API usage. (#1229 <https://github.com/pypa/twine/issues/1229>)

    •   twine now catches configparser.Error to prevent accidental leaks of secret tokens or passwords to the user's console. (#1240 <https://github.com/pypa/twine/issues/1240>)

  Deprecations and Removals

    •   Remove hacks that support --skip-existing for indexes other than PyPI and TestPyPI.

        To date, these hacks continue to accrue and there have been numerous issues with them, not the least of which being that every time we update them, the paid index providers change things to break the compatibility we implement for them. Beyond that, these hacks do not work when text is internationalized in the response from the index provider.

        For a sample of past issues, see:

        •   <https://github.com/pypa/twine/issues/1251>

        •   <https://github.com/pypa/twine/issues/918>

        •   <https://github.com/pypa/twine/issues/856>

        •   <https://github.com/pypa/twine/issues/693>

        •   <https://github.com/pypa/twine/issues/332> (#1251 <https://github.com/pypa/twine/issues/1251>)

    •   Remove support for MD5 digests during uploads.

        This support was entirely vestigial, as MD5 is not a secure hash function and is not actually required on upload by PyPI.

        Indices that cross-reference the uploaded content with a digest should use the provided SHA-256 and/or BLAKE2 digests instead. (#1262 <https://github.com/pypa/twine/issues/1262>)

  Misc

    •   #1247 <https://github.com/pypa/twine/issues/1247>

TWINE 6.1.0 (2025-01-17)

  Features

    •   Twine now has preliminary built-in support for Trusted Publishing <https://docs.pypi.org/trusted-publishers/> as an authentication mechanism. (#1194 <https://github.com/pypa/twine/pull/1194>)

  Deprecations and Removals

    •   Remove support for egg and wininst distribution types. These are not accepted by PyPI and not produced by any modern build-backends. (#1195 <https://github.com/pypa/twine/issues/1195>)

    •   Twine no longer supports .tar.bz2 source distributions. (#1200 <https://github.com/pypa/twine/pull/1200>)

  Misc

    •   packaging is used instead of pkginfo for parsing and validating metadata. This aligns metadata validation to the one performed by PyPI. packaging version 24.0 or later is required. Support for metadata version 2.4 requires packaging 24.2 or later. pkginfo is not a dependency anymore. (#1180 <https://github.com/pypa/twine/issues/1180>)

    •   Use "source" instead of None as pyversion for sdist uploads. This is what PyPI (and most likely other package indexes) expects. (#1191 <https://github.com/pypa/twine/issues/1191>)

TWINE 6.0.1 (2024-11-30)

  Bugfixes

    •   Fixed a regression where twine check would fail to expand wildcards, e.g. twine check 'dist/*'. (#1188 <https://github.com/pypa/twine/issues/1188>)

  Misc

    •   #1184 <https://github.com/pypa/twine/issues/1184>

TWINE 6.0.0 (2024-11-29)

  Bugfixes

    •   Restore support for pkginfo 1.11 (#1116 <https://github.com/pypa/twine/issues/1116>)

  Deprecations and Removals

    •   Username for PyPI and Test PyPI now defaults to __token__ but no longer overrides a username configured in the environment or supplied on the command line. Workflows still supplying anything other than __token__ for the username when uploading to PyPI or Test PyPI will now fail. Either supply __token__ or do not supply a username at all. (#1121 <https://github.com/pypa/twine/issues/1121>)

  Misc

    •   #1024 <https://github.com/pypa/twine/issues/1024>

TWINE 5.1.1 (2024-06-26)

  Bugfixes

    •   Resolve DeprecationWarnings when extracting twine metadata. (#1115 <https://github.com/pypa/twine/issues/1115>)

    •   Fix bug for Repository URLs with auth where the port was lost. When attempting to prevent printing authentication credentials in URLs provided with username and password, we did not properly handle the case where the URL also contains a port (when reconstructing the URL). This is now handled and tested to ensure no regressions. (#fix-repo-urls-with-auth-and-port <https://github.com/pypa/twine/issues/fix-repo-urls-with-auth-and-port>)

TWINE 5.1.0 (2024-05-15)

  Features

    •   Add the experimental --attestations flag. (#1095 <https://github.com/pypa/twine/issues/1095>)

TWINE 5.1.0 (2024-05-15)

  Misc

    •   #1104 <https://github.com/pypa/twine/issues/1104>

TWINE 5.0.0 (2024-02-10)

  Bugfixes

    •   Use email.message instead of cgi as cgi has been deprecated (#969 <https://github.com/pypa/twine/issues/969>)

  Features

    •   Remove support for usernames other than __token__ when uploading to PyPI and TestPyPI (#1040 <https://github.com/pypa/twine/issues/1040>)

  Misc

    •   #931 <https://github.com/pypa/twine/issues/931>, #991 <https://github.com/pypa/twine/issues/991>, #1028 <https://github.com/pypa/twine/issues/1028>

TWINE 4.0.2 (2022-11-30)

  Bugfixes

    •   Remove deprecated function to fix twine check with pkginfo 1.9.0. (#941 <https://github.com/pypa/twine/issues/941>)

TWINE 4.0.1 (2022-06-01)

  Bugfixes

    •   Improve logging when keyring fails. (#890 <https://github.com/pypa/twine/issues/890>)

    •   Reconfigure root logger to show all log messages. (#896 <https://github.com/pypa/twine/issues/896>)

TWINE 4.0.0 (2022-03-31)

  Features

    •   Drop support for Python 3.6. (#869 <https://github.com/pypa/twine/issues/869>)

    •   Use Rich to add color to upload output. (#851 <https://github.com/pypa/twine/issues/851>)

    •   Use Rich to add color to check output. (#874 <https://github.com/pypa/twine/issues/874>)

    •   Use Rich instead of tqdm for upload progress bar. (#877 <https://github.com/pypa/twine/issues/877>)

  Bugfixes

    •   Remove Twine's dependencies from the User-Agent header when uploading. (#871 <https://github.com/pypa/twine/issues/871>)

    •   Improve detection of disabled BLAKE2 hashing due to FIPS mode. (#879 <https://github.com/pypa/twine/issues/879>)

    •   Restore warning for missing long_description. (#887 <https://github.com/pypa/twine/issues/887>)

TWINE 3.8.0 (2022-02-02)

  Features

    •   Add --verbose logging for querying keyring credentials. (#849 <https://github.com/pypa/twine/issues/849>)

    •   Log all upload responses with --verbose. (#859 <https://github.com/pypa/twine/issues/859>)

    •   Show more helpful error message for invalid metadata. (#861 <https://github.com/pypa/twine/issues/861>)

  Bugfixes

    •   Require a recent version of urllib3. (#858 <https://github.com/pypa/twine/issues/858>)

TWINE 3.7.1 (2021-12-07)

  Improved Documentation

    •   Fix broken link to packaging tutorial. (#844 <https://github.com/pypa/twine/issues/844>)

TWINE 3.7.0 (2021-12-01)

  Features

    •   Add support for core metadata version 2.2, defined in PEP 643. (#833 <https://github.com/pypa/twine/issues/833>)

TWINE 3.6.0 (2021-11-10)

  Features

    •   Add support for Python 3.10. (#827 <https://github.com/pypa/twine/issues/827>)

TWINE 3.5.0 (2021-11-02)

  Features

    •   Show more helpful messages for invalid passwords. (#815 <https://github.com/pypa/twine/issues/815>)

    •   Allow the --skip-existing option to work with GCP Artifact Registry. (#823 <https://github.com/pypa/twine/issues/823>)

  Bugfixes

    •   Add a helpful error message when an upload fails due to missing a trailing slash in the URL. (#812 <https://github.com/pypa/twine/issues/812>)

    •   Generalize --verbose suggestion when an upload fails. (#817 <https://github.com/pypa/twine/issues/817>)

TWINE 3.4.2 (2021-07-20)

  Bugfixes

    •   Improve error message for unsupported metadata. (#755 <https://github.com/pypa/twine/issues/755>)

    •   Improve error message for a missing config file. (#770 <https://github.com/pypa/twine/issues/770>)

    •   Do not include md5_digest or blake2_256_digest if FIPS mode is enabled on the host. This removes those fields from the metadata before sending the metadata to the repository. (#776 <https://github.com/pypa/twine/issues/776>)

TWINE 3.4.1 (2021-03-16)

  Bugfixes

    •   Fix a regression that was causing some namespace packages with dots in them fail to upload to PyPI. (#745 <https://github.com/pypa/twine/issues/745>)

TWINE 3.4.0 (2021-03-15)

  Features

    •   Prefer importlib.metadata for entry point handling. (#728 <https://github.com/pypa/twine/issues/728>)

    •   Rely on importlib_metadata 3.6 for nicer entry point processing. (#732 <https://github.com/pypa/twine/issues/732>)

    •   Eliminate dependency on setuptools/pkg_resources and replace with packaging and importlib_metadata. (#736 <https://github.com/pypa/twine/issues/736>)

TWINE 3.3.0 (2020-12-23)

  Features

    •   Print files to be uploaded using upload --verbose (#670 <https://github.com/pypa/twine/issues/670>)

    •   Print configuration file location when using upload --verbose (#675 <https://github.com/pypa/twine/issues/675>)

    •   Print source and values of credentials when using upload --verbose (#685 <https://github.com/pypa/twine/issues/685>)

    •   Add support for Python 3.9 (#708 <https://github.com/pypa/twine/issues/708>)

    •   Turn warnings into errors when using check --strict (#715 <https://github.com/pypa/twine/issues/715>)

  Bugfixes

    •   Make password optional when using upload --client-cert (#678 <https://github.com/pypa/twine/issues/678>)

    •   Support more Nexus versions with upload --skip-existing (#693 <https://github.com/pypa/twine/issues/693>)

    •   Support Gitlab Enterprise with upload --skip-existing (#698 <https://github.com/pypa/twine/issues/698>)

    •   Show a better error message for malformed files (#714 <https://github.com/pypa/twine/issues/714>)

  Improved Documentation

    •   Adopt PSF code of conduct (#680 <https://github.com/pypa/twine/issues/680>)

    •   Adopt towncrier for the changleog (#718 <https://github.com/pypa/twine/issues/718>)

TWINE 3.2.0 (2020-06-24)

  Features

    •   Improve display of HTTP errors during upload (#666 <https://github.com/pypa/twine/issues/666>)

    •   Print packages and signatures to be uploaded when using --verbose option (#652 <https://github.com/pypa/twine/issues/652>)

    •   Use red text when printing errors on the command line (#649 <https://github.com/pypa/twine/issues/649>)

    •   Require repository URL scheme to be http or https (#602 <https://github.com/pypa/twine/issues/602>)

    •   Add type annotations, checked with mypy, with PEP 561 <https://peps.python.org/pep-0561/> support for users of Twine's API (#231 <https://github.com/pypa/twine/issues/231>)

  Bugfixes

    •   Update URL to .pypirc specification (#655 <https://github.com/pypa/twine/issues/655>)

    •   Don't raise an exception when Python version can't be parsed from filename (#612 <https://github.com/pypa/twine/issues/612>)

    •   Fix inaccurate retry message during upload (#611 <https://github.com/pypa/twine/issues/611>)

    •   Clarify error messages for archive format (#601 <https://github.com/pypa/twine/issues/601>)

TWINE 3.1.1 (2019-11-27)

  Bugfixes

    •   Restore --non-interactive as a flag not expecting an argument. (#548 <https://github.com/pypa/twine/issues/548>)

TWINE 3.1.0 (2019-11-23)

  Features

    •   Add support for specifying --non-interactive as an environment variable. (#547 <https://github.com/pypa/twine/issues/547>)

TWINE 3.0.0 (2019-11-18)

  Features

    •   When a client certificate is indicated, all password processing is disabled. (#336 <https://github.com/pypa/twine/issues/336>)

    •   Add --non-interactive flag to abort upload rather than interactively prompt if credentials are missing. (#489 <https://github.com/pypa/twine/issues/489>)

    •   Twine now unconditionally requires the keyring library and no longer supports uninstalling keyring as a means to disable that functionality. Instead, use keyring --disable keyring functionality if necessary. (#524 <https://github.com/pypa/twine/issues/524>)

    •   Add Python 3.8 to classifiers. (#518 <https://github.com/pypa/twine/issues/518>)

  Bugfixes

    •   More robust handling of server response in --skip-existing (#332 <https://github.com/pypa/twine/issues/332>)

TWINE 2.0.0 (2019-09-24)

  Features

    •   Twine now requires Python 3.6 or later. Use pip 9 or pin to "twine<2" to install twine on older Python versions. (#437 <https://github.com/pypa/twine/issues/437>)

  Bugfixes

    •   Require requests 2.20 or later to avoid reported security vulnerabilities in earlier releases. (#491 <https://github.com/pypa/twine/issues/491>)

TWINE 1.15.0 (2019-09-17)

  Features

    •   Improved output on check command: Prints a message when there are no distributions given to check. Improved handling of errors in a distribution's markup, avoiding messages flowing through to the next distribution's errors. (#488 <https://github.com/pypa/twine/issues/488>)

TWINE 1.14.0 (2019-09-06)

  Features

    •   Show Warehouse URL after uploading a package (#459 <https://github.com/pypa/twine/issues/459>)

    •   Better error handling and gpg2 fallback if gpg not available. (#456 <https://github.com/pypa/twine/issues/456>)

    •   Now provide a more meaningful error on redirect during upload. (#310 <https://github.com/pypa/twine/issues/310>)

  Bugfixes

    •   Fail more gracefully when encountering bad metadata (#341 <https://github.com/pypa/twine/issues/341>)

TWINE 1.13.0 (2019-02-13)

  Features

    •   Add disable_progress_bar option to disable tqdm. (#427 <https://github.com/pypa/twine/issues/427>)

    •   Allow defining an empty username and password in .pypirc. (#426 <https://github.com/pypa/twine/issues/426>)

    •   Support keyring.get_credential. (#419 <https://github.com/pypa/twine/issues/419>)

    •   Support keyring.get_username_and_password. (#418 <https://github.com/pypa/twine/issues/418>)

    •   Add Python 3.7 to classifiers. (#416 <https://github.com/pypa/twine/issues/416>)

  Bugfixes

    •   Restore prompts while retaining support for suppressing prompts. (#452 <https://github.com/pypa/twine/issues/452>)

    •   Avoid requests-toolbelt to 0.9.0 to prevent attempting to use openssl when it isn't available. (#447 <https://github.com/pypa/twine/issues/447>)

    •   Use io.StringIO instead of StringIO. (#444 <https://github.com/pypa/twine/issues/444>)

    •   Only install pyblake2 if needed. (#441 <https://github.com/pypa/twine/issues/441>)

    •   Use modern Python language features. (#436 <https://github.com/pypa/twine/issues/436>)

    •   Specify python_requires in setup.py (#435 <https://github.com/pypa/twine/issues/435>)

    •   Use https URLs everywhere. (#432 <https://github.com/pypa/twine/issues/432>)

    •   Fix --skip-existing for Nexus Repos. (#428 <https://github.com/pypa/twine/issues/428>)

    •   Remove unnecessary usage of readme_render.markdown. (#421 <https://github.com/pypa/twine/issues/421>)

    •   Don't crash if there's no package description. (#412 <https://github.com/pypa/twine/issues/412>)

    •   Fix keyring support. (#408 <https://github.com/pypa/twine/issues/408>)

  Misc

    •   Refactor tox env and travis config. (#439 <https://github.com/pypa/twine/issues/439>)

TWINE 1.12.1 (2018-09-24)

  Bugfixes

    •   Fix regression with upload exit code (#404 <https://github.com/pypa/twine/issues/404>)

TWINE 1.12.0 (2018-09-24)

  Features

    •   Add twine check command to check long description (#395 <https://github.com/pypa/twine/issues/395>)

    •   Drop support for Python 3.3 (#392 <https://github.com/pypa/twine/issues/392>)

    •   Empower --skip-existing for Artifactory repositories (#363 <https://github.com/pypa/twine/issues/363>)

  Bugfixes

    •   Avoid MD5 when Python is compiled in FIPS mode (#367 <https://github.com/pypa/twine/issues/367>)

TWINE 1.11.0 (2018-03-19)

  Features

    •   Remove PyPI as default register package index. (#320 <https://github.com/pypa/twine/issues/320>)

    •   Support Metadata 2.1 (PEP 566 <https://peps.python.org/pep-0566/>), including Markdown for description fields. (#319 <https://github.com/pypa/twine/issues/319>)

  Bugfixes

    •   Raise exception if attempting upload to deprecated legacy PyPI URLs. (#322 <https://github.com/pypa/twine/issues/322>)

    •   Avoid uploading to PyPI when given alternate repository URL, and require http:// or https:// in repository_url. (#269 <https://github.com/pypa/twine/issues/269>)

  Misc

    •   Update PyPI URLs <https://packaging.python.org/guides/migrating-to-pypi-org/>. (#318 <https://github.com/pypa/twine/issues/318>)

    •   Add new maintainer, release checklists. (#314 <https://github.com/pypa/twine/issues/314>)

    •   Add instructions on how to use keyring. (#277 <https://github.com/pypa/twine/issues/277>)

TWINE 1.10.0 (2018-03-07)

  Features

    •   Link to changelog from README (#46 <https://github.com/pypa/twine/issues/46>)

    •   Reorganize & improve user & developer documentation. (#304 <https://github.com/pypa/twine/issues/304>)

    •   Revise docs predicting future of twine (#303 <https://github.com/pypa/twine/issues/303>)

    •   Add architecture overview to docs (#296 <https://github.com/pypa/twine/issues/296>)

    •   Add doc building instructions (#295 <https://github.com/pypa/twine/issues/295>)

    •   Declare support for Python 3.6 (#257 <https://github.com/pypa/twine/issues/257>)

    •   Improve progressbar (#256 <https://github.com/pypa/twine/issues/256>)

  Bugfixes

    •   Degrade gracefully when keyring is unavailable (#315 <https://github.com/pypa/twine/issues/315>)

    •   Fix changelog formatting (#299 <https://github.com/pypa/twine/issues/299>)

    •   Fix syntax highlighting in README (#298 <https://github.com/pypa/twine/issues/298>)

    •   Fix Read the Docs, tox, Travis configuration (#297 <https://github.com/pypa/twine/issues/297>)

    •   Fix Travis CI and test configuration (#286 <https://github.com/pypa/twine/issues/286>)

    •   Print progress to stdout, not stderr (#268 <https://github.com/pypa/twine/issues/268>)

    •   Fix --repository[-url] help text (#265 <https://github.com/pypa/twine/issues/265>)

    •   Remove obsolete registration guidance (#200 <https://github.com/pypa/twine/issues/200>)

TWINE 1.9.1 (2017-05-27)

  Bugfixes

    •   Blacklist known bad versions of Requests. (#253 <https://github.com/pypa/twine/issues/253>)

TWINE 1.9.0 (2017-05-22)

  Bugfixes

    •   Twine sends less information about the user's system in the User-Agent string. (#229 <https://github.com/pypa/twine/issues/229>)

    •   Fix --skip-existing when used to upload a package for the first time. (#220 <https://github.com/pypa/twine/issues/220>)

    •   Fix precedence of --repository-url over --repository. (#206 <https://github.com/pypa/twine/issues/206>)

  Misc

    •   Twine will now resolve passwords using the keyring <https://pypi.org/project/keyring/> if available. Module can be required with the keyring extra.

    •   Twine will use hashlib.blake2b on Python 3.6+ instead of pyblake2

TWINE 1.8.1 (2016-08-09)

  Misc

    •   Check if a package exists if the URL is one of:

                •   https://pypi.python.org/pypi/

                •   https://upload.pypi.org/

                •   https://upload.pypi.io/

            This helps people with https://upload.pypi.io still in their .pypirc file.

TWINE 1.8.0 (2016-08-08)

  Features

    •   Switch from upload.pypi.io to upload.pypi.org. (#201 <https://github.com/pypa/twine/issues/201>)

    •   Retrieve configuration from the environment as a default. (#144 <https://github.com/pypa/twine/issues/144>)

                •   Repository URL will default to TWINE_REPOSITORY

                •   Username will default to TWINE_USERNAME

                •   Password will default to TWINE_PASSWORD

    •   Allow the Repository URL to be provided on the command-line (--repository-url) or via an environment variable (TWINE_REPOSITORY_URL). (#166 <https://github.com/pypa/twine/issues/166>)

    •   Generate Blake2b 256 digests for packages if pyblake2 is installed. Users can use python -m pip install twine[with-blake2] to have pyblake2 installed with Twine. (#171 <https://github.com/pypa/twine/issues/171>)

  Misc

    •   Generate SHA256 digest for all packages by default.

    •   Stop testing on Python 2.6.

    •   Warn users if they receive a 500 error when uploading to *pypi.python.org (#199 <https://github.com/pypa/twine/issues/199>)

TWINE 1.7.4 (2016-07-09)

  Bugfixes

    •   Correct a packaging error.

TWINE 1.7.3 (2016-07-08)

  Bugfixes

    •   Fix uploads to instances of pypiserver using --skip-existing. We were not properly checking the return status code on the response after attempting an upload. (#195 <https://github.com/pypa/twine/issues/195>)

  Misc

    •   Avoid attempts to upload a package if we can find it on Legacy PyPI.

TWINE 1.7.2 (2016-07-05)

  Bugfixes

    •   Fix issue where we were checking the existence of packages even if the user didn't specify --skip-existing. (#189 <https://github.com/pypa/twine/issues/189>) (#191 <https://github.com/pypa/twine/issues/191>)

TWINE 1.7.1 (2016-07-05)

  Bugfixes

    •   Clint was not specified in the wheel metadata as a dependency. (#187 <https://github.com/pypa/twine/issues/187>)

TWINE 1.7.0 (2016-07-04)

  Features

    •   Support --cert and --client-cert command-line flags and config file options for feature parity with pip. This allows users to verify connections to servers other than PyPI (e.g., local package repositories) with different certificates. (#142 <https://github.com/pypa/twine/issues/142>)

    •   Add progress bar to uploads. (#152 <https://github.com/pypa/twine/issues/152>)

    •   Allow --skip-existing to work for 409 status codes. (#162 <https://github.com/pypa/twine/issues/162>)

    •   Implement retries when the CDN in front of PyPI gives us a 5xx error. (#167 <https://github.com/pypa/twine/issues/167>)

    •   Switch Twine to upload to pypi.io instead of pypi.python.org. (#177 <https://github.com/pypa/twine/issues/177>)

  Bugfixes

    •   Allow passwords to have %s in them. (#186 <https://github.com/pypa/twine/issues/186>)

TWINE 1.6.5 (2015-12-16)

  Bugfixes

    •   Bump requests-toolbelt version to ensure we avoid ConnectionErrors (#155 <https://github.com/pypa/twine/issues/155>)

TWINE 1.6.4 (2015-10-27)

  Bugfixes

    •   Paths with hyphens in them break the Wheel regular expression. (#145 <https://github.com/pypa/twine/issues/145>)

    •   Exception while accessing the repository key (sic) when raising a redirect exception. (#146 <https://github.com/pypa/twine/issues/146>)

TWINE 1.6.3 (2015-10-05)

  Bugfixes

    •   Fix uploading signatures causing a 500 error after large file support was added. (#137 <https://github.com/pypa/twine/issues/137>, #140 <https://github.com/pypa/twine/issues/140>)

TWINE 1.6.2 (2015-09-28)

  Bugfixes

    •   Upload signatures with packages appropriately (#132 <https://github.com/pypa/twine/issues/132>)
            As part of the refactor for the 1.6.0 release, we were using the wrong name to find the signature file.

            This also uncovered a bug where if you're using twine in a situation where * is not expanded by your shell, we might also miss uploading signatures to PyPI. Both were fixed as part of this.

TWINE 1.6.1 (2015-09-18)

  Bugfixes

    •   Fix signing support for uploads (#130 <https://github.com/pypa/twine/issues/130>)

TWINE 1.6.0 (2015-09-14)

  Features

    •   Allow the user to specify the location of their .pypirc (#97 <https://github.com/pypa/twine/issues/97>)

    •   Support registering new packages with twine register (#8 <https://github.com/pypa/twine/issues/8>)

    •   Add the --skip-existing flag to twine upload to allow users to skip releases that already exist on PyPI. (#115 <https://github.com/pypa/twine/issues/115>)

    •   Upload wheels first to PyPI (#106 <https://github.com/pypa/twine/issues/106>)

    •   Large file support via the requests-toolbelt (#104 <https://github.com/pypa/twine/issues/104>)

  Bugfixes

    •   Raise an exception on redirects (#92 <https://github.com/pypa/twine/issues/92>)

    •   Work around problems with Windows when using getpass.getpass (#116 <https://github.com/pypa/twine/issues/116>)

    •   Warnings triggered by pkginfo searching for PKG-INFO files should no longer be user visible. (#114 <https://github.com/pypa/twine/issues/114>)

    •   Provide more helpful messages if .pypirc is out of date. (#111 <https://github.com/pypa/twine/issues/111>)

TWINE 1.5.0 (2015-03-10)

  Features

    •   Support commands not named "gpg" for signing (#29 <https://github.com/pypa/twine/issues/29>)

  Bugfixes

    •   Display information about the version of setuptools installed (#85 <https://github.com/pypa/twine/issues/85>)

    •   Support deprecated pypirc file format (#61 <https://github.com/pypa/twine/issues/61>)

  Misc

    •   Add lower-limit to requests dependency

TWINE 1.4.0 (2014-12-12)

  Features

    •   Switch to a git style dispatching for the commands to enable simpler commands and programmatic invocation. (#6 <https://github.com/pypa/twine/issues/6>)

    •   Parse ~/.pypirc ourselves and use subprocess instead of the distutils.spawn module. (#13 <https://github.com/pypa/twine/issues/13>)

  Bugfixes

    •   Expand globs and check for existence of dists to upload (#65 <https://github.com/pypa/twine/issues/65>)

    •   Fix issue uploading packages with _s in the name (#47 <https://github.com/pypa/twine/issues/47>)

    •   List registered commands in help text (#34 <https://github.com/pypa/twine/issues/34>)

    •   Use pkg_resources to load registered commands (#32 <https://github.com/pypa/twine/issues/32>)

    •   Prevent ResourceWarning from being shown (#28 <https://github.com/pypa/twine/issues/28>)

    •   Add support for uploading Windows installers (#26 <https://github.com/pypa/twine/issues/26>)

TWINE 1.3.0 (2014-03-31)

  Features

    •   Additional functionality.

TWINE 1.2.2 (2013-10-03)

  Features

    •   Basic functionality.

We are happy you have decided to contribute to Twine.

Please see the GitHub repository <https://github.com/pypa/twine> for code and more documentation, and the official Python Packaging User Guide <https://packaging.python.org/tutorials/packaging-projects/> for user documentation. To ask questions or get involved, you can join the Python Packaging Discourse forum <https://discuss.python.org/c/packaging/>, #pypa or #pypa-dev on IRC <https://web.libera.chat/#pypa-dev,#pypa>, or the distutils-sig mailing list <https://mail.python.org/mailman3/lists/distutils-sig.python.org/>.

Everyone interacting in the Twine project's codebases, issue trackers, chat rooms, and mailing lists is expected to follow the PSF Code of Conduct <https://github.com/pypa/.github/blob/main/CODE_OF_CONDUCT.md>.

GETTING STARTED

We use tox <https://tox.readthedocs.io/> to run tests, check code style, and build the documentation. To install tox, run:

            python3 -m pip install tox

Clone the twine repository from GitHub, then run:

            cd /path/to/your/local/twine
            tox -e dev

This creates a virtual environment <https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/>, so that twine and its dependencies do not interfere with other packages installed on your machine. In the virtual environment, twine is pointing at your local copy, so when you make changes, you can easily see their effect.

The virtual environment also contains the tools for running tests and checking code style, so you can run them on single files directly or in your code editor. However, we still encourage using the tox commands below on the whole codebase.

To use the virtual environment, run:

            source venv/bin/activate

  Building the documentation

Additions and edits to twine's documentation are welcome and appreciated.

To preview the docs while you're making changes, run:

            tox -e watch-docs

Then open a web browser to <http://127.0.0.1:8000>.

When you're done making changes, lint and build the docs locally before making a pull request. In your active virtual environment, run:

            tox -e docs

The HTML of the docs will be written to docs/_build/html.

  Code style

To automatically reformat your changes with isort <https://timothycrosley.github.io/isort/> and black <https://black.readthedocs.io/>, run:

            tox -e format

To detect any remaining code smells with flake8 <https://flake8.pycqa.org/>, run:

            tox -e lint

To perform strict type-checking using mypy <https://mypy.readthedocs.io/>, run:

            tox -e types

Any errors from lint or types need to be fixed manually.

Additionally, we prefer that import statements be used for packages and modules only, rather than individual classes or functions.

  Testing

We use pytest <https://docs.pytest.org/> for writing and running tests.

To run the tests in your virtual environment, run:

            tox -e py

To pass options to pytest, e.g. the name of a test, run:

            tox -e py -- tests/test_upload.py::test_exception_for_http_status

Twine is continuously tested against supported versions of Python using GitHub Actions <https://github.com/pypa/twine/actions>. To run the tests against a specific version, e.g. Python 3.8, you will need it installed on your machine. Then, run:

            tox -e py38

To run the "integration" tests of uploading to real package indexes, run:

            tox -e integration

To run the tests against all supported Python versions, check code style, and build the documentation, run:

            tox

SUBMITTING CHANGES

    1.  Fork the GitHub repository <https://github.com/pypa/twine>.

    2.  Make a branch off of main and commit your changes to it.

    3.  Run the tests, check code style, and build the docs as described above.

    4.  Optionally, add your name to the end of the AUTHORS file using the format Name <email@domain.com> (url), where the (url) portion is optional.

    5.  Submit a pull request to the main branch on GitHub, referencing an open issue.

    6.  Add a changelog entry.

  Changelog entries

The docs/changelog.rst file is built by towncrier <https://pypi.org/project/towncrier/> from files in the changelog/ directory. To add an entry, create a file in that directory named {number}.{type}.rst, where {number} is the pull request number, and {type} is feature, bugfix, doc, removal, or misc.

For example, if your PR number is 1234 and it's fixing a bug, then you would create changelog/1234.bugfix.rst. PRs can span multiple categories by creating multiple files: if you added a feature and deprecated/removed an old feature in PR #5678, you would create changelog/5678.feature.rst and changelog/5678.removal.rst.

A changelog entry is meant for end users and should only contain details relevant to them. In order to maintain a consistent style, please keep the entry to the point, in sentence case, shorter than 80 characters, and in an imperative tone. An entry should complete the sentence "This change will ...". If one line is not enough, use a summary line in an imperative tone, followed by a description of the change in one or more paragraphs, each wrapped at 80 characters and separated by blank lines.

You don't need to reference the pull request or issue number in a changelog entry, since towncrier will add a link using the number in the file name, and the pull request should reference an issue number. Similarly, you don't need to add your name to the entry, since that will be associated with the pull request.

Changelog entries are rendered using reStructuredText <https://www.writethedocs.org/guide/writing/reStructuredText/>, but they should only have minimal formatting (such as ``monospaced text``).

ARCHITECTURAL OVERVIEW

Twine is a command-line tool for interacting with PyPI securely over HTTPS. Its three purposes are to be:

    1.  A user-facing tool for publishing on pypi.org

    2.  A user-facing tool for publishing on other Python package indexes (e.g., devpi instances)

    3.  A useful API for other programs (e.g., zest.releaser) to call for publishing on any Python package index

Currently, twine has two principal functions: uploading new packages and registering new projects <https://packaging.python.org/glossary/#term-Project> (register is no longer supported on PyPI, and is in Twine for use with other package indexes).

Its command line arguments are parsed in twine/cli.py. The code for registering new projects is in twine/commands/register.py, and the code for uploading is in twine/commands/upload.py. The file twine/package.py contains a single class, PackageFile, which hashes the project files and extracts their metadata. The file twine/repository.py contains the Repository class, whose methods control the URL the package is uploaded to (which the user can specify either as a default, in the .pypirc file, or pass on the command line), and the methods that upload the package securely to a URL.

For more details, refer to the source documentation (currently a work in progress <https://github.com/pypa/twine/issues/635>):

  twine package

Top-level module for Twine.

The contents of this package are not a public API. For more details, see <https://github.com/pypa/twine/issues/194> and <https://github.com/pypa/twine/issues/665>.

  twine.commands package

Module containing the logic for the twine sub-commands.

The contents of this package are not a public API. For more details, see <https://github.com/pypa/twine/issues/194> and <https://github.com/pypa/twine/issues/665>.

  twine.commands.check module

Module containing the logic for twine check.

    class twine.commands.check._WarningStream

        write(text: str <https://docs.python.org/3/library/stdtypes.html#str>) -> int <https://docs.python.org/3/library/functions.html#int>
            Write string to file.

            Returns the number of characters written, which is always equal to the length of the string.

    twine.commands.check._parse_content_type(value: str <https://docs.python.org/3/library/stdtypes.html#str>) -> Tuple <https://docs.python.org/3/library/typing.html#typing.Tuple>[str <https://docs.python.org/3/library/stdtypes.html#str>, Dict <https://docs.python.org/3/library/typing.html#typing.Dict>[str <https://docs.python.org/3/library/stdtypes.html#str>, str <https://docs.python.org/3/library/stdtypes.html#str>]]
        Implement logic of deprecated cgi.parse_header().

        From <https://docs.python.org/3.11/library/cgi.html#cgi.parse_header>.

    twine.commands.check._check_file(filename: str <https://docs.python.org/3/library/stdtypes.html#str>, render_warning_stream: _WarningStream <#twine.commands.check._WarningStream>) -> Tuple <https://docs.python.org/3/library/typing.html#typing.Tuple>[List <https://docs.python.org/3/library/typing.html#typing.List>[str <https://docs.python.org/3/library/stdtypes.html#str>], bool <https://docs.python.org/3/library/functions.html#bool>]
        Check given distribution.

    twine.commands.check.check(dists: List <https://docs.python.org/3/library/typing.html#typing.List>[str <https://docs.python.org/3/library/stdtypes.html#str>], strict: bool <https://docs.python.org/3/library/functions.html#bool> = False) -> bool <https://docs.python.org/3/library/functions.html#bool>
        Check that a distribution will render correctly on PyPI and display the results.

        This is currently only validates long_description, but more checks could be added.

        Parameters

            •   dists -- The distribution files to check.

            •   output_stream -- The destination of the resulting output.

            •   strict -- If True, treat warnings as errors.

        Returns
            True if there are rendering errors, otherwise False.

    twine.commands.check.main(args: List <https://docs.python.org/3/library/typing.html#typing.List>[str <https://docs.python.org/3/library/stdtypes.html#str>]) -> bool <https://docs.python.org/3/library/functions.html#bool>
        Execute the check command.

        Parameters
            args -- The command-line arguments.

        Returns
            The exit status of the check command.

  twine.commands.register module

Module containing the logic for twine register.

    twine.commands.register.register(register_settings: Settings <#twine.settings.Settings>, package: str <https://docs.python.org/3/library/stdtypes.html#str>) -> None <https://docs.python.org/3/library/constants.html#None>
        Pre-register a package name with a repository before uploading a distribution.

        Pre-registration is not supported on PyPI, so the register command is only necessary if you are using a different repository that requires it.

        Parameters

            •   register_settings -- The configured options relating to repository registration.

            •   package -- The path of the distribution to use for package metadata.

        Raises

            •   twine.exceptions.TwineException <#twine.exceptions.TwineException> -- The registration failed due to a configuration error.

            •   requests.HTTPError <https://requests.readthedocs.io/en/latest/api.html#requests.HTTPError> -- The repository responded with an error.

    twine.commands.register.main(args: List <https://docs.python.org/3/library/typing.html#typing.List>[str <https://docs.python.org/3/library/stdtypes.html#str>]) -> None <https://docs.python.org/3/library/constants.html#None>
        Execute the register command.

        Parameters
            args -- The command-line arguments.

  twine.commands.upload module

Module containing the logic for twine upload.

    twine.commands.upload.skip_upload(response: Response <https://requests.readthedocs.io/en/latest/api.html#requests.Response>, skip_existing: bool <https://docs.python.org/3/library/functions.html#bool>, package: PackageFile <#twine.package.PackageFile>) -> bool <https://docs.python.org/3/library/functions.html#bool>
        Determine if a failed upload is an error or can be safely ignored.

        Parameters

            •   response -- The response from attempting to upload package to a repository.

            •   skip_existing -- If True, use the status and content of response to determine if the package already exists on the repository. If so, then a failed upload is safe to ignore.

            •   package -- The package that was being uploaded.

        Returns
            True if a failed upload can be safely ignored, otherwise False.

    twine.commands.upload._make_package(filename: str <https://docs.python.org/3/library/stdtypes.html#str>, signatures: Dict <https://docs.python.org/3/library/typing.html#typing.Dict>[str <https://docs.python.org/3/library/stdtypes.html#str>, str <https://docs.python.org/3/library/stdtypes.html#str>], attestations: List <https://docs.python.org/3/library/typing.html#typing.List>[str <https://docs.python.org/3/library/stdtypes.html#str>], upload_settings: Settings <#twine.settings.Settings>) -> PackageFile <#twine.package.PackageFile>
        Create and sign a package, based off of filename, signatures, and settings.

        Additionally, any supplied attestations are attached to the package when the settings indicate to do so.

    twine.commands.upload.upload(upload_settings: Settings <#twine.settings.Settings>, dists: List <https://docs.python.org/3/library/typing.html#typing.List>[str <https://docs.python.org/3/library/stdtypes.html#str>]) -> None <https://docs.python.org/3/library/constants.html#None>
        Upload one or more distributions to a repository, and display the progress.

        If a package already exists on the repository, most repositories will return an error response. However, if upload_settings.skip_existing is True, a message will be displayed and any remaining distributions will be uploaded.

        For known repositories (like PyPI), the web URLs of successfully uploaded packages will be displayed.

        Parameters

            •   upload_settings -- The configured options related to uploading to a repository.

            •   dists -- The distribution files to upload to the repository. This can also include .asc and .attestation files, which will be added to their respective file uploads.

        Raises

            •   twine.exceptions.TwineException <#twine.exceptions.TwineException> -- The upload failed due to a configuration error.

            •   requests.HTTPError <https://requests.readthedocs.io/en/latest/api.html#requests.HTTPError> -- The repository responded with an error.

    twine.commands.upload.main(args: List <https://docs.python.org/3/library/typing.html#typing.List>[str <https://docs.python.org/3/library/stdtypes.html#str>]) -> None <https://docs.python.org/3/library/constants.html#None>
        Execute the upload command.

        Parameters
            args -- The command-line arguments.

  twine.auth module

    twine.auth.TOKEN_RENEWAL_THRESHOLD: Final <https://docs.python.org/3/library/typing.html#typing.Final>[timedelta <https://docs.python.org/3/library/datetime.html#datetime.timedelta>] = datetime.timedelta(seconds=300)
        Tokens expire after 15 minutes, let's start allowing renewal/replacement after 10 minutes that way if we fail, we may still have time to replace it before it expires. Thus, if our current time + this threshold is past the greater or equal to the expiration time, we should start trying to replace the token.

    class twine.auth.CredentialInput

        __init__(username: str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None> = None, password: str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None> = None) -> None <https://docs.python.org/3/library/constants.html#None>

    class twine.auth.TrustedPublishingTokenRetrievalError

        code: str <https://docs.python.org/3/library/stdtypes.html#str>

        description: str <https://docs.python.org/3/library/stdtypes.html#str>

    class twine.auth.TrustedPublishingToken

        message: str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None>

        errors: list <https://docs.python.org/3/library/stdtypes.html#list>[TrustedPublishingTokenRetrievalError <#twine.auth.TrustedPublishingTokenRetrievalError>] | None <https://docs.python.org/3/library/constants.html#None>

        token: str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None>

        success: bool <https://docs.python.org/3/library/functions.html#bool> | None <https://docs.python.org/3/library/constants.html#None>

        expires: int <https://docs.python.org/3/library/functions.html#int> | None <https://docs.python.org/3/library/constants.html#None>

    class twine.auth.TrustedPublishingAuthenticator

        __init__(resolver: Resolver <#twine.auth.Resolver>) -> None <https://docs.python.org/3/library/constants.html#None>

    class twine.auth.Resolver

        _tp_token: TrustedPublishingToken <#twine.auth.TrustedPublishingToken> | None <https://docs.python.org/3/library/constants.html#None> = None

        _expires: int <https://docs.python.org/3/library/functions.html#int> | None <https://docs.python.org/3/library/constants.html#None> = None

        __init__(config: Dict <https://docs.python.org/3/library/typing.html#typing.Dict>[str <https://docs.python.org/3/library/stdtypes.html#str>, str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None>], input: CredentialInput <#twine.auth.CredentialInput>) -> None <https://docs.python.org/3/library/constants.html#None>

        property authenticator: AuthBase <https://requests.readthedocs.io/en/latest/api.html#requests.auth.AuthBase>

        classmethod choose(interactive: bool <https://docs.python.org/3/library/functions.html#bool>) -> Type <https://docs.python.org/3/library/typing.html#typing.Type>[Resolver <#twine.auth.Resolver>]

        property username: str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None>

        property password: str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None>

        _has_valid_cached_tp_token() -> bool <https://docs.python.org/3/library/functions.html#bool>

        _make_trusted_publishing_token() -> TrustedPublishingToken <#twine.auth.TrustedPublishingToken> | None <https://docs.python.org/3/library/constants.html#None>

        make_trusted_publishing_token() -> str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None>

        property system: str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None>

        get_username_from_keyring() -> str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None>

        get_password_from_keyring() -> str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None>

        username_from_keyring_or_prompt() -> str <https://docs.python.org/3/library/stdtypes.html#str>

        password_from_keyring_or_trusted_publishing_or_prompt() -> str <https://docs.python.org/3/library/stdtypes.html#str>

        prompt(what: str <https://docs.python.org/3/library/stdtypes.html#str>, how: Callable <https://docs.python.org/3/library/typing.html#typing.Callable>[[...], str <https://docs.python.org/3/library/stdtypes.html#str>]) -> str <https://docs.python.org/3/library/stdtypes.html#str>

        is_pypi() -> bool <https://docs.python.org/3/library/functions.html#bool>
            As of 2024-01-01, PyPI requires API tokens for uploads.

    class twine.auth.Private

        prompt(what: str <https://docs.python.org/3/library/stdtypes.html#str>, how: Callable <https://docs.python.org/3/library/typing.html#typing.Callable>[[...], str <https://docs.python.org/3/library/stdtypes.html#str>] | None <https://docs.python.org/3/library/constants.html#None> = None) -> str <https://docs.python.org/3/library/stdtypes.html#str>

  twine.cli module

    twine.cli.configure_output() -> None <https://docs.python.org/3/library/constants.html#None>

    twine.cli.list_dependencies_and_versions() -> List <https://docs.python.org/3/library/typing.html#typing.List>[Tuple <https://docs.python.org/3/library/typing.html#typing.Tuple>[str <https://docs.python.org/3/library/stdtypes.html#str>, str <https://docs.python.org/3/library/stdtypes.html#str>]]

    twine.cli.dep_versions() -> str <https://docs.python.org/3/library/stdtypes.html#str>

    twine.cli.dispatch(argv: List <https://docs.python.org/3/library/typing.html#typing.List>[str <https://docs.python.org/3/library/stdtypes.html#str>]) -> Any <https://docs.python.org/3/library/typing.html#typing.Any>

  twine.exceptions module

Module containing exceptions raised by twine.

    exception twine.exceptions.TwineException
        Base class for all exceptions raised by twine.

    exception twine.exceptions.RedirectDetected
        A redirect was detected that the user needs to resolve.

        In some cases, requests refuses to issue a new POST request after a redirect. In order to prevent a confusing user experience, we raise this exception to allow users to know the index they're uploading to is redirecting them.

        classmethod from_args(repository_url: str <https://docs.python.org/3/library/stdtypes.html#str>, redirect_url: str <https://docs.python.org/3/library/stdtypes.html#str>) -> RedirectDetected <#twine.exceptions.RedirectDetected>

    exception twine.exceptions.PackageNotFound
        A package file was provided that could not be found on the file system.

        This is only used when attempting to register a package_file.

    exception twine.exceptions.UploadToDeprecatedPyPIDetected
        An upload attempt was detected to deprecated PyPI domains.

        The sites pypi.python.org and testpypi.python.org are deprecated.

        classmethod from_args(target_url: str <https://docs.python.org/3/library/stdtypes.html#str>, default_url: str <https://docs.python.org/3/library/stdtypes.html#str>, test_url: str <https://docs.python.org/3/library/stdtypes.html#str>) -> UploadToDeprecatedPyPIDetected <#twine.exceptions.UploadToDeprecatedPyPIDetected>
            Return an UploadToDeprecatedPyPIDetected instance.

    exception twine.exceptions.UnsupportedConfiguration
        An upload attempt was detected using features not supported by a repository.

        The features specified either in configuration or on the command-line.

        class Builder
            Build the parameters for an UnsupportedConfiguration exception.

            In the event we add additional features we are not allowing with something other than PyPI or TestPyPI, we can use a builder to accumulate them all instead of requiring someone to run multiple times to discover all unsupported configuration options.

            __init__() -> None <https://docs.python.org/3/library/constants.html#None>

            repository_url: str <https://docs.python.org/3/library/stdtypes.html#str>

            features: List <https://docs.python.org/3/library/typing.html#typing.List>[str <https://docs.python.org/3/library/stdtypes.html#str>]

            with_repository_url(repository_url: str <https://docs.python.org/3/library/stdtypes.html#str>) -> Builder <#twine.exceptions.UnsupportedConfiguration.Builder>

            with_feature(feature: str <https://docs.python.org/3/library/stdtypes.html#str>) -> Builder <#twine.exceptions.UnsupportedConfiguration.Builder>

            finalize() -> UnsupportedConfiguration <#twine.exceptions.UnsupportedConfiguration>

    exception twine.exceptions.UnreachableRepositoryURLDetected
        An upload attempt was detected to a URL without a protocol prefix.

        All repository URLs must have a protocol (e.g., https://).

    exception twine.exceptions.InvalidSigningConfiguration
        Both the sign and identity parameters must be present.

    exception twine.exceptions.InvalidSigningExecutable
        Signing executable must be installed on system.

    exception twine.exceptions.InvalidConfiguration
        Raised when configuration is invalid.

    exception twine.exceptions.InvalidDistribution
        Raised when a distribution is invalid.

    exception twine.exceptions.NonInteractive
        Raised in non-interactive mode when credentials could not be found.

    exception twine.exceptions.TrustedPublishingFailure
        Raised if we expected to use trusted publishing but couldn't.

    exception twine.exceptions.InvalidPyPIUploadURL
        Repository configuration tries to use PyPI with an incorrect URL.

        For example, <https://pypi.org> instead of <https://upload.pypi.org/legacy>.

  twine.package module

    twine.package._safe_name(name: str <https://docs.python.org/3/library/stdtypes.html#str>) -> str <https://docs.python.org/3/library/stdtypes.html#str>
        Convert an arbitrary string to a standard distribution name.

        Any runs of non-alphanumeric/. characters are replaced with a single '-'.

        Copied from pkg_resources.safe_name for compatibility with warehouse. See <https://github.com/pypa/twine/issues/743>.

    class twine.package.PackageMetadata

        metadata_version: str <https://docs.python.org/3/library/stdtypes.html#str>

        name: str <https://docs.python.org/3/library/stdtypes.html#str>

        version: str <https://docs.python.org/3/library/stdtypes.html#str>

        platform: List <https://docs.python.org/3/library/typing.html#typing.List>[str <https://docs.python.org/3/library/stdtypes.html#str>]

        summary: str <https://docs.python.org/3/library/stdtypes.html#str>

        description: str <https://docs.python.org/3/library/stdtypes.html#str>

        keywords: List <https://docs.python.org/3/library/typing.html#typing.List>[str <https://docs.python.org/3/library/stdtypes.html#str>]

        home_page: str <https://docs.python.org/3/library/stdtypes.html#str>

        author: str <https://docs.python.org/3/library/stdtypes.html#str>

        author_email: str <https://docs.python.org/3/library/stdtypes.html#str>

        license: str <https://docs.python.org/3/library/stdtypes.html#str>

        supported_platform: List <https://docs.python.org/3/library/typing.html#typing.List>[str <https://docs.python.org/3/library/stdtypes.html#str>]

        download_url: str <https://docs.python.org/3/library/stdtypes.html#str>

        classifiers: List <https://docs.python.org/3/library/typing.html#typing.List>[str <https://docs.python.org/3/library/stdtypes.html#str>]

        requires: List <https://docs.python.org/3/library/typing.html#typing.List>[str <https://docs.python.org/3/library/stdtypes.html#str>]

        provides: List <https://docs.python.org/3/library/typing.html#typing.List>[str <https://docs.python.org/3/library/stdtypes.html#str>]

        obsoletes: List <https://docs.python.org/3/library/typing.html#typing.List>[str <https://docs.python.org/3/library/stdtypes.html#str>]

        maintainer: str <https://docs.python.org/3/library/stdtypes.html#str>

        maintainer_email: str <https://docs.python.org/3/library/stdtypes.html#str>

        requires_dist: List <https://docs.python.org/3/library/typing.html#typing.List>[str <https://docs.python.org/3/library/stdtypes.html#str>]

        provides_dist: List <https://docs.python.org/3/library/typing.html#typing.List>[str <https://docs.python.org/3/library/stdtypes.html#str>]

        obsoletes_dist: List <https://docs.python.org/3/library/typing.html#typing.List>[str <https://docs.python.org/3/library/stdtypes.html#str>]

        requires_python: str <https://docs.python.org/3/library/stdtypes.html#str>

        requires_external: List <https://docs.python.org/3/library/typing.html#typing.List>[str <https://docs.python.org/3/library/stdtypes.html#str>]

        project_urls: Dict <https://docs.python.org/3/library/typing.html#typing.Dict>[str <https://docs.python.org/3/library/stdtypes.html#str>, str <https://docs.python.org/3/library/stdtypes.html#str>]

        description_content_type: str <https://docs.python.org/3/library/stdtypes.html#str>

        provides_extra: List <https://docs.python.org/3/library/typing.html#typing.List>[str <https://docs.python.org/3/library/stdtypes.html#str>]

        dynamic: List <https://docs.python.org/3/library/typing.html#typing.List>[str <https://docs.python.org/3/library/stdtypes.html#str>]

        license_expression: str <https://docs.python.org/3/library/stdtypes.html#str>

        license_file: List <https://docs.python.org/3/library/typing.html#typing.List>[str <https://docs.python.org/3/library/stdtypes.html#str>]

        comment: str <https://docs.python.org/3/library/stdtypes.html#str>

        pyversion: str <https://docs.python.org/3/library/stdtypes.html#str>

        filetype: str <https://docs.python.org/3/library/stdtypes.html#str>

        gpg_signature: Tuple <https://docs.python.org/3/library/typing.html#typing.Tuple>[str <https://docs.python.org/3/library/stdtypes.html#str>, bytes <https://docs.python.org/3/library/stdtypes.html#bytes>]

        attestations: str <https://docs.python.org/3/library/stdtypes.html#str>

        sha256_digest: str <https://docs.python.org/3/library/stdtypes.html#str>

        blake2_256_digest: str <https://docs.python.org/3/library/stdtypes.html#str>

    class twine.package.PackageFile

        __init__(filename: str <https://docs.python.org/3/library/stdtypes.html#str>, comment: str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None>, metadata: RawMetadata, python_version: str <https://docs.python.org/3/library/stdtypes.html#str>, filetype: str <https://docs.python.org/3/library/stdtypes.html#str>) -> None <https://docs.python.org/3/library/constants.html#None>

        classmethod from_filename(filename: str <https://docs.python.org/3/library/stdtypes.html#str>, comment: str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None>) -> PackageFile <#twine.package.PackageFile>

        metadata_dictionary() -> PackageMetadata <#twine.package.PackageMetadata>
            Merge multiple sources of metadata into a single dictionary.

            Includes values from filename, PKG-INFO, hashers, and signature.

        add_attestations(attestations: List <https://docs.python.org/3/library/typing.html#typing.List>[str <https://docs.python.org/3/library/stdtypes.html#str>]) -> None <https://docs.python.org/3/library/constants.html#None>

        add_gpg_signature(signature_filepath: str <https://docs.python.org/3/library/stdtypes.html#str>, signature_filename: str <https://docs.python.org/3/library/stdtypes.html#str>) -> None <https://docs.python.org/3/library/constants.html#None>

        sign(sign_with: str <https://docs.python.org/3/library/stdtypes.html#str>, identity: str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None>) -> None <https://docs.python.org/3/library/constants.html#None>

        classmethod run_gpg(gpg_args: Tuple <https://docs.python.org/3/library/typing.html#typing.Tuple>[str <https://docs.python.org/3/library/stdtypes.html#str>, ...]) -> None <https://docs.python.org/3/library/constants.html#None>

    class twine.package.Hexdigest
        Hexdigest(sha2, blake2)

        sha2: str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None>
            Alias for field number 0

        blake2: str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None>
            Alias for field number 1

        static __new__(_cls, sha2: str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None>, blake2: str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None>)
            Create new instance of Hexdigest(sha2, blake2)

        _asdict()
            Return a new dict which maps field names to their values.

        _field_defaults = {}

        _fields = ('sha2', 'blake2')

        classmethod _make(iterable)
            Make a new Hexdigest object from a sequence or iterable

        _replace(**kwds)
            Return a new Hexdigest object replacing specified fields with new values

    class twine.package.HashManager
        Manage our hashing objects for simplicity.

        This will also allow us to better test this logic.

        __init__(filename: str <https://docs.python.org/3/library/stdtypes.html#str>) -> None <https://docs.python.org/3/library/constants.html#None>
            Initialize our manager and hasher objects.

        _sha2_update(content: bytes <https://docs.python.org/3/library/stdtypes.html#bytes>) -> None <https://docs.python.org/3/library/constants.html#None>

        _sha2_hexdigest() -> str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None>

        _blake_update(content: bytes <https://docs.python.org/3/library/stdtypes.html#bytes>) -> None <https://docs.python.org/3/library/constants.html#None>

        _blake_hexdigest() -> str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None>

        hash() -> None <https://docs.python.org/3/library/constants.html#None>
            Hash the file contents.

        hexdigest() -> Hexdigest <#twine.package.Hexdigest>
            Return the hexdigest for the file.

  twine.repository module

    class twine.repository.Repository

        __init__(repository_url: str <https://docs.python.org/3/library/stdtypes.html#str>, username: str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None>, password: str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None>, disable_progress_bar: bool <https://docs.python.org/3/library/functions.html#bool> = False) -> None <https://docs.python.org/3/library/constants.html#None>

        close() -> None <https://docs.python.org/3/library/constants.html#None>

        static _convert_metadata_to_list_of_tuples(data: PackageMetadata <#twine.package.PackageMetadata>) -> List <https://docs.python.org/3/library/typing.html#typing.List>[Tuple <https://docs.python.org/3/library/typing.html#typing.Tuple>[str <https://docs.python.org/3/library/stdtypes.html#str>, Any <https://docs.python.org/3/library/typing.html#typing.Any>]]

        set_certificate_authority(cacert: str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None>) -> None <https://docs.python.org/3/library/constants.html#None>

        set_client_certificate(clientcert: str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None>) -> None <https://docs.python.org/3/library/constants.html#None>

        register(package: PackageFile <#twine.package.PackageFile>) -> Response <https://requests.readthedocs.io/en/latest/api.html#requests.Response>

        _upload(package: PackageFile <#twine.package.PackageFile>) -> Response <https://requests.readthedocs.io/en/latest/api.html#requests.Response>

        upload(package: PackageFile <#twine.package.PackageFile>, max_redirects: int <https://docs.python.org/3/library/functions.html#int> = 5) -> Response <https://requests.readthedocs.io/en/latest/api.html#requests.Response>

        package_is_uploaded(package: PackageFile <#twine.package.PackageFile>, bypass_cache: bool <https://docs.python.org/3/library/functions.html#bool> = False) -> bool <https://docs.python.org/3/library/functions.html#bool>
            Determine if a package has been uploaded to PyPI already.

            Warning:
                This does not support indexes other than PyPI or TestPyPI

            Parameters

                •   package (PackageFile <#twine.package.PackageFile>) -- The package file that will otherwise be uploaded.

                •   bypass_cache (bool <https://docs.python.org/3/library/functions.html#bool>) -- Force a request to PyPI.

            Returns
                True if package has already been uploaded, False otherwise

            Return type
                bool <https://docs.python.org/3/library/functions.html#bool>

        release_urls(packages: List <https://docs.python.org/3/library/typing.html#typing.List>[PackageFile <#twine.package.PackageFile>]) -> Set <https://docs.python.org/3/library/typing.html#typing.Set>[str <https://docs.python.org/3/library/stdtypes.html#str>]

        verify_package_integrity(package: PackageFile <#twine.package.PackageFile>) -> None <https://docs.python.org/3/library/constants.html#None>

  twine.settings module

Module containing logic for handling settings.

    class twine.settings.Settings
        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 <https://docs.python.org/3/library/exceptions.html#TypeError>. Instead, you would want

                Settings(sign=True, username='fakeusername')

        __init__(*, attestations: bool <https://docs.python.org/3/library/functions.html#bool> = False, sign: bool <https://docs.python.org/3/library/functions.html#bool> = False, sign_with: str <https://docs.python.org/3/library/stdtypes.html#str> = 'gpg', identity: str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None> = None, username: str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None> = None, password: str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None> = None, non_interactive: bool <https://docs.python.org/3/library/functions.html#bool> = False, comment: str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None> = None, config_file: str <https://docs.python.org/3/library/stdtypes.html#str> = utils.DEFAULT_CONFIG_FILE, skip_existing: bool <https://docs.python.org/3/library/functions.html#bool> = False, cacert: str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None> = None, client_cert: str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None> = None, repository_name: str <https://docs.python.org/3/library/stdtypes.html#str> = 'pypi', repository_url: str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None> = None, verbose: bool <https://docs.python.org/3/library/functions.html#bool> = False, disable_progress_bar: bool <https://docs.python.org/3/library/functions.html#bool> = False, **ignored_kwargs: Any <https://docs.python.org/3/library/typing.html#typing.Any>) -> None <https://docs.python.org/3/library/constants.html#None>
            Initialize our settings instance.

            Parameters

                •   attestations -- Whether the package file should be uploaded with attestations.

                •   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: str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None>

        property password: str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None>

        _allow_noninteractive() -> AbstractContextManager <https://docs.python.org/3/library/contextlib.html#contextlib.AbstractContextManager>[None <https://docs.python.org/3/library/constants.html#None>]
            Bypass NonInteractive error when client cert is present.

        property verbose: bool <https://docs.python.org/3/library/functions.html#bool>

        static register_argparse_arguments(parser: ArgumentParser <https://docs.python.org/3/library/argparse.html#argparse.ArgumentParser>) -> None <https://docs.python.org/3/library/constants.html#None>
            Register the arguments for argparse.

        classmethod from_argparse(args: Namespace <https://docs.python.org/3/library/argparse.html#argparse.Namespace>) -> Settings <#twine.settings.Settings>
            Generate the Settings from parsed arguments.

        _handle_package_signing(sign: bool <https://docs.python.org/3/library/functions.html#bool>, sign_with: str <https://docs.python.org/3/library/stdtypes.html#str>, identity: str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None>) -> None <https://docs.python.org/3/library/constants.html#None>

        _handle_repository_options(repository_name: str <https://docs.python.org/3/library/stdtypes.html#str>, repository_url: str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None>) -> None <https://docs.python.org/3/library/constants.html#None>

        _handle_certificates(cacert: str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None>, client_cert: str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None>) -> None <https://docs.python.org/3/library/constants.html#None>

        verify_feature_capability() -> None <https://docs.python.org/3/library/constants.html#None>
            Verify configured settings are supported for the configured repository.

            This presently checks: - --skip-existing was only provided for PyPI and TestPyPI

            Raises
                twine.exceptions.UnsupportedConfiguration <#twine.exceptions.UnsupportedConfiguration> -- The configured features are not available with the configured repository.

        check_repository_url() -> None <https://docs.python.org/3/library/constants.html#None>
            Verify we are not using legacy PyPI.

            Raises
                twine.exceptions.UploadToDeprecatedPyPIDetected <#twine.exceptions.UploadToDeprecatedPyPIDetected> -- The configured repository URL is for legacy PyPI.

        create_repository() -> Repository <#twine.repository.Repository>
            Create a new repository for uploading.

  twine.utils module

    twine.utils.get_config(path: str <https://docs.python.org/3/library/stdtypes.html#str>) -> Dict <https://docs.python.org/3/library/typing.html#typing.Dict>[str <https://docs.python.org/3/library/stdtypes.html#str>, Dict <https://docs.python.org/3/library/typing.html#typing.Dict>[str <https://docs.python.org/3/library/stdtypes.html#str>, str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None>]]
        Read repository configuration from a file (i.e. ~/.pypirc).

        Format: <https://packaging.python.org/specifications/pypirc/>

        If the default config file doesn't exist, return a default configuration for pypyi and testpypi.

    twine.utils.sanitize_url(url: str <https://docs.python.org/3/library/stdtypes.html#str>) -> str <https://docs.python.org/3/library/stdtypes.html#str>
        Sanitize a URL.

        Sanitize URLs, removing any user:password combinations and replacing them with asterisks. Returns the original URL if the string is a non-matching pattern.

        Parameters
            url -- str containing a URL to sanitize.

        return:
            str either sanitized or as entered depending on pattern match.

    twine.utils._validate_repository_url(repository_url: str <https://docs.python.org/3/library/stdtypes.html#str>) -> None <https://docs.python.org/3/library/constants.html#None>
        Validate the given url for allowed schemes and components.

    twine.utils.get_repository_from_config(config_file: str <https://docs.python.org/3/library/stdtypes.html#str>, repository: str <https://docs.python.org/3/library/stdtypes.html#str>, repository_url: str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None> = None) -> Dict <https://docs.python.org/3/library/typing.html#typing.Dict>[str <https://docs.python.org/3/library/stdtypes.html#str>, str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None>]
        Get repository config command-line values or the .pypirc file.

    twine.utils._config_from_repository_url(url: str <https://docs.python.org/3/library/stdtypes.html#str>) -> Dict <https://docs.python.org/3/library/typing.html#typing.Dict>[str <https://docs.python.org/3/library/stdtypes.html#str>, str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None>]

    twine.utils.normalize_repository_url(url: str <https://docs.python.org/3/library/stdtypes.html#str>) -> str <https://docs.python.org/3/library/stdtypes.html#str>

    twine.utils.get_file_size(filename: str <https://docs.python.org/3/library/stdtypes.html#str>) -> str <https://docs.python.org/3/library/stdtypes.html#str>
        Return the size of a file in KB, or MB if >= 1024 KB.

    twine.utils.check_status_code(response: Response <https://requests.readthedocs.io/en/latest/api.html#requests.Response>, verbose: bool <https://docs.python.org/3/library/functions.html#bool>) -> None <https://docs.python.org/3/library/constants.html#None>
        Generate a helpful message based on the response from the repository.

        Raise a custom exception for recognized errors. Otherwise, print the response content (based on the verbose option) before re-raising the HTTPError.

    twine.utils.get_userpass_value(cli_value: str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None>, config: Dict <https://docs.python.org/3/library/typing.html#typing.Dict>[str <https://docs.python.org/3/library/stdtypes.html#str>, str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None>], key: str <https://docs.python.org/3/library/stdtypes.html#str>, prompt_strategy: Callable <https://docs.python.org/3/library/typing.html#typing.Callable>[[], str <https://docs.python.org/3/library/stdtypes.html#str>] | None <https://docs.python.org/3/library/constants.html#None> = None) -> str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None>
        Get a credential (e.g. a username or password) from the configuration.

        Uses the following rules:

        1.  If cli_value is specified, use that.

        2.  If config[key] is specified, use that.

        3.  If prompt_strategy is specified, use its return value.

        4.  Otherwise return None

        Parameters

            •   cli_value -- The value supplied from the command line.

            •   config -- A dictionary of repository configuration values.

            •   key -- The credential to look up in config, e.g. "username" or "password".

            •   prompt_strategy -- An argumentless function to get the value, e.g. from keyring or by prompting the user.

        Returns
            The credential value, i.e. the username or password.

    twine.utils.get_cacert(cli_value: str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None>, config: Dict <https://docs.python.org/3/library/typing.html#typing.Dict>[str <https://docs.python.org/3/library/stdtypes.html#str>, str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None>], *, key: str <https://docs.python.org/3/library/stdtypes.html#str> = 'ca_cert', prompt_strategy: Callable <https://docs.python.org/3/library/typing.html#typing.Callable>[[], str <https://docs.python.org/3/library/stdtypes.html#str>] | None <https://docs.python.org/3/library/constants.html#None> = None) -> str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None>
        Get the CA bundle via get_userpass_value().

    twine.utils.get_clientcert(cli_value: str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None>, config: Dict <https://docs.python.org/3/library/typing.html#typing.Dict>[str <https://docs.python.org/3/library/stdtypes.html#str>, str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None>], *, key: str <https://docs.python.org/3/library/stdtypes.html#str> = 'client_cert', prompt_strategy: Callable <https://docs.python.org/3/library/typing.html#typing.Callable>[[], str <https://docs.python.org/3/library/stdtypes.html#str>] | None <https://docs.python.org/3/library/constants.html#None> = None) -> str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None>
        Get the client certificate via get_userpass_value().

    twine.utils.make_requests_session() -> Session <https://requests.readthedocs.io/en/latest/api.html#requests.Session>
        Prepare a requests Session with retries & twine's user-agent string.

    class twine.utils.EnvironmentDefault
        Get values from environment variable.

        __init__(env: str <https://docs.python.org/3/library/stdtypes.html#str>, required: bool <https://docs.python.org/3/library/functions.html#bool> = True, default: str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None> = None, **kwargs: Any <https://docs.python.org/3/library/typing.html#typing.Any>) -> None <https://docs.python.org/3/library/constants.html#None>

    class twine.utils.EnvironmentFlag
        Set boolean flag from environment variable.

        __init__(env: str <https://docs.python.org/3/library/stdtypes.html#str>, **kwargs: Any <https://docs.python.org/3/library/typing.html#typing.Any>) -> None <https://docs.python.org/3/library/constants.html#None>

        static bool_from_env(val: str <https://docs.python.org/3/library/stdtypes.html#str> | None <https://docs.python.org/3/library/constants.html#None>) -> bool <https://docs.python.org/3/library/functions.html#bool>
            Allow '0' and 'false' and 'no' to be False.

  twine.wheel module

    class twine.wheel.Wheel

        __init__(filename: str <https://docs.python.org/3/library/stdtypes.html#str>) -> None <https://docs.python.org/3/library/constants.html#None>

        property py_version: str <https://docs.python.org/3/library/stdtypes.html#str>

        static find_candidate_metadata_files(names: List <https://docs.python.org/3/library/typing.html#typing.List>[str <https://docs.python.org/3/library/stdtypes.html#str>]) -> List <https://docs.python.org/3/library/typing.html#typing.List>[List <https://docs.python.org/3/library/typing.html#typing.List>[str <https://docs.python.org/3/library/stdtypes.html#str>]]
            Filter files that may be METADATA files.

        read() -> bytes <https://docs.python.org/3/library/stdtypes.html#bytes>

  Where Twine gets configuration and credentials

A user can set the repository URL, username, and/or password via command line, .pypirc files, environment variables, and keyring.

ADDING A MAINTAINER

A checklist for adding a new maintainer to the project.

    1.  Add them as a Member in the GitHub repo settings.

    2.  Get them Test PyPI and canon PyPI usernames and add them as a Maintainer on our Test PyPI project <https://test.pypi.org/manage/project/twine/collaboration/> and canon PyPI <https://pypi.org/manage/project/twine/collaboration/>.

MAKING A NEW RELEASE

A checklist for creating, testing, and distributing a new version.

    1.  Choose a version number, and create a new branch

                VERSION=3.4.2

                git switch -c release-$VERSION

    2.  Update docs/changelog.rst

                tox -e changelog -- --version $VERSION

                git commit -am "Update changelog for $VERSION"

    3.  Open a pull request for review

    4.  Merge the pull request, and ensure the GitHub Actions <https://github.com/pypa/twine/actions> build passes

    5.  Create a new git tag for the version

                git switch main

                git pull --ff-only upstream main

                git tag -m "Release v$VERSION" $VERSION

    6.  Push to start the release, and watch it in GitHub Actions <https://github.com/pypa/twine/actions>

                git push upstream $VERSION

    7.  View the new release on PyPI <https://pypi.org/project/twine/>

FUTURE DEVELOPMENT

See our open issues <https://github.com/pypa/twine/issues>.

In the future, pip and twine may merge into a single tool; see ongoing discussion <https://github.com/pypa/packaging-problems/issues/60>.

Twine is a utility for publishing <https://packaging.python.org/tutorials/packaging-projects/> Python packages to PyPI <https://pypi.org> and other repositories <https://packaging.python.org/glossary/#term-Package-Index>. It provides build system independent uploads of source and binary distribution artifacts <https://packaging.python.org/glossary/#term-Distribution-Package> for both new and existing projects <https://packaging.python.org/glossary/#term-Project>.

WHY SHOULD I USE THIS?

The goal of Twine is to improve PyPI interaction by improving security and testability.

The biggest reason to use Twine is that it securely authenticates you to PyPI over HTTPS using a verified connection, regardless of the underlying Python version. Meanwhile, python setup.py upload will only work correctly and securely if your build system, Python version, and underlying operating system are configured properly.

Secondly, Twine encourages you to build your distribution files. python setup.py upload only allows you to upload a package as a final step after building with distutils or setuptools, within the same command invocation. This means that you cannot test the exact file you're going to upload to PyPI to ensure that it works before uploading it.

Finally, Twine allows you to pre-sign your files and pass the .asc files into the command line invocation (twine upload myproject-1.0.1.tar.gz myproject-1.0.1.tar.gz.asc). This enables you to be assured that you're typing your gpg passphrase into gpg itself and not anything else, since you will be the one directly executing gpg --detach-sign -a <filename>.

FEATURES

    •   Verified HTTPS connections

    •   Uploading doesn't require executing setup.py

    •   Uploading files that have already been created, allowing testing of distributions before release

    •   Supports uploading any packaging format (including wheels <https://packaging.python.org/glossary/#term-Wheel>)

INSTALLATION

            pip install twine

USING TWINE

    1.  Create some distributions in the normal way:

                python -m build

    2.  Upload to Test PyPI <https://packaging.python.org/guides/using-testpypi/> and verify things look right:

                twine upload -r testpypi dist/*

    Twine will prompt for your username and password.

    3.  Upload to PyPI <https://pypi.org>:

                twine upload dist/*

    4.  Done!

Note:
        Like many other command line tools, Twine does not show any characters when you enter your password.

        If you're using Windows and trying to paste your username, password, or token in the Command Prompt or PowerShell, Ctrl-V and Shift+Insert won't work. Instead, you can use "Edit > Paste" from the window menu, or enable "Use Ctrl+Shift+C/V as Copy/Paste" in "Properties". This is a known issue <https://bugs.python.org/issue37426> with Python's getpass module.

More documentation on using Twine to upload packages to PyPI is in the Python Packaging User Guide <https://packaging.python.org/tutorials/packaging-projects/>.

COMMANDS

  twine upload

Uploads one or more distributions to a repository.

            usage: twine upload [-h] [-r REPOSITORY] [--repository-url REPOSITORY_URL]
                                [--attestations] [-s] [--sign-with SIGN_WITH]
                                [-i IDENTITY] [-u USERNAME] [-p PASSWORD]
                                [--non-interactive] [-c COMMENT]
                                [--config-file CONFIG_FILE] [--skip-existing]
                                [--cert path] [--client-cert path] [--verbose]
                                [--disable-progress-bar]
                                dist [dist ...]

            positional arguments:
              dist                  The distribution files to upload to the repository
                                    (package index). Usually dist/* . May additionally
                                    contain a .asc file to include an existing signature
                                    with the file upload.

            options:
              -h, --help            show this help message and exit
              -r, --repository REPOSITORY
                                    The repository (package index) to upload the package
                                    to. Should be a section in the config file [default:
                                    pypi]. (Can also be set via TWINE_REPOSITORY
                                    environment variable.)
              --repository-url REPOSITORY_URL
                                    The repository (package index) URL to upload the
                                    package to. This overrides --repository. (Can also be
                                    set via TWINE_REPOSITORY_URL environment variable.)
              --attestations        Upload each file's associated attestations.
              -s, --sign            Sign files to upload using GPG.
              --sign-with SIGN_WITH
                                    GPG program used to sign uploads [default: gpg].
              -i, --identity IDENTITY
                                    GPG identity used to sign files.
              -u, --username USERNAME
                                    The username to authenticate to the repository
                                    (package index) as. Has no effect on PyPI or TestPyPI.
                                    (Can also be set via TWINE_USERNAME environment
                                    variable.)
              -p, --password PASSWORD
                                    The password to authenticate to the repository
                                    (package index) with. (Can also be set via
                                    TWINE_PASSWORD environment variable.)
              --non-interactive     Do not interactively prompt for username/password if
                                    the required credentials are missing. (Can also be set
                                    via TWINE_NON_INTERACTIVE environment variable.)
              -c, --comment COMMENT
                                    The comment to include with the distribution file.
              --config-file CONFIG_FILE
                                    The .pypirc config file to use.
              --skip-existing       Continue uploading files if one already exists. (Only
                                    valid when uploading to PyPI. Other implementations
                                    may not support this.)
              --cert path           Path to alternate CA bundle (can also be set via
                                    TWINE_CERT environment variable).
              --client-cert path    Path to SSL client certificate, a single file
                                    containing the private key and the certificate in PEM
                                    format.
              --verbose             Show verbose output.
              --disable-progress-bar
                                    Disable the progress bar.

  twine check

Checks whether your distribution's long description will render correctly on PyPI.

            usage: twine check [-h] [--strict] dist [dist ...]

            positional arguments:
              dist        The distribution files to check, usually dist/*

            options:
              -h, --help  show this help message and exit
              --strict    Fail on warnings

  twine register

Pre-register a name with a repository before uploading a distribution.

Warning:
        Pre-registration is not supported on PyPI <https://packaging.python.org/guides/migrating-to-pypi-org/#registering-package-names-metadata>, so the register command is only necessary if you are using a different repository that requires it. See issue #1627 on Warehouse <https://github.com/pypi/warehouse/issues/1627> (the software running on PyPI) for more details.

            usage: twine register [-h] [-r REPOSITORY] [--repository-url REPOSITORY_URL]
                                  [--attestations] [-s] [--sign-with SIGN_WITH]
                                  [-i IDENTITY] [-u USERNAME] [-p PASSWORD]
                                  [--non-interactive] [-c COMMENT]
                                  [--config-file CONFIG_FILE] [--skip-existing]
                                  [--cert path] [--client-cert path] [--verbose]
                                  [--disable-progress-bar]
                                  package

            register operation is not required with PyPI.org

            positional arguments:
              package               File from which we read the package metadata.

            options:
              -h, --help            show this help message and exit
              -r, --repository REPOSITORY
                                    The repository (package index) to upload the package
                                    to. Should be a section in the config file [default:
                                    pypi]. (Can also be set via TWINE_REPOSITORY
                                    environment variable.)
              --repository-url REPOSITORY_URL
                                    The repository (package index) URL to upload the
                                    package to. This overrides --repository. (Can also be
                                    set via TWINE_REPOSITORY_URL environment variable.)
              --attestations        Upload each file's associated attestations.
              -s, --sign            Sign files to upload using GPG.
              --sign-with SIGN_WITH
                                    GPG program used to sign uploads [default: gpg].
              -i, --identity IDENTITY
                                    GPG identity used to sign files.
              -u, --username USERNAME
                                    The username to authenticate to the repository
                                    (package index) as. Has no effect on PyPI or TestPyPI.
                                    (Can also be set via TWINE_USERNAME environment
                                    variable.)
              -p, --password PASSWORD
                                    The password to authenticate to the repository
                                    (package index) with. (Can also be set via
                                    TWINE_PASSWORD environment variable.)
              --non-interactive     Do not interactively prompt for username/password if
                                    the required credentials are missing. (Can also be set
                                    via TWINE_NON_INTERACTIVE environment variable.)
              -c, --comment COMMENT
                                    The comment to include with the distribution file.
              --config-file CONFIG_FILE
                                    The .pypirc config file to use.
              --skip-existing       Continue uploading files if one already exists. (Only
                                    valid when uploading to PyPI. Other implementations
                                    may not support this.)
              --cert path           Path to alternate CA bundle (can also be set via
                                    TWINE_CERT environment variable).
              --client-cert path    Path to SSL client certificate, a single file
                                    containing the private key and the certificate in PEM
                                    format.
              --verbose             Show verbose output.
              --disable-progress-bar
                                    Disable the progress bar.

CONFIGURATION

Twine can read repository configuration from a .pypirc file, either in your home directory, or provided with the --config-file option. For details on writing and using .pypirc, see the specification <https://packaging.python.org/specifications/pypirc/> in the Python Packaging User Guide.

  Environment Variables

Twine also supports configuration via environment variables. Options passed on the command line will take precedence over options set via environment variables. Definition via environment variable is helpful in environments where it is not convenient to create a .pypirc file (for example, on a CI/build server).

    •   TWINE_USERNAME - the username to use for authentication to the repository.

    •   TWINE_PASSWORD - the password to use for authentication to the repository.

    •   TWINE_REPOSITORY - the repository configuration, either defined as a section in .pypirc or provided as a full URL.

    •   TWINE_REPOSITORY_URL - the repository URL to use.

    •   TWINE_CERT - custom CA certificate to use for repositories with self-signed or untrusted certificates.

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

  Proxy Support

Twine can be configured to use a proxy by setting environment variables. For example, to use a proxy for just the twine command, without export-ing it for other tools:

            HTTPS_PROXY=socks5://user:pass@host:port twine upload dist/*

For more information, see the Requests documentation on Proxies <https://requests.readthedocs.io/en/latest/user/advanced.html#proxies> and SOCKS <https://requests.readthedocs.io/en/latest/user/advanced.html#socks>, and an in-depth article about proxy environment variables <https://about.gitlab.com/blog/2021/01/27/we-need-to-talk-no-proxy/>.

KEYRING SUPPORT

Instead of typing in your password every time you upload a distribution, Twine allows storing a username and password securely using keyring <https://pypi.org/project/keyring/>. Keyring is installed with Twine but for some systems (Linux mainly) may require additional installation steps <https://pypi.org/project/keyring/#installation-linux>.

Once Twine is installed, use the keyring program to set a username and password to use for each repository to which you may upload.

For example, to set an API token for PyPI:

            keyring set https://upload.pypi.org/legacy/ __token__

and paste your API key when prompted.

For a different repository, replace the URL with the relevant repository URL. For example, for Test PyPI, use https://test.pypi.org/legacy/.

Note:
        If you are using Linux in a headless environment (such as on a server) you'll need to do some additional steps to ensure that Keyring can store secrets securely. See Using Keyring on headless systems <https://keyring.readthedocs.io/en/latest/#using-keyring-on-headless-linux-systems>.

  Disabling Keyring

In most cases, simply not setting a password with keyring will allow Twine to fall back to prompting for a password. In some cases, the presence of Keyring will cause unexpected or undesirable prompts from the backing system. In these cases, it may be desirable to disable Keyring altogether. To disable Keyring, run:

            keyring --disable

See Twine issue #338 <https://github.com/pypa/twine/issues/338> for discussion and background.

Author
Donald Stufft, Individual contributors

Copyright
2019, Donald Stufft and individual contributors