K i".dZddlmZddlZddlmZmZ ddlZddl m Z ddl m Z ddl mZdd lmZ dd lmZ dd lmZd Zd Z d d!dZ d" d#dZedgdfedgdfedgdfedgdfedgdfegdfdZdZe d$ d%dZe d& d'dZ d$ d(dZy#e$rdZYwxYw#e$rdZYwxYw#e$rdZYwxYw))zodistutils.archive_util Utility functions for creating archive files (tarballs, zip files, that sort of thing).) annotationsN)Literaloverload)log)mkpath)DistutilsExecError)spawn)getpwnam)getgrnamc^t|y t|}||dSy#t$rd}YwxYw)z"Returns a gid, given a group name.N)r KeyErrornameresults h/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/setuptools/_distutils/archive_util.py_get_gidr!H4<$ay    ,,c^t|y t|}||dSy#t$rd}YwxYw)z"Returns an uid, given a user name.Nr)r rrs r_get_uidr.rrc ddddd}dddd }|||jvr td |d z} | |j|dz } ttj j | | dd l} tjdtt fd} |s>| j| d||} | j|| | j| S| S#| jwxYw)aCreate a (possibly compressed) tar file from all the files under 'base_dir'. 'compress' must be "gzip" (the default), "bzip2", "xz", or None. 'owner' and 'group' can be used to define an owner and a group for the archive that is being built. If not provided, the current owner and group will be used. The output tar file will be named 'base_dir' + ".tar", possibly plus the appropriate compression extension (".gz", ".bz2", ".xz" or ".Z"). Returns the output filename. gzbz2xz)gzipbzip2rNz.gzz.bz2z.xz)rrrNz=bad value for 'compress': must be None, 'gzip', 'bzip2', 'xz'z.tardry_runrzCreating tar archivecH|_|_|_|_|SN)gidgnameuiduname)tarinfor$groupownerr&s r _set_uid_gidz"make_tarball.._set_uid_gidms. ?GK!GM ?GK!GMzw|)filter)keys ValueErrorgetrospathdirnametarfilerinforropenaddclose) base_namebase_dircompressverboser!r*r)tar_compression compress_ext archive_namer4r+tarr$r&s `` @@r make_tarballrA;s 0 O "F%@L 0A0A0C C K  v%LL$$Xr22L 277??< (':HH #$ 5/C 5/C ll<2oh.G-H)IJ  GGH\G 2 IIK < IIKs C..Dc $|dz}ttjj||t|rd}nd} t d|||g||Stjd |||s t j|d tj }|5|tjk7retjjtjj|d }|j!||tjd |tj"|D]\}} } | D]h} tjjtjj|| d }|j!||tjd |j| D]} tjjtjj|| }tjj%|s`|j!||tjd | ddd|S|S#t $rt d|dwxYw#t$r*t j|d tj }YwxYw#1swY|SxYw)avCreate a zip file from all the files under 'base_dir'. The output zip file will be named 'base_name' + ".zip". Uses either the "zipfile" Python module (if available) or the InfoZIP "zip" utility (if installed and found on the default search path). If neither tool is available, raises DistutilsExecError. Returns the name of the output zip file. z.zipr Nz-rz-rqzipzunable to create zip file 'zN': could neither import the 'zipfile' module nor find a standalone zip utilityz#creating '%s' and adding '%s' to itw) compressionrz adding '%s')rr1r2r3zipfiler r rr5ZipFile ZIP_DEFLATED RuntimeError ZIP_STOREDcurdirnormpathjoinwritewalkisfile) r9r:r<r! zip_filename zipoptionsrCr2dirpathdirnames filenamesrs r make_zipfilerVs1v%L 277??< (': JJ  5*lH=w OJ 5 6 hO Yoo #73G3G  :ryy(77++BGGLL2,FGDIIdD)HH]D146GGH4E :0GXy (6!ww// WdB0OP $-56!*:!ww// Wd0KL77>>$/IIdD1HH]D9 : :  : <I" %-l^<00  "  YoolCWEWEWX Y : s0H3,&IE$J9-J3I /JJJ)r;rzgzip'ed tar-file)r;rzbzip2'ed tar-file)r;rzxz'ed tar-file)r;r;zcompressed tar file)r;Nzuncompressed tar filezZIP file)gztarbztarxztarztarr@rCc*|D]}|tvs |cSy)zqReturns the first format from the 'format' list that is unknown. If all formats are known, returns None N)ARCHIVE_FORMATS)formatsformats rcheck_archive_formatsr_s%   (M r,cyr#r9r^root_dirr:r<r!r*r)s r make_archiverd r,cyr#rarbs rrdrdrer,chtj}|Ltjd|tjj |}|stj ||tj}d|i} t|} | d} | j| d|dk7r || d<|| d < | ||fi| } |+tjd |tj || S#t$rtd|dwxYw#|,tjd |tj |wwxYw) aCreate an archive file (eg. zip or tar). 'base_name' is the name of the file to create, minus any format-specific extension; 'format' is the archive format: one of "zip", "tar", "gztar", "bztar", "xztar", or "ztar". 'root_dir' is a directory that will be the root directory of the archive; ie. we typically chdir into 'root_dir' before creating the archive. 'base_dir' is the directory where we start archiving from; ie. 'base_dir' will be the common prefix of all files and directories in the archive. 'root_dir' and 'base_dir' both default to the current directory. Returns the name of the archive file. 'owner' and 'group' are used when creating a tar archive. By default, uses the current owner and group. zchanging into '%s'r!zunknown archive format ''rrrCr*r)zchanging back to '%s') r1getcwdrdebugr2abspathchdirrKr\rr/update) r9r^rcr:r<r!r*r)save_cwdkwargs format_infofuncfilenames rrdrds,4yy{H &1GGOOI.  HHX 99 !F?%f-  q>D MM+a.! ww 86v6   II-x 8 HHX  O# ?3F81=>>?   II-x 8 HHX  s: C%, D%C>0D1)rFFNN)r9strr:str | os.PathLike[str]r;z%Literal['gzip', 'bzip2', 'xz'] | Noner<boolr!rur* str | Noner)rvreturnrs)FF) r9rsr:rtr<rur!rurwrs)NNFFNN)r9rsr^rsrc:str | os.PathLike[str] | bytes | os.PathLike[bytes] | Noner:rvr<rur!rur*rvr)rvrwrs)NFFNN)r9rtr^rsrcz3str | os.PathLike[str] | bytes | os.PathLike[bytes]r:rvr<rur!rur*rvr)rvrwrs)r9rtr^rsrcrxr:rvr<rur!rur*rvr)rvrwrs)__doc__ __future__rr1typingrrrF ImportError_logrdir_utilrerrorsr r pwdr grpr rrrArVr\r_rdrar,rrs # $ &   7=BB$B4B B  B  B B BP ??$?? ?  ?F124F G235H I/02B C 457L M -.0G H "j )  LP    I                 %   B              LP9%9 9I9 9  9  9 9 9 9AGH Hs3C0C=D 0C:9C:=DD DD