
    F\hQ                     
   S r SSKrSSKrSSKrSSKrSSKrSSKrSSKJ	r	  SSK
Jr  / SQrSS jr   SSSSSS.S	 jjr   SSSSSS.S
 jjr   SS jrS r\S:X  a%  \" \" 5       (       + 5      r\R*                  " \5        gg)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              #   Z  #    US:  a5  [        U [        R                  5      (       a  [        R                  " U 5      n U(       d  [	        SR                  U 5      5         [        R                  " U 5      nUR                  5         U H  nUS:X  a  M  [        R                  R                  X5      n[        R                  R                  U5      (       d  Uv   MT  US:  d  M\  U[        R                  :w  d  Mr  U[        R                  :w  d  M  [        R                  R                  U5      (       d  M  [        R                  R                  U5      (       a  M  [        XQS-
  US9 S h  vN   M     g ! [         a&    US:  a  [	        SR                  U 5      5        / n GN/f = f N<7f)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         !/usr/lib/python3.13/compileall.pyr   r      s/    qyZR[[11iin&&s+,

3
 
JJL= 77<<*ww}}X&&N!m		 1dbii6GggmmH%%bggnnX.F.F ]',. . .   19#**3/0.sU   AF+ E6 6A*F+$F+:F+"F+6"F+F+,F)-	F+6,F&"F+%F&&F+Fstripdir
prependdirlimit_sl_desthardlink_dupesc
                   SnUb  U
c  Ub  [        S5      eUb  U n
UnSnUS:  a  [        S5      eUS:w  a  SSKJn   U" 5         SSKJn  Uc  [        R                  " 5       n[        XUS9nS	nUS:w  a}  Ubz   SSK	nUR                  5       S
:X  a  UR                  S5      nOSn U=(       d    SnU" UUS9 nUR                  [        [        X#XEUUU	U
UUUS9USS9n[!        US	S9nSSS5        U$ U H  n[        UX#XEXgU	XUUS9(       a  M  SnM     U$ ! [
         a    Sn Nf = f! [         a    Sn Nf = f! , (       d  f       U$ = f)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fork
forkserver)max_workers
mp_context)ddirforcerxr   legacyoptimizeinvalidation_moder$   r%   r&   r'      )	chunksize)defaultr#   F)
ValueErrorconcurrent.futures.processr*   concurrent.futuresr+   NotImplementedErrorsysgetrecursionlimitr   multiprocessingget_start_methodget_contextImportErrormapr   r   min)r   r   r0   r1   r2   r   r3   r4   workersr5   r$   r%   r&   r'   r+   r*   filessuccessr?   r/   executorresultsfiles                          r"   r   r   0   s   8 X1Z5K G I 	I
{@AA!|C	? " ?))+	c)<EG!|+7	"//1V;,88F
!
 /T W,68;Cll7<04.0284<=N4<6@9F:H	$J $)-. # 0G '40G8. N Dd2 &2C)1.;/=	? ?
    NU # 	G	  	J	8 8. Ns5   D 9)D( #D( 80D:D%$D%(D76D7:
E	c          
         Ub  Uc  U	b  [        S5      eSn[        R                  " U 5      n Ub  [        R                  " U5      OSn[        R                  R	                  U 5      nSnUb  [        R                  R                  X5      nUb  U R                  [        R                  R                  5      nUR                  [        R                  R                  5      nUUS[        U5       :w  a!  US:  a  [        SR                  X5      5        O)[        R                  R
                  " U[        U5      S 6 nU	bB  Uc   [        R                  R                  X5      nO[        R                  R                  X5      n[        U[        5      (       a  U/n[        [        U5      5      nU(       a  [        U5      S:  a  [        S5      eUb  UR                  U 5      nU(       a  U$ U
bd  [        R                  R!                  U 5      (       a@  [#        U
5      R%                  5       [#        U 5      R%                  5       R&                  ;  a  U$ 0 n[        R                  R)                  U 5      (       Ga  U Hm  nU(       a
  U S-   UU'   M  US:  a/  US	:  a  UOS
n[*        R,                  R/                  U US9nUUU'   MI  [*        R,                  R/                  U 5      nUUU'   Mo     USS USS nnUS:X  Gaq  U(       d   [        [        R0                  " U 5      R2                  5      n[4        R6                  " S[*        R,                  R8                  SUS-  5      nUR;                  5        H1  n[=        US5       nUR?                  S5      nSSS5        UW:w  d  M1    O   U$ U(       d  [        SR                  U 5      5         [C        U5       H  u  nnUU   n[D        RF                  " U UUSUUS9nUS:  d  M,  U(       d  M5  UUUS	-
        n[H        RJ                  " UUSS9(       d  M]  [        RL                  " U5        [        RN                  " UU5        M     WS:X  a  SnU$ U$ ! , (       d  f       N= f! [@         a     Nf = f! [D        RP                   a  nSnUS:  a  Us SnA$ U(       a  [        SR                  U 5      5        O
[        SS
S9  [R        RT                  RV                  =(       d    [R        RX                  " 5       n URZ                  R]                  U SS9R_                  U 5      n![        U!5         SnAU$ SnAf[`        [b        [@        4 ai  n"SnUS:  a  Us Sn"A"$ U(       a  [        SR                  U 5      5        O
[        SS
S9  [        U"Rd                  Rf                  S-   U"5         Sn"A"U$ Sn"A"ff = f)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	   zKThe stripdir path {!r} is not a valid prefix for source path {!r}; ignoringzXHardlinking of duplicated bytecode makes sense only for more than one optimization levelcr   r    )optimizationz.pyz<4sLLl    rb   zCompiling {!r}...)r4   r5   F)shallowz*** Error compiling {!r}...z*** )endbackslashreplace)errors:)4r9   r   r   r   basenamer   splitseplenr   r   r   intsortedsetsearchr   r   resolveparentsisfile	importlibutilcache_from_sourcestatst_mtimestructpackMAGIC_NUMBERvaluesopenreadr   	enumerate
py_compilecompilefilecmpcmpunlinklinkPyCompileErrorr=   stdoutencodinggetdefaultencodingmsgencodedecodeSyntaxErrorUnicodeError	__class____name__)#r!   r0   r1   r2   r   r3   r4   r5   r$   r%   r&   r'   rG   r    dfilefullname_partsstripdir_partsmo
opt_cfiles	opt_leveloptcfileheadtailmtimeexpectchandleactualindexokprevious_cfileerrrv   rx   es#                                      r"   r   r      s   6 X1Z5K G I 	I Gyy"H&.&:ryy"H77H%DET(!4!4^,@S-@AAqy 3396(3MO GGLL.^1D1E"FGE=GGLL6EGGLL3E(C  : c(m$H#h-!+ F G 	G 
~YYx N RWW^^H%=%=&&(X0F0F0H0P0PPNJ	ww~~h!I(03
9%>'0A~)2C&^^==%C > 9E,1Jy)%NN<<XFE,1Jy) " #2YRS	d5= 1 : :;E#[[)..2M2M)*EK,?AF!+!2!2!4!%.'%,\\"%5F /!V+!	 "5  ' )00:;"$(1((;$E9&y1E#++HeUD5>>OQB qy^^)3HUQY4G)H";;uneLLIIe,GGNE: )<@ 7#GN7N[ /.   ,, A:"N7>>xHI&b)::..J#2H2H2JggnnX6HnIPPQYZc

 N  w7 5A:"N7>>xHI&b)akk**S0!44 N5s   A<R Q0R #R %R 3R R $R 31R 0
Q>	:R 
RRW%	U.W4BUW(	W1W7AWWc                     Sn[         R                   HS  nU(       a  U[        R                  :X  a  U (       a  US:  a  [	        S5        M8  M:  U=(       a    [        UUSUUUUUS9nMU     U$ )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   r3   r4   r5   )r=   r   r   r   r   r   )	skip_curdirr   r1   r   r3   r4   r5   rG   r   s	            r"   r   r     sn     Gxxsbii'[qy23   	+!"3	#G  N    c                  
   SSK n U R                  SS9nUR                  SSSSSSS	9  UR                  S
[        SSS9  UR                  SSSSS9  UR                  SSSSSS9  UR                  SSSSS9  UR                  SSSSSS9  UR                  S S!S"SS#S9  UR                  S$S%S&SS'S9  UR                  S(S)S*SS+S9  UR                  S,S-S.S/S09  UR                  S1S2S3S4S59  UR                  S6S7S8[        S9S:9  [        R
                   Vs/ s H-  nUR                  R                  5       R                  S;S<5      PM/     nnUR                  S=[        U5      S>S?9  UR                  S@SA[        SBSCSD9  UR                  SESFSGSHS09  UR                  SISSJSKS9  UR                  5       nUR                  nUR                  (       a$  SSKnUR                  UR                  5      Ul        UR                  SL:X  a  SUl        UR                   b  UR                   nOUR"                  nUR$                  c  SM/Ul        ['        UR$                  5      S8:X  a"  UR(                  (       a  UR+                  SN5        UR,                  b+  UR.                  c  UR0                  b  UR+                  SO5        UR2                  (       af   UR2                  S<:X  a  [4        R6                  O[9        UR2                  SPSQ9 nU H"  n	UR;                  U	R=                  5       5        M$     SSS5        URF                  (       a>  URF                  R                  S<S;5      RI                  5       n
[        R
                  U
   nOSnSUn U(       Ga@  U GH7  n[J        RL                  RO                  U5      (       a  [Q        XR,                  URR                  UR                  UR@                  URT                  UUR.                  UR0                  UR$                  UR                  UR(                  SV9(       d  STnM  M  [W        XUR,                  URR                  UR                  UR@                  URT                  URX                  UUR.                  UR0                  UR$                  UR                  UR(                  SW9(       a  GM5  STnGM:     U$ [[        URT                  URR                  UR@                  USX9$ s  snf ! , (       d  f       GN= f! [>         a7    UR@                  SR:  a$  [C        SSRE                  UR2                  5      5         gTf = f! [\         a    UR@                  SR:  a  [C        SY5         gTf = f)ZzScript main program.r   Nz1Utilities to support installing Python libraries.)descriptionz-lstore_constr   z!don't recurse into subdirectories)actionconstr8   desthelpz-r	recursionzhcontrol the maximum recursion level. if `-l` and `-r` options are specified, then `-r` takes precedence.)typer   r   z-f
store_truer1   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   r8   r   z-br3   z0use legacy (pre-PEP3147) compiled file locationsz-dDESTDIRr0   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   r8   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REGEXPr2   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)r8   r   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 filesrM   zYHardlinking of duplicated bytecode makes sense only for more than one optimization level.z.-d cannot be used in combination with -s or -pzutf-8)rv   r	   zError reading file list {}FT)r5   r$   r%   r4   r&   r'   )rE   r5   r$   r%   r4   r&   r'   )r3   r1   r   r5   z
[interrupted])/argparseArgumentParseradd_argumentr[   rn   PycInvalidationModer    lowerreplacer\   
parse_argsr   r2   rero   r&   r   r   r   rZ   r'   errorr0   r$   r%   r   r=   stdinrk   r   stripr   r   r   r   r5   upperr   r   ra   r   r1   r3   r   rE   r   KeyboardInterrupt)r   parsermodeinvalidation_modesargscompile_destsr   r   flineivl_moder5   rG   r   s                 r"   mainr   >  sv   $$G % IF
]! $;@  B 3[<  > \N  P
W7A;  < \O  Q
ivt,  .
 j
 $4  6 l, $4  6 hT4H  J f7B  D 
#A  C k1 'D  F '1&D&DF&Dd ))//+33C=&D  F
- &'9 :7  9 XClK  M e/J  L
*<-<  > D%%Mww**TWW%R!~~!NN	NN	$
4??q T%8%8 C 	E yy!T__%@EF zz	#zz3#))g67;<D!((6 7 ))11#s;AAC&::8D G %77>>$'''iiTWW(,

DKK:K1537??156:6H6H7;7J7JL #(L 't		'+zz477DJJ'+{{DLL9J0426//04595G5G6:6I6IK K #(+ &, Nt{{$**&*jj2CE EuF`7 7  	zzA~299$**EF	R  ::>#$sU   4S,4T 5)S1T :D:U 9U )U 1
T ;T  T >UU%U/.U/__main__)r   )	NNFNr   Fr   r   N)NFNr   Fr   N)r   r   Fr   Fr   N)__doc__r   r=   importlib.utilrb   rn   rg   rp   	functoolsr   pathlibr   __all__r   r   r   r   r   r~   r[   exit_statusexit r   r"   <module>r      s    
 
      
7.. 7<EF"&U48tEUn CD(*#'S59d#ESj AB(*#'DVr z$&j/KHH[ r   