
    dO                        d Z ddlZddlZddlZddlZddlZddlZddlm	Z	 ddl
mZ g dZddZ	 	 	 dddddd
dZ	 	 	 dddddd
dZ	 	 	 ddZd Zedk    r& e e                       Z ej        e           dS dS )a  Module/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   |dk     r.t          | t          j                  rt          j        |           } |s"t	          d                    |                      	 t          j        |           }n:# t          $ r- |dk     r"t	          d                    |                      g }Y nw xY w|                                 |D ]}|dk    r	t          j	        
                    | |          }t          j	                            |          s|V  M|dk    ry|t          j        k    ri|t          j        k    rYt          j	                            |          r:t          j	                            |          st          ||dz
  |          E d {V  d S )N   zListing {!r}...zCan't list {!r}__pycache__r      )	maxlevelsquiet)
isinstanceosPathLikefspathprintformatlistdirOSErrorsortpathjoinisdircurdirpardirislink	_walk_dir)dirr   r   namesnamefullnames           /croot/python-split_1694437901252/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac/lib/python3.11/compileall.pyr   r      s     qyyZR[11yinn -&&s++,,,
3   199#**3//000 
JJLLL 	. 	.=  7<<T**w}}X&& 	.NNNN!mm	 1 1dbi6G6GgmmH%% 7H.0gnnX.F.F 7H Y]',. . . . . . . . . .	. 	.s   A1 14B('B(Fr   stripdir
prependdirlimit_sl_desthardlink_dupesc
                P   d}||
|t          d          || }
|}d}|dk     rt          d          |dk    r*ddlm} 	  |             ddlm} n# t
          $ r d}Y nw xY w|t          j                    }t          | ||          }d	}|dk    rp|n|pd} ||
          5 }|	                    t          t          |||||||	|
|||          |          }t          |d	          }ddd           n# 1 swxY w Y   n"|D ]}t          ||||||||	|
|||          sd} |S )a  Byte-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 prependdirr   z%workers must be greater or equal to 0r   )_check_system_limits)ProcessPoolExecutor)r   r   T)max_workers)ddirforcerxr   legacyoptimizeinvalidation_moder%   r&   r'   r(   )defaultr$   F)
ValueErrorconcurrent.futures.processr+   concurrent.futuresr,   NotImplementedErrorsysgetrecursionlimitr   mapr   r   min)r   r   r.   r/   r0   r   r1   r2   workersr3   r%   r&   r'   r(   r,   r+   filessuccessexecutorresultsfiles                        r"   r   r   0   s/   8 X1Z5K G I I 	I
{{@AAA!||CCCCCC	?  """ ?>>>>>> # 	 	 	GGG	 )++	c)<<<EG!||+7/T  W555 	1ll7<04E.0284<=N4<6@9F:H	$J 	$J 	$J $)
* 
*G '4000G	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1  	  	 DdE2u &2C)1j.;/=	? ? ?  
  Ns%   
A A"!A"&AC88C<?C<c          	      j   |||	t          d          d}t          j        |           } |t          j        |          nd}t          j                            |           }d}| t          j                            ||          }||                     t          j        j                  }|                    t          j        j                  }t          |          }t          ||          D ] \  }}||k    r|
                    |           !t          j        j        | }|	C|!t          j                            |	|           }n t          j                            |	|          }t          |t                    r|g}t          t          |                    }|r"t          |          dk     rt          d          ||                    |           }|r|S |
ht          j                            |           rIt%          |
                                          t%          |                                           j        vr|S i }t          j                            |           rK|D ]h}|r	| dz   ||<   |dk    r1|dk    r|nd	}t,          j                            | |
          }|||<   Dt,          j                            |           }|||<   i|dd         |dd         }}|dk    r|s	 t          t          j        |           j                  }t7          j        dt,          j        j        d|dz            }|                                D ]G}t?          |d          5 }|                     d          }ddd           n# 1 swxY w Y   ||k    r nH|S n# tB          $ r Y nw xY w|s"tE          d#                    |                      	 tI          |          D ]\  }}||         }tK          j&        | ||d||          } |dk    rS|rQ|||dz
                    }!tO          j(        ||!d          r)t          j)        |           t          j*        |!|           	 | dk    rd}nD# tJ          j+        $ r}"d}|dk    r|cY d}"~"S |r#tE          d#                    |                      ntE          dd	           tX          j-        j.        ptY          j/                    }#|"j0        1                    |#d          2                    |#          }$tE          |$           Y d}"~"nd}"~"wtf          th          tB          f$ rl}%d}|dk    r|cY d}%~%S |r#tE          d#                    |                      ntE          dd	           tE          |%j5        j6        dz   |%           Y d}%~%nd}%~%ww xY w|S )a  Byte-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 levelcr   r    )optimizationz.pyz<4sLLl    rb   zCompiling {!r}...)r2   r3   F)shallowz*** Error compiling {!r}...z*** )endbackslashreplace)errors:)7r5   r   r   r   basenamer   splitseplistzipremover   intsortedsetlensearchr   r   resolveparentsisfile	importlibutilcache_from_sourcestatst_mtimestructpackMAGIC_NUMBERvaluesopenreadr   r   r   	enumerate
py_compilecompilefilecmpcmpunlinklinkPyCompileErrorr9   stdoutencodinggetdefaultencodingmsgencodedecodeSyntaxErrorUnicodeError	__class____name__)&r!   r.   r/   r0   r   r1   r2   r3   r%   r&   r'   r(   r?   r    dfilefullname_partsstripdir_parts
ddir_partsspartopartmo
opt_cfiles	opt_leveloptcfileheadtailmtimeexpectchandleactualindexokprevious_cfileerrrq   rs   es&                                         r"   r   r   }   sy   6 X1Z5K G I I 	I Gy""H&.&:ry"""H7H%%DET4((!44!44.))
?? 	) 	)LE5~~!!%(((j)=GLLX66EEGLLU33E(C   : c(mm$$H G#h--!++ F G G 	G 
~YYx   	N RW^^H%=%= &&((X0F0F0H0H0PPPNJ	w~~h B$! 	2 	2I 
2(03
9%%>>'0A~~))2C&^==%C > 9 9E,1Jy))%N<<XFFE,1Jy))#2#YRSS	d5==  1 1 :;;E#[).2M)*EK,?A AF!+!2!2!4!4 ' '!%.. 6'%,\\"%5%5F6 6 6 6 6 6 6 6 6 6 6 6 6 6 6!V++!E ,  ' "    D <)00::;;;"$(1((;(; 	; 	;$E9&y1E#+HeUD5>>OQ Q QB qyy^y)3HUQY4G)H";uneLLL ;Ie,,,GNE:::	;@ 77#G/ ,   A::"NNNNNN *7>>xHHIIII&b)))):.J#2H2J2JgnnX6HnIIPPQYZZc







w7 5 5 5A::"NNNNNN *7>>xHHIIII&b))))ak*S0!444444445 Nsv   1A5N &N<N N	N N	N 
N,+N,BQ/ /V0>	T*V0BT**V0	V+V0AV++V0c                     d}t           j        D ]E}|r|t          j        k    r| r|dk     rt	          d           ,|ot          ||d|||||          }F|S )a  Byte-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	   zSkipping current directoryN)r   r1   r2   r3   )r9   r   r   r   r   r   )	skip_curdirr   r/   r   r1   r2   r3   r?   r   s	            r"   r   r     s     Gx   	sbi''['qyy2333 	+!"3	# 	# 	#GG N    c                  	   ddl } |                     d          }|                    dddddd	           |                    d
t          dd           |                    dddd           |                    ddddd           |                    dddd           |                    ddddd           |                    d d!d"dd#           |                    d$d%d&dd'           |                    d(d)d*dd+           |                    d,d-d.d/0           |                    d1d2d3d45           |                    d6d7d8t          d9:           d; t          j        D             }|                    d<t          |          d=>           |                    d?d@t          dAdBC           |                    dDdEdFdG0           |                    dHddIdJ           |                                }|j        }|j	        r#ddl
}|                    |j	                  |_	        |j        dKk    rd|_        |j        |j        }n|j        }|j        dLg|_        t!          |j                  d8k    r|j        r|                    dM           |j        #|j        |j        |                    dN           |j        r	 |j        dOk    rt.          j        nt3          |j        dPQ          5 }|D ])}|                    |                                           *	 ddd           n# 1 swxY w Y   nC# t8          $ r6 |j        dRk     r't=          dS                    |j                             Y dTS w xY w|j         r@|j         !                    dOdU          "                                }	t          j        |	         }
nd}
dV}	 |r|D ]}tF          j$        %                    |          rPtM          ||j        |j'        |j	        |j        |j(        |
|j        |j        |j        |j        |j        W          sdT}qtS          |||j        |j'        |j	        |j        |j(        |j*        |
|j        |j        |j        |j        |j        X          sdT}|S tW          |j(        |j'        |j        |
Y          S # tX          $ r |j        dRk     rt=          dZ           Y dTS w xY w)[zScript main program.r   Nz1Utilities to support installing Python libraries.)descriptionz-lstore_constr   z!don't recurse into subdirectories)actionconstr4   desthelpz-r	recursionzhcontrol the maximum recursion level. if `-l` and `-r` options are specified, then `-r` takes precedence.)typer   r   z-f
store_truer/   z/force rebuild even if timestamps are up to date)r   r   r   z-qcountr   zIoutput only error messages; -qq will suppress the error messages as well.)r   r   r4   r   z-br1   z0use legacy (pre-PEP3147) compiled file locationsz-dDESTDIRr.   zdirectory to prepend to file paths for use in compile-time tracebacks and in runtime tracebacks in cases where the source file is unavailable)metavarr   r4   r   z-sSTRIPDIRr%   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-xREGEXPr0   zskip files matching the regular expression; the regexp is searched for in the full path of each file considered for compilationz-iFILEflistzzadd all the files and directories listed in FILE to the list considered for compilation; if "-", names are read from stdin)r   r   r   compile_destzFILE|DIR*zrzero or more file and directory names to compile; if no arguments given, defaults to the equivalent of -l sys.path)r   nargsr   z-jz	--workersr   zRun compileall concurrently)r4   r   r   c                 h    g | ]/}|j                                                             d d          0S )_-)r    lowerreplace).0modes     r"   
<listcomp>zmain.<locals>.<listcomp>i  sJ     F F F" )//++33C== F F Fr   z--invalidation-modezset .pyc invalidation mode; defaults to "checked-hash" if the SOURCE_DATE_EPOCH environment variable is set, and "timestamp" otherwise.)choicesr   z-oappend
opt_levelszOptimization levels to run compilation with. Default is -1 which uses the optimization level of the Python interpreter itself (see -O).)r   r   r   r   z-eDIRr'   z+Ignore symlinks pointing outsite of the DIRz--hardlink-dupesr(   zHardlink duplicated pyc filesrE   r#   zYHardlinking of duplicated bytecode makes sense only for more than one optimization level.z.-d cannot be used in combination with -s or -pr   zutf-8)rq   r	   zError reading file list {}Fr   T)r3   r%   r&   r2   r'   r(   )r=   r3   r%   r&   r2   r'   r(   )r1   r/   r   r3   z
[interrupted])-argparseArgumentParseradd_argumentrU   ri   PycInvalidationModerV   
parse_argsr   r0   rerj   r'   r   r   r   rX   r(   errorr.   r%   r&   r   r9   stdinrf   r   stripr   r   r   r   r3   r   upperr   r   r\   r   r/   r1   r   r=   r   KeyboardInterrupt)r   parserinvalidation_modesargscompile_destsr   r   flineivl_moder3   r?   r   s                r"   mainr   4  s   OOO$$G % I IF
]! $;@  B B B 3[<  > > > \N  P P P
W7A;  < < < \O  Q Q Q
ivt,  . . .
 j
 $4  6 6 6 l, $4  6 6 6 hT4H  J J J f7B  D D D 
#A  C C C k1 'D  F F FF F&0&DF F F
- &'9 : :7  9 9 9 XClK  M M M e/J  L L L
*<-<  > > > D%Mw &			**TW%%R!~!N		N	$
4?q  T%8  C 	E 	E 	E y!T_%@EFFF z 		#z3#))g6667;< 7 7D!((666677 7 7 7 7 7 7 7 7 7 7 7 7 7 7  	 	 	zA~~299$*EEFFF55	
  !)11#s;;AACC&:8D G  	E% ( (7>>$'' ('diTW(,
DK:K1537?156:6H7;7JL L L ( #(&tY	'+z47DJ'+{DL9J0426/04595G6:6IK K K 	( #(Nt{$*&*j2CE E E E    :>>#$$$uusO   -L: 4-L."L: .L22L: 5L26L: :<M:9M:	CR9 !R9 9$S! S!__main__)r   )	NNFNr   Fr#   r   N)NFNr   Fr#   N)r   r   Fr   Fr#   N)__doc__r   r9   importlib.utilr]   ri   rb   rk   	functoolsr   pathlibr   __all__r   r   r   r   r   ry   rU   exit_statusexit r   r"   <module>r      s}    
			 



                      
7
7
7. . . .. 7<EF"&K48tEK K K K KZ CD(*#'S59d#ES S S S Sj AB(*#'   DV V Vr z#$$&&j//KCH[ r   