twine.commands.upload module¶
Module containing the logic for twine upload
.
- twine.commands.upload.skip_upload(response: Response, skip_existing: bool, package: PackageFile) bool [source]¶
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 ofresponse
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, otherwiseFalse
.
- twine.commands.upload._make_package(filename: str, signatures: Dict[str, str], attestations: List[str], upload_settings: Settings) PackageFile [source]¶
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.
- class twine.commands.upload.Inputs[source]¶
Represents structured user inputs.
- static __new__(_cls, dists: List[str], signatures: Dict[str, str], attestations_by_dist: Dict[str, List[str]])¶
Create new instance of Inputs(dists, signatures, attestations_by_dist)
- _asdict()¶
Return a new dict which maps field names to their values.
- _field_defaults = {}¶
- _fields = ('dists', 'signatures', 'attestations_by_dist')¶
- classmethod _make(iterable)¶
Make a new Inputs object from a sequence or iterable
- _replace(**kwds)¶
Return a new Inputs object replacing specified fields with new values
- twine.commands.upload._split_inputs(inputs: List[str]) Inputs [source]¶
Split the unstructured list of input files provided by the user into groups.
Three groups are returned: upload files (i.e. dists), signatures, and attestations.
Upload files are returned as a linear list, signatures are returned as a dict of
basename -> path
, and attestations are returned as a dict ofdist-path -> [attestation-path]
.
- twine.commands.upload.upload(upload_settings: Settings, dists: List[str]) None [source]¶
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
isTrue
, 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.