QfPdZddlZddlZddlZddlZddlZddlZddlm Z ddl m Z gdZ ddZ ddddddd Z ddddddd Z dd Zd Zed k(r!ee Zej*eyy)aModule/script to byte-compile all .py files to .pyc files. When called as a script with arguments, this compiles the directories given as arguments recursively; the -l option prevents it from recursing into directories. Without arguments, it compiles all modules on sys.path, without recursing into subdirectories. (Even though it should do so for packages -- for now, you'll have to deal with packages separately.) See module py_compile for details of the actual byte-compilation. N)partial)Path) compile_dir compile_file compile_pathc#K|dkr/t|tjrtj|}|st dj | tj |}|j|D]}|dk(r tjj||}tjj|s|M|dkDsS|tjk7sg|tjk7s{tjj|stjj|rt||dz |Ed{y#t$r%|dkrt dj |g}YwxYw78w)NzListing {!r}...zCan't list {!r} __pycache__r) maxlevelsquiet) isinstanceosPathLikefspathprintformatlistdirOSErrorsortpathjoinisdircurdirpardirislink _walk_dir)dirr r namesnamefullnames 1/opt/alt/python312/lib64/python3.12/compileall.pyrrs( qyZR[[1iin  &&s+, 3  JJL = 77<<T*ww}}X&N!m 1dbii6GggmmH%bggnnX.F Y]',. . .  19 #**3/ 0 .sUAFE)A$FF"F6FF6F F F*F<F?FFFstripdir prependdir limit_sl_desthardlink_dupesc bd}|| | td||} |} d}|dkr td|dk7rddlm} |ddlm}|t j}t|||}d }|dk7r|~ddl }|jd k(r|jd }nd}|xsd}||| 5}|jtt||||||| | | | | |}t|d }ddd|S|D]}t|||||||| | | | |  rd}|S#t $rd}YwxYw#1swY|SxYw)aByte-compile all modules in the given directory tree. Arguments (only dir is required): dir: the directory to byte-compile maxlevels: maximum recursion level (default `sys.getrecursionlimit()`) ddir: the directory that will be prepended to the path to the file as it is compiled into each byte-code file. force: if True, force compilation, even if timestamps are up-to-date quiet: full output with False or 0, errors only with 1, no output with 2 legacy: if True, produce legacy pyc paths instead of PEP 3147 paths optimize: int or list of optimization levels or -1 for level of the interpreter. Multiple levels leads to multiple compiled files each with one optimization level. workers: maximum number of parallel workers invalidation_mode: how the up-to-dateness of the pyc will be checked stripdir: part of path to left-strip from source file path prependdir: path to prepend to beginning of original file path, applied after stripdir limit_sl_dest: ignore symlinks if they are pointing outside of the defined path hardlink_dupes: hardlink duplicated pyc files NPDestination dir (ddir) cannot be used in combination with stripdir or prependdirrz%workers must be greater or equal to 0r )_check_system_limits)ProcessPoolExecutor)r r Tfork forkserver) max_workers mp_context) ddirforcerxr legacyoptimizeinvalidation_moder$r%r&r')defaultr#F) ValueErrorconcurrent.futures.processr*concurrent.futuresr+NotImplementedErrorsysgetrecursionlimitrmultiprocessingget_start_method get_contextmaprrmin)rr r0r1r2r r3r4workersr5r$r%r&r'r+r*filessuccessr=r/executorresultsfiles r"rr0s8 X1Z5KGI I  {@AA!|C ? " ?))+ c) t%| j't%|j'j(vr| Si}tjj+|r|D]f}|r |dz||<|dk\r0|dk\r|nd }t,j.j1|| }|||<Ct,j.j1|}|||<h| dd | d d}}|d k(rU|s ttj2|j4}t7j8d t,j.j:d|dz}|j=D]/}t?|d5}|jAd}ddd|k7s/n| S |stEdjG| tI|D]}\}}||}tKjL|||d||} |dkDs,| s/|||dz }!tOjP||!dsStjR|tjT|!|  dk(rd} | S| S#1swYxYw#tB$rYwxYw#tJjV$r}"d} |dk\r| cYd}"~"S|rtEdjG|n tEdd tXjZj\xstYj^}#|"j`jc|#dje|#}$tE|$Yd}"~"| Sd}"~"wtfthtBf$rf}%d} |dk\r| cYd}%~%S|rtEdjG|n tEdd tE|%jjjldz|%Yd}%~%| Sd}%~%wwxYw)aByte-compile one file. Arguments (only fullname is required): fullname: the file to byte-compile ddir: if given, the directory name compiled in to the byte-code file. force: if True, force compilation, even if timestamps are up-to-date quiet: full output with False or 0, errors only with 1, no output with 2 legacy: if True, produce legacy pyc paths instead of PEP 3147 paths optimize: int or list of optimization levels or -1 for level of the interpreter. Multiple levels leads to multiple compiled files each with one optimization level. invalidation_mode: how the up-to-dateness of the pyc will be checked stripdir: part of path to left-strip from source file path prependdir: path to prepend to beginning of original file path, applied after stripdir limit_sl_dest: ignore symlinks if they are pointing outside of the defined path. hardlink_dupes: hardlink duplicated pyc files Nr)Tr zXHardlinking of duplicated bytecode makes sense only for more than one optimization levelcrr ) optimizationz.pyz<4sLLlrb zCompiling {!r}...)r4r5F)shallowz*** Error compiling {!r}...z*** )endbackslashreplace)errors:)7r7rrrbasenamersplitseplistzipremoverintsortedsetlensearchrrresolveparentsisfile importlibutilcache_from_sourcestatst_mtimestructpack MAGIC_NUMBERvaluesopenreadrrr enumerate py_compilecompilefilecmpcmpunlinklinkPyCompileErrorr;stdoutencodinggetdefaultencodingmsgencodedecode SyntaxError UnicodeError __class____name__)&r!r0r1r2r r3r4r5r$r%r&r'rDr dfilefullname_partsstripdir_parts ddir_partsspartopartmo opt_cfiles opt_leveloptcfileheadtailmtimeexpectchandleactualindexokprevious_cfileerrrvrxes& r"rrs6 X1Z5KGI IGyy"H&.&:ryy"H 77  H %D E  T4(! 4! 4.) ?LE5~!!%(@ j) =GGLLX6EGGLLU3E(C :c(m$H#h-!+FG G ~ YYx  N RWW^^H%=   & & (X0F0F0H0P0P PNJ ww~~h!I(03 9%>'0A~)2C&^^==%C>9E,1Jy)%NN<>OQBqy^)3HUQY4G)H";;uneLIIe,GGNE:)<@7#G N7N[/. ,, A:"N7>>xHI&b)::..J#2H2H2JggnnX6HnIPPQYZc  N w7 5A:"N7>>xHI&b)akk**S0!44 N 5sA:P(P P("P(6P7<P7?#P7#-P7P% !P(( P43P47U, S/U,BS//U,U'U,A U''U,c d}tjD]B}|r|tjk(r|r|dks t d,|xrt ||d|||||}D|S)aByte-compile all module on sys.path. Arguments (all optional): skip_curdir: if true, skip current directory (default True) maxlevels: max recursion level (default 0) force: as for compile_dir() (default False) quiet: as for compile_dir() (default 0) legacy: as for compile_dir() (default False) optimize: as for compile_dir() (default -1) invalidation_mode: as for compiler_dir() Tr zSkipping current directoryN)r r3r4r5)r;rrrrr) skip_curdirr r1r r3r4r5rDrs r"rrsgGxxsbii'[qy23 +!"3 #G  Nc ddl}|jd}|jdddddd |jd td d |jdddd|jddddd|jdddd|jddddd|jd d!d"dd#|jd$d%d&dd'|jd(d)d*dd+|jd,d-d.d/0|jd1d2d3d45|jd6d7d8td9:tj Dcgc],}|j jjd;d<.}}|jd=t|d>?|jd@dAtdBdCD|jdEdFdGdH0|jdIddJdK|j}|j}|jr$ddl }|j|j|_ |jdLk(rd|_|j |j }n |j"}|j$dMg|_t'|j$d8k(r|j(r|j+dN|j,)|j. |j0|j+dO|j2rg |j2d|jFjd$r6|j@dRkr$tCdSjE|j2YyTwxYw#t\$r|j@dRkr tCdYYyTwxYw)ZzScript main program.rNz1Utilities to support installing Python libraries.) descriptionz-l store_constr z!don't recurse into subdirectories)actionconstr6desthelpz-r recursionzhcontrol the maximum recursion level. if `-l` and `-r` options are specified, then `-r` takes precedence.)typerrz-f store_truer1z/force rebuild even if timestamps are up to date)rrrz-qcountr zIoutput only error messages; -qq will suppress the error messages as well.)rrr6rz-br3z0use legacy (pre-PEP3147) compiled file locationsz-dDESTDIRr0zdirectory to prepend to file paths for use in compile-time tracebacks and in runtime tracebacks in cases where the source file is unavailable)metavarrr6rz-sSTRIPDIRr$zpart of path to left-strip from path to source file - for example buildroot. `-d` and `-s` options cannot be specified together.z-p PREPENDDIRr%zpath to add as prefix to path to source file - for example / to make it absolute when some part is removed by `-s` option. `-d` and `-p` options cannot be specified together.z-xREGEXPr2zskip files matching the regular expression; the regexp is searched for in the full path of each file considered for compilationz-iFILEflistzzadd all the files and directories listed in FILE to the list considered for compilation; if "-", names are read from stdin)rrr compile_destzFILE|DIR*zrzero or more file and directory names to compile; if no arguments given, defaults to the equivalent of -l sys.path)rnargsrz-jz --workersr zRun compileall concurrently)r6rr_-z--invalidation-modezset .pyc invalidation mode; defaults to "checked-hash" if the SOURCE_DATE_EPOCH environment variable is set, and "timestamp" otherwise.)choicesrz-oappend opt_levelszOptimization levels to run compilation with. Default is -1 which uses the optimization level of the Python interpreter itself (see -O).)rrrrz-eDIRr&z+Ignore symlinks pointing outsite of the DIRz--hardlink-dupesr'zHardlink duplicated pyc filesrJzYHardlinking of duplicated bytecode makes sense only for more than one optimization level.z.-d cannot be used in combination with -s or -pzutf-8)rvr zError reading file list {}FT)r5r$r%r4r&r')rBr5r$r%r4r&r')r3r1r r5z [interrupted])/argparseArgumentParser add_argumentrZrnPycInvalidationModer lowerreplacer[ parse_argsrr2reror&rr rr]r'errorr0r$r%rr;stdinrkrstriprr rrr5upperrrrarr1r3rrBrKeyboardInterrupt)rparsermodeinvalidation_modesargs compile_destsrr flineivl_moder5rDrs r"mainr:si  $ $G%IF ]! $;@B 3[<> \NP W7A;< \OQ ivt,.  j $46  l, $46 hT4HJ f7BD  #AC k1 'DF'1&D&DF&Dd))//+33C=&DF - &'9 :79  XClKM e/JL *<-<>    D%%M ww**TWW% R! ~~!NN NN  $ 4??q T%8%8 C E yy !T__%@ EF zz #zz3#))g67;<D!((67 ))11#s;AAC&::8D G  %77>>$''diiTWW(, DKK:K1537??156:6H6H7;7J7JL#(&tY '+zz477DJJ'+{{DLL9J04 26//04595G5G6:6I6IK#(+&,Nt{{$**&*jj2CE EuF`77 zzA~299$**EF R  ::> # $sV51S46T'S99TB#U4B UU,U9T>Trs    7..7