Skip to content
Back to top
View this page

# twine.commands.upload module

Module containing the logic for `twine upload`.

twine.commands.upload.skip_upload(response: Response, skip_existing: bool, package: PackageFile) → 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, signatures: Dict[str, str], attestations: List[str], upload_settings: Settings) → 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, dists: List[str]) → 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 – The upload failed due to a configuration error.

    - requests.HTTPError – The repository responded with an error.

twine.commands.upload.main(args: List[str]) → None

  Execute the `upload` command.

  Parameters:

    args – The command-line arguments.