B
5$D @ s d dl Z d dlZd dlZd dlZd dlZd dlmZ dddgZdddZ dddZ
d
d ZdddZdddZ
dd Zedkree Zee dS ) N)partialcompile_dircompile_filecompile_path
c c s" |dk rt | tjrt| } |s0td| yt| }W n. tk
rl |dk rdtd| g }Y nX | x|D ]}|dkrq|tj
| |}|d k rtj
||}nd }tj |s||fV q||dkr||tjkr||tj
kr|tj |r|tj |s|t|||d |dE d H q|W d S )N zListing {!r}...zCan't list {!r}__pycache__r )ddir maxlevelsquiet)
isinstanceosPathLikefspathprintformatlistdirOSErrorsortpathjoinisdircurdirpardirislink _walk_dir)dirr
r r namesnamefullnamedfile r" //opt/alt/python37/lib64/python3.7/compileall.pyr s0
r Fr c
C s d }
|d k rP|dk rt dn2|dkrPyddlm}
W n tk
rN d}Y nX t| |||d}d}|d k r|dkr|
d k r|pd }|
|d0}
|
tt|||||| d|}t|dd }W d Q R X n,x*|D ]"\}}t |||||||| sd
}qW |S )Nr z%workers must be greater or equal to 0r )ProcessPoolExecutor)r r r
T)max_workers)forcerxr legacyoptimizeinvalidation_mode)defaultF)
ValueErrorconcurrent.futuresr% ImportErrorr mapr _compile_file_tupleminr )r r r
r' r( r r) r* workersr+ r% files_and_ddirssuccessexecutorresultsfiler! r" r" r# r 2 s6
c K s | \}}t ||f|S )N)r )file_and_dfilekwargsr8 r! r" r" r# r1 e s r1 c
C s d}|dk r"t | tjr"t| } tj| } |d k rFtj|| }
nd }
|d k rd|| }|rd|S tj| r|r| d }nB|dkr|dkr|nd}
t j
j| |
d}nt j
| }tj|}| d d | dd }}|d kr|sZyVt
t| j}td
t j
jd|}t|d}|d}W d Q R X ||kr@|S W n tk
rX Y nX |sntd
| ytj| ||
d||d}W n tjk
r } zbd}|dkr|S |rtd| ntddd |jjtjjdd}| tjj}t| W d d }~X Y n~ t!t"tfk
rz } zJd}|dkr6|S |rLtd| ntddd t|j#j$d | W d d }~X Y nX |dkrd}|S )NTr cr r )optimizationz.pyz<4sllrb zCompiling {!r}...)r* r+ Fz*** Error compiling {!r}...z*** )endbackslashreplace)errors:)%r
r r r r basenamer searchisfile importlibutilcache_from_sourcedirnameintstatst_mtimestructpackMAGIC_NUMBERopenreadr r r
py_compilecompilePyCompileErrormsgencodesysstdoutencodingdecodeSyntaxErrorUnicodeError __class____name__)r r
r' r( r r) r* r+ r5 r r! mocfileopt cache_dirheadtailmtimeexpectchandleactualokerrrW er" r" r# r j sz
$
c C sX d}xNt jD ]D}|r|tjkr4| r4|dk rPtd q|oNt||d |||||d}qW |S )NTr zSkipping current directory)r r) r* r+ )rY r r r r r ) skip_curdirr r' r r) r* r+ r5 r r" r" r# r s
c
C s dd l } | jdd}|jddddddd |jd
tddd
|jddddd |jdddddd |jddddd |jdddd dd |jd d!d"d d#d |jd$d%d&d'd( |jd)d*d+d,d- |jd.d/d0td1d2 d3d4 tjD }|jd5t|d6d7 | }|j}|j r$dd l
}||j |_ |jd k r8|j}n|j
}|jryJ|jd8krZtjnt|j$}x|D ]}|| qlW W d Q R X W n2 tk
r |jd9k rtd:|j d;S X |jd k r|jpd |_|jr|jd8d< } tj| }
nd }
d=}y|rxp|D ]h}tj|rTt||j |j!|j |j|j"|
d>sd;}n,t#|||j |j!|j |j|j"|j|
d? sd;}qW |S t$|j"|j!|j|
d@S W n* t%k
r |jd9k rtdA d;S X d=S )BNr z1Utilities to support installing Python libraries.)descriptionz-lstore_constr r z!don't recurse into subdirectories)actionconstr, desthelpz-r recursionzhcontrol the maximum recursion level. if `-l` and `-r` options are specified, then `-r` takes precedence.)typers rt z-f
store_truer' z/force rebuild even if timestamps are up to date)rq rs rt z-qcountr zIoutput only error messages; -qq will suppress the error messages as well.)rq rs r, rt z-br) z0use legacy (pre-PEP3147) compiled file locationsz-dDESTDIRr
zdirectory to prepend to file paths for use in compile-time tracebacks and in runtime tracebacks in cases where the source file is unavailable)metavarrs r, rt z-xREGEXPr( zskip 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)rz rs rt compile_destzFILE|DIR*zrzero or more file and directory names to compile; if no arguments given, defaults to the equivalent of -l sys.path)rz nargsrt z-jz --workersr zRun compileall concurrently)r, rv rt c S s g | ]}|j d dqS )_-)r lowerreplace).0moder" r" r#