U &Ì.eôã@s”ddlZddlZddlZddlZddlmZddlmZmZm Z ddl m Z ddl m Z mZddlmZddlmZddlmZGd d „d eƒZdS) éN)Ústandard_b64encode)ÚurlopenÚRequestÚ HTTPError)Úurlparse)ÚDistutilsErrorÚDistutilsOptionError)Ú PyPIRCCommand)Úspawn)Úlogc@sJeZdZdZejddgZejdgZdd„Zdd„Zd d „Z d d „Z d S)Úuploadzupload binary package to PyPI)ÚsignÚszsign files to upload using gpg)z identity=ÚizGPG identity used to sign filesr cCs,t |¡d|_d|_d|_d|_d|_dS)NÚrF)r Úinitialize_optionsÚusernameÚpasswordÚ show_responser Úidentity)Úself©rú0/usr/lib64/python3.8/distutils/command/upload.pyr s  zupload.initialize_optionscCsrt |¡|jr|jstdƒ‚| ¡}|ikrV|d|_|d|_|d|_|d|_ |jsn|j jrn|j j|_dS)Nz.Must use --sign for --identity to have meaningrrÚ repositoryÚrealm) r Úfinalize_optionsrr rZ _read_pypircrrrrÚ distribution)rZconfigrrrr(s  ÿ    zupload.finalize_optionscCs:|jjsd}t|ƒ‚|jjD]\}}}| |||¡qdS)NzHMust create and upload files in one command (e.g. setup.py sdist upload))rZ dist_filesrÚ upload_file)rÚmsgÚcommandÚ pyversionÚfilenamerrrÚrun:s z upload.runc"Cst|jƒ\}}}}}} |s"|s"| r0td|jƒ‚|dkrDtd|ƒ‚|jr|ddd|g} |jrnd|jg| dd…<t| |jd t|d ƒ} z |   ¡} W5|  ¡X|j j } d d |   ¡|   ¡tj |¡| f||t | ¡ ¡d |  ¡|  ¡|  ¡|  ¡|  ¡|  ¡|  ¡|  ¡|  ¡|  ¡|  ¡|  ¡|   ¡dœ}zt !| ¡ ¡}WnPt"k rŒ}z0d|}| #|t$j%¡ddl&m'}|ƒs|‚W5d}~XYn X||d<d|d<|jrÜt|dd ƒ"} tj |¡d|   ¡f|d<W5QRX|j(d|j) *d¡}dt+|ƒ ,d¡}d}d| *d¡}|d}t- .¡}| /¡D]”\}}d|}t0|t1ƒsP|g}|D]j}t2|ƒt3kr€|d|d7}|d}nt4|ƒ *d ¡}| 5|¡| 5| *d ¡¡| 5d!¡| 5|¡qTq.| 5|¡| 6¡}d"||jf}| #|t$j%¡d#|t4t7|ƒƒ|d$œ}t8|j||d%}zt9|ƒ}| :¡}|j;} Wnftk rš}z| #t4|ƒt$j?¡‚W5d}~XYnX|d&krî| #d'|| ft$j%¡|j@r| A|¡}!d( Bd)|!d)f¡}| #|t$j%¡n"d*|| f}| #|t$j?¡tC|ƒ‚dS)+NzIncompatible url %s)ZhttpZhttpszunsupported schema Zgpgz --detach-signz-az --local-useré)Údry_runÚrbZ file_uploadÚ1z1.0)z:actionZprotocol_versionÚnameÚversionÚcontentZfiletyper Z sha256_digestZmetadata_versionZsummaryZ home_pageZauthorZ author_emailÚlicenseÚ descriptionÚkeywordsÚplatformZ classifiersZ download_urlZprovidesZrequiresZ obsoletesz#calculating md5 checksum failed: %sr)Ú get_fips_modeZ md5_digestrZcommentz.ascZ gpg_signatureú:ÚasciizBasic z3--------------GHSKFJDLGDS7543FJKLFHRE75642756743254s --s-- z+ Content-Disposition: form-data; name="%s"z; filename="%s"ézutf-8s zSubmitting %s to %sz multipart/form-data; boundary=%s)z Content-typezContent-lengthZ Authorization)ÚdataÚheaderséÈzServer response (%s): %sÚ zK---------------------------------------------------------------------------zUpload failed (%s): %s)DrrÚAssertionErrorr rr r$ÚopenÚcloseÚreadrZmetadataZget_nameZ get_versionÚosÚpathÚbasenameÚhashlibZsha256Z hexdigestZget_descriptionZget_urlZ get_contactZget_contact_emailZ get_licenceZget_long_descriptionZ get_keywordsZ get_platformsZget_classifiersZget_download_urlZ get_providesZ get_requiresZ get_obsoletesZmd5Ú ValueErrorZannouncer ÚINFOZ_hashlibr.rrÚencoderÚdecodeÚioÚBytesIOÚitemsÚ isinstanceÚlistÚtypeÚtupleÚstrÚwriteÚgetvalueÚlenrrZgetcoderrÚcodeÚOSErrorZERRORrZ_read_pypi_responseÚjoinr)"rrr r!ZschemaZnetlocZurlZparamsZqueryZ fragmentsZgpg_argsÚfr)Úmetar2ZdigestÚerr.Z user_passZauthÚboundaryZ sep_boundaryZ end_boundaryZbodyÚkeyÚvalueÚtitler3ZrequestÚresultZstatusÚreasonÚtextrrrrBsÖÿ   ÿ    â! ÿ      ýÿ  ÿ  zupload.upload_fileN) Ú__name__Ú __module__Ú __qualname__r+r Z user_optionsZboolean_optionsrrr"rrrrrr sý r )r:rBr-r=Úbase64rZurllib.requestrrrZ urllib.parserZdistutils.errorsrrZdistutils.corer Zdistutils.spawnr Z distutilsr r rrrrÚs