B 5$D @sddlZddlZddlZddlZddlZddlmZdddgZdddZ dd dZ d dZ dddZ dddZ ddZedkree ZeedS)N)partial compile_dir compile_file compile_path ccs"|dkrt|tjrt|}|s0td|yt|}Wn.tk rl|dkrdtd|g}YnX|x|D]}|dkrq|tj ||}|dk rtj ||}nd}tj |s||fVq||dkr||tj kr||tj kr|tj |r|tj |s|t|||d|dEdHq|WdS)NzListing {!r}...zCan't list {!r} __pycache__r)ddir maxlevelsquiet) isinstanceosPathLikefspathprintformatlistdirOSErrorsortpathjoinisdircurdirpardirislink _walk_dir)dirr r r namesnamefullnamedfiler"-/opt/alt/python37/lib/python3.7/compileall.pyrs0     rFr c  Csd} |dk rP|dkrtdn2|dkrPyddlm} Wntk rNd}YnXt||||d} d} |dk r|dkr| dk r|pd}| |d0} | tt|||||| d| }t|dd } WdQRXn,x*| D]"\}}t |||||||| sd } qW| S) Nrz%workers must be greater or equal to 0r )ProcessPoolExecutor)r r r T) max_workers)forcerxr legacyoptimizeinvalidation_mode)defaultF) ValueErrorconcurrent.futuresr% ImportErrorrmapr_compile_file_tupleminr)rr r r'r(r r)r*workersr+r%files_and_ddirssuccessexecutorresultsfiler!r"r"r#r2s6     cKs|\}}t||f|S)N)r)file_and_dfilekwargsr8r!r"r"r#r1esr1c Csd}|dkr"t|tjr"t|}tj|} |dk rFtj|| } nd} |dk rd||} | rd|Stj|r|r|d} nB|dkr|dkr|nd} t j j || d} n t j |} tj | }| dd| dd}}|d kr|sZyVt t|j}td t j jd|}t| d }|d }WdQRX||kr@|SWntk rXYnX|sntd |ytj|| | d||d}Wntjk r }zbd}|dkr|S|rtd|n tddd|jjtjjdd}| tjj}t|Wdd}~XYn~t!t"tfk rz}zJd}|dkr6|S|rLtd|n tdddt|j#j$d|Wdd}~XYnX|dkrd}|S)NTrcrr ) optimizationz.pyz<4sllrb zCompiling {!r}...)r*r+Fz*** Error compiling {!r}...z*** )endbackslashreplace)errors:)%r rrrrbasenamersearchisfile importlibutilcache_from_sourcedirnameintstatst_mtimestructpack MAGIC_NUMBERopenreadrrr py_compilecompilePyCompileErrormsgencodesysstdoutencodingdecode SyntaxError UnicodeError __class____name__)r r r'r(r r)r*r+r5rr!mocfileopt cache_dirheadtailmtimeexpectchandleactualokerrrWer"r"r#rjsz                  $ c CsXd}xNtjD]D}|r|tjkr4|r4|dkrPtdq |oNt||d|||||d}q W|S)NTrzSkipping current directory)r r)r*r+)rYrrrrr) skip_curdirr r'r r)r*r+r5rr"r"r#rs   c Csddl}|jdd}|jddddddd |jd td d d |jddddd|jdddddd|jddddd|jdddddd|jd d!d"dd#d|jd$d%d&d'd(|jd)d*d+d,d-|jd.d/d0td1d2d3d4tjD}|jd5t|d6d7|}|j}|j r$ddl }| |j |_ |j dk r8|j }n|j }|jryJ|jd8krZtjnt|j$}x|D]}||qlWWdQRXWn2tk r|jd9krtd:|jd;SX|jdk 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| St$|j"|j!|j| d@SWn*t%k r|jd9krtdAd;SXd=S)BNrz1Utilities to support installing Python libraries.) descriptionz-l store_constrr 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.)typersrtz-f store_truer'z/force rebuild even if timestamps are up to date)rqrsrtz-qcountr zIoutput only error messages; -qq will suppress the error messages as well.)rqrsr,rtz-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)metavarrsr,rtz-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)rzrsrt compile_destzFILE|DIR*zrzero or more file and directory names to compile; if no arguments given, defaults to the equivalent of -l sys.path)rznargsrtz-jz --workersr zRun compileall concurrently)r,rvrtcSsg|]}|jddqS)_-)rlowerreplace).0moder"r"r# szmain..z--invalidation-modezset .pyc invalidation mode; defaults to "checked-hash" if the SOURCE_DATE_EPOCH environment variable is set, and "timestamp" otherwise.)choicesrtrrzError reading file list {}FrT)r+)r3r+)r)r'r r+z [interrupted])&argparseArgumentParser add_argumentrLrTPycInvalidationModesorted parse_argsr~r(rerUrur r}rYstdinrRappendstriprr rrr3r+rupperrrrGrr r'r)rrKeyboardInterrupt) rparserinvalidation_modesargs compile_destsrr flineivl_moder+r5rsr"r"r#mains              "            r__main__)Nrr) rNFNrFr$r N)NFNrFr$N)r rFrFr$N)rrYimportlib.utilrHrTrO functoolsr__all__rrr1rrrr`rL exit_statusexitr"r"r"r# s*    1 T l