\do*ddlZddlZddlZddlZddlZddlZddlZgdZdZej drdZ nej Z Gdde ZejdZd Zdd Z dd Zd ZddZedkr edSdS)N) ZipAppErrorcreate_archiveget_interpreterz8# -*- coding: utf-8 -*- import {module} {module}.{fn}() winutf-8ceZdZdS)rN)__name__ __module__ __qualname__..\python\lib\zipapp.pyrr!sDr rc#Kt|ttjfr/t ||5}|VddddS#1swxYwYdS|VdSN) isinstancestrosPathLikeopen)archivemodefs r _maybe_openr%s'C-.. '4  AGGG                   sAA  A cx|r7d|tzdz}||dSdS)zWrite a shebang line.#! N)encodeshebang_encodingwrite)r interpretershebangs r_write_file_prefixr".sJ+,,-=>>>F r c$t|d5}|d}|dkrd}|t|d5}t||||t j||dddn #1swxYwYdddn #1swxYwY|rPt|tr=tj |tj |j tj zdSdSdS)z8Copy an application archive, modifying the shebang line.rbrr wbN)rreadreadliner"rshutil copyfileobjrrrchmodstatst_modeS_IEXEC)r new_archiver srcfirst_2dsts r _copy_archiver35s Wd # #)s((1++ e  G LLNNN d + + )s sK 0 0 0 IIg     sC ( ( (  ) ) ) ) ) ) ) ) ) ) ) ) ) ) ))))))))))))))))"Kz+s33K bgk22:T\IJJJJJKKKKs6AB1;B B1B B1!B "B11B58B5Fcd}t|drt|drd}n*tj|}|rd}|rt |||dS|st d|dz }|r|rt d|s|st d d}|r|d \} } } td | d D} td | d D} | d kr| r| st d|zt | | }|| d}n$t|dstj|}t|d5}t|||r tjn tj}tj|d|5}|dD]L}||}| ||r(|||M|r)|d|ddddn #1swxYwYdddn #1swxYwY|rKt|ds=||jt4jzdSdSdS)abCreate an application archive from SOURCE. The SOURCE can be the name of a directory, or a filename or a file-like object referring to an existing archive. The content of SOURCE is packed into an application archive in TARGET, which can be a filename or a file-like object. If SOURCE is a directory, TARGET can be omitted and will default to the name of SOURCE with .pyz appended. The created application archive will have a shebang line specifying that it should run with INTERPRETER (there will be no shebang line if INTERPRETER is None), and a __main__.py which runs MAIN (if MAIN is not specified, an existing __main__.py will be used). It is an error to specify MAIN for anything other than a directory source with no __main__.py, and it is an error to omit MAIN if the directory has no __main__.py. Fr'r(TNzSource does not existz __main__.pyz8Cannot specify entry point if the source has __main__.pyzArchive has no entry point:c3>K|]}|VdSr isidentifier.0parts r z!create_archive..{s.DDTT&&((DDDDDDr .c3>K|]}|VdSrr7r9s rr<z!create_archive..|s.BBDD%%''BBBBBBr zInvalid entry point: )modulefnz.pyzrr&w) compression*r)hasattrpathlibPathis_filer3existsr partitionallsplit MAIN_TEMPLATEformat with_suffixrr"zipfile ZIP_DEFLATED ZIP_STOREDZipFilerglob relative_toras_posixwritestrrr+r,r-r.)sourcetargetr mainfilter compressedsource_is_filehas_mainmain_pymodsepr@mod_okfn_okfdrBzchildarcnames rrrLs*Nvv"76:#>#>"f%% >>   "!Nffk222 ==??31222&//11H HH FHH H 8H86777G :~~c** S"DDSYYs^^DDDDDBBBHHSMMBBBBBs v % 5<== =&&cb&99 ~##F++ VW % %&f%% VT " " Cb2{+++/9*w++)  _R+ > > > C!c** 7 7++F33>VVG__>GGE7#3#3#5#5666 C ='..*A*ABBB  C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C;76733; V[[]]*T\9:::::;;;;s8>AJ1BJ J1J J1!J "J11J58J5c t|d5}|ddkrJ|t cdddS ddddS#1swxYwYdS)Nr$r%r)rr'r(stripdecoder)rrs rrrs Wd # #Aq 66!99  ::<<%%''../?@@AAAAAAAA AAAAAAAAAAAAAAAAAAsABB Bc*ddl}|}|dddd|dddd |d d dd |d ddd|dddd|dd||}|jrt j|jstdt|j}td |pdtjdt j|jrz|jNt j|jr9t j|j|jrtd|jrtdt'|j|j|j|j|jdS)zRun the zipapp command line interface. The ARGS parameter lets you specify the argument list directly. Omitting ARGS (or setting it to None) works as for argparse, using sys.argv[1:] as the argument list. rNz--outputz-ozAThe name of the output archive. Required if SOURCE is an archive.)defaulthelpz--pythonz-pzEThe name of the Python interpreter to use (default: no shebang line).z--mainz-mzLThe main function of the application (default: use an existing __main__.py).z --compressz-c store_truezQCompress files with the deflate method. Files are stored uncompressed by default.)actionrlz--infoFz)Display the interpreter from the archive.)rkrnrlrWz'Source directory (or existing archive).)rlz%Can only get info for an archive filezInterpreter: {}zz-In-place editing of archives is not supportedz,Cannot change the main function when copying)r rYr[)argparseArgumentParser add_argument parse_argsinforpathisfilerW SystemExitrprintrMsysexitoutputrHsamefilerYrpythoncompress)argsroparserr s rrYrYsIOOO  $ $ & &F  D$5666  D$/000 $;<<<  d<=>>> % <>>> :<<<   T " "D yw~~dk** FDEE E%dk22  &&{'>h??@@@   w~~dk""M ; 27>>$+#>#> #%7#3#3DK#M#M LMM M 9 MKLL L4; #{"m------r __main__r)NNNNF) contextlibrrEr)r,rxrO__all__rLplatform startswithrgetfilesystemencoding ValueErrorrcontextmanagerrr"r3rrrYr r r rrsk   > > > <5!!30s022     *    KKKK.@D+0G;G;G;G;TAAA .-.-.-.-b zDFFFFFr