Y3@skdZddlZddlZddlZddlZddlZddlmZddl m Z ddl m Z m Z mZmZmZddlmZdd ZddlZGd d d eZd d ZeddZdeddZddZddZdddZdddddddZddZddZd d!Zd"d#Z dS)$z Wheel command-line utility. N)iglob) signatures)urlsafe_b64decodeurlsafe_b64encodenativebinarymatches_requirement) WheelFilec Cs>yddl}Wn'tk r9tdj|YnXdS)Nrz/'{0}' needs pkg_resources (part of setuptools).) pkg_resources ImportError RuntimeErrorformat)namer r4/tmp/pip-build-3puug3g5/wheel/wheel/tool/__init__.pyrequire_pkgresourcess rc@seZdZdS) WheelErrorN)__name__ __module__ __qualname__rrrrrs rc Csiy5ddlm}ddl}|jjs4tWn$ttfk r[tdYnX|j|fS)Nr)keysrzQInstall wheel[signatures] (requires keyring, keyrings.alt, pyxdg) for signatures.) rrkeyring get_keyringpriorityAssertionErrorr r WheelKeys)rrrrrrs rc Cs"|\}}tj}|j}|j}tt|j}tt|j}|j}|j d||t j j dj |t j j dj ||jd|} | |krtdt j j dj ||jd||jd||jdS)z#Generate a public/private key pair.wheelz$Created Ed25519 keypair with vk={0} z in {0!r} z1Keyring is broken. Could not retrieve secret key.z.Trusting {0} to sign and verify all packages. +N)r get_ed25519llloadZcrypto_sign_keypairrrvkskrZ set_passwordsysstdoutwriter get_passwordrZ add_signertrustsave) rrr ed25519llwkkeypairr!r"krZsk2rrrkeygen%s"     r-FcCs|\}}tj}t|dd}|j}|jjd}|j|d} tjj dj || d| d} |j } | j d| } |j tt| tt| } |jd}|jd }||jjkrtd |jj|}d d tttj|ji}tj|| }|jj|tj|d d|jjdS)z Sign a wheelappendTrrzSigning {0} with {1} rz/RECORDz /RECORD.jwszWheel is already signed.hashzsha256= sort_keysN)rrr r parsed_filenamegroupZsignersr#r$r%rrr&ZKeypairrr distinfo_namezipfilenamelistrreadrrhashlibsha256digestsignwritestrjsondumpsclose) wheelfilereplacerrrr)wfr*rZ sign_withr!r,r"r+Z record_namesig_nameZ record_datapayloadsigrrrr;>s*       +"r;cCssddl}|jj|d}|j}t|oL|djjds[td|j|j dS)a$ Remove RECORD.jws from a wheel by truncating the zip file. RECORD.jws must be at the end of the archive. The zip file must be an ordinary archive, with the compressed files and the directory in the same order, and without any non-zip content after the truncation point. rNar/z /RECORD.jwsz'RECORD.jws not found at end of archive.) Z wheel.installinstallZVerifyingZipFileinfolistlenfilenameendswithrpopr?)r@rZvzfinforrrunsign\s  "  rOcCst|}|jd}tjt|jj|j}tj |}t j j dt j j tj|ddt j j ddS)zVerify a wheel. The signature will be verified for internal consistency ONLY and printed. Wheel's own unpack/install commands verify the manifest against the signature and file contents. z /RECORD.jwsz&Signatures are internally consistent. indentr N)r r4r=loadsrr5openr7rverifyr#stderrr%r$r>)r@rBrCrEZverifiedrrrrTls  'rT.cCsht|}|jjd}tjj||}tjjd||j j ||j j dS)aUnpack a wheel. Wheel content will be unpacked to {dest}/{name}-{ver}, where {name} is the package name and {ver} its version. :param wheelfile: The path to the wheel. :param dest: Destination directory (default to current directory). nameverzUnpacking to: %s N) r r2r3ospathjoinr#rUr%r5 extractallr?)r@destrBrWZ destinationrrrunpack{s r]c Csw|s?tjd}|r0|jtj}ntjjg}g}xh|D]`}xWtj|D]F} | jdrbttjj || } | j rb|j | qbWqLW|r*tjj |sx<|D]4}tjj ||} tjj | r| }PqWt |} |j| WdQRXg} x|D]}|jdrtjj |rt|} | j sy|r| j | qdj|}t|q7tdj|q7t||}|stdj|| j t|q7W|rtjjd|r dSxP| D]H} |rRtjjdj| jq'| jd || jjq'WdS) aInstall wheels. :param requirements: A list of requirements or wheel files to install. :param requirements_file: A file containing requirements to install. :param wheel_dirs: A list of directories to search for wheels. :param force: Install a wheel file even if it is not compatible. :param list_files: Only list the files to install, don't install them. :param dry_run: Do everything but the actual install. Z WHEELPATHz.whlNzB{0} is not compatible with this Python. --force to install anyway.zNo such wheel file: {}zNo match for requirement {}z Installing: z {0} force)rXgetenvsplitpathseprYcurdirlistdirrLr rZ compatibler.existsrSextendrrr maxr#r$r%rKrHr5r?) requirementsrequirements_file wheel_dirsr^ list_filesdry_runZ wheelpathZ all_wheelsdwrBrfd to_installreqmsgmatchesrrrrHs^       rHc Csy ddlm}ddl}Wntk r@tdYnXxd|D]\}|j|}tjj|}|j|j }dg|_ |j |j |qHWdS)zQ Regenerate the entry_points console_scripts for the named distribution. r) easy_installNz)'wheel install_scripts' needs setuptools.r) Zsetuptools.commandrtr r r get_distributionrpathsZget_install_command distributionargsfinalize_optionsZinstall_egg_scripts) distributionsrtr distZpkg_resources_distrHcommandrrrinstall_scriptss    r}cCstdddlm}ddlm}x|D]}xt|D]}tjj|ddkro|}n|}|rtj j dj |tj j ||||rDtj j dqDWq1WdS) Nz wheel convertr)bdist_wininst2wheel) egg2wheelr/z.eggz{0}... zOK ) rZ wininst2wheelr~rrrXrYsplitextr#r$r%rflush) installersdest_dirverboser~rpat installerconvrrrconverts     rc stjjdd}dd}|jddd}|jd|dd }|jd dd }|jd dd |jd|dd}|jddtj}|jd dd |jd|dd}|jddtj}|jd dd |jd|dd} |jddd} | jdddddd| jd dd | jd| dd} |jddd } | jd!d"d#dd$| jd%dd&d'd(dd)| jd*dd'd+d,d-dd.| jd/d0dd1| jd2d3dd&d,d4d'd(dd5| jd| d6d7} |jd8dd9}|jd:d"d#dd;|jd| d<d=}|jd>dd?}|jd@d"d#ddA|jdBddt j j ddC|jdDdEd'd(|jd|dFdG}|jdHddI}|jd|fdJdK}|jdddL}|jd|S)MNhelpcommandscSs tdS)N)r-)rxrrrkeygen_f szparser..keygen_fr-zGenerate signing keyfunccSst|jdS)N)r;r@)rxrrrsign_fszparser..sign_fr;z Sign wheelr@z Wheel filecSst|jdS)N)rOr@)rxrrrunsign_fszparser..unsign_frOcSst|jdS)N)rTr@)rxrrrverify_fszparser..verify_frTcSst|j|jdS)N)r]r@r\)rxrrrunpack_f!szparser..unpack_fr]z Unpack wheelz--destz-dzDestination directorydefaultrVcSs)t|j|j|j|j|jdS)N)rHrhrirjr^rk)rxrrr install_f)szparser..install_frHzInstall wheelsrhnargs*zRequirements to install.z--forceFaction store_truez!Install incompatible wheel files.z --wheel-dirr.r\rjzDirectories containing wheels.z--requirements-filez-rz*A file containing requirements to install.z--listz-lrkzJList wheels which would be installed, but don't actually install anything.cSst|jdS)N)r}rz)rxrrrinstall_scripts_f?sz!parser..install_scripts_fzinstall-scriptszInstall console_scriptsrzz2Regenerate console_scripts for these distributionscSst|j|j|jdS)N)rrrr)rxrrr convert_fFszparser..convert_frzConvert egg or wininst to wheelrzInstallers to convertz --dest-dirz/Directory to store wheels (default %(default)s)z --verbosez-vcSs(ddlm}tjjd|dS)Nr) __version__z wheel %s )rr#r$r%)rxrrrr version_fOszparser..version_fversionzPrint version and exitcsjdS)N) print_help)rx)prrhelp_fUszparser..help_fzShow this help) argparseArgumentParserZadd_subparsersZ add_parser set_defaults add_argumentrO__doc__rTrXrYrb)srZ keygen_parserrZ sign_parserrZ unsign_parserrZ verify_parserrZ unpack_parserrZinstall_parserrZinstall_scripts_parserrZconvert_parserrZversion_parserrZ help_parserr)rrparsersv          rcCst}|j}t|ds1|jnTy|j|dSWn<tk r}ztjj|j dWYdd}~XnXdS)NrrrQr/) r parse_argshasattrrrrr#rUr%message)rrxerrrmain\s    *r)!rrXr8r#r=Z wheel.pathsrglobrrrutilrrrrr rHr rr Exceptionrrr-r;rOrTr]r}rrrrrrrs2     (      S   V