3 2a]/@sddlZddlZddlZddlZddlZddlmZdddgZdddZ dd dZ dd dZ dd dZ ddZ edkree ZejedS)N)partial compile_dir compile_file compile_path ccs |dkrt|tjrtj|}|s0tdj|ytj|}Wn.tk rl|dkrdtdj|g}YnX|jx|D]}|dkrq|tj j ||}|dk rtj j ||}nd}tj j |s|Vq||dkr||tj kr||tj kr|tj j |r|tj j| r|t|||d|dEdHq|WdS)NzListing {!r}...zCan't list {!r} __pycache__r)ddir maxlevelsquiet) isinstanceosPathLikefspathprintformatlistdirOSErrorsortpathjoinisdircurdirpardirislink _walk_dir)dirr r r namesnamefullnamedfiler"//opt/alt/python36/lib64/python3.6/compileall.pyrs0    rFr c Csd} |dk rP|dkrtdn2|dkrPyddlm} Wntk rNd}YnXt||||d} d} |dk r|dkr| dk r|pd}| |d0} | jtt||||||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)r forcerxr legacyoptimize)defaultF) ValueErrorconcurrent.futuresr$ ImportErrorrmaprrmin)rr r r&r'r r(r)workersr$filessuccessexecutorresultsfiler"r"r#r2s6     cCsd}|dkr"t|tjr"tj|}tjj|}|dk rFtjj||} nd} |dk rd|j|} | rd|Stjj|r|r|d} nB|dkr|dkr|nd} t j j || d} n t j j |} tjj | } |dd|dd}}|d kr|sXyTt tj|j}tjd t j j|}t| d }|jd }WdQRX||kr>|SWntk rVYnX|sltd j|ytj|| | d|d}Wntjk r}zdd}|dkr|S|rtdj|n tddd|jjtjjdd}|j tjj}t|WYdd}~Xn~t!t"tfk rv}zLd}|dkr2|S|rHtdj|n tdddt|j#j$d|WYdd}~XnX|dkrd}|S)NTrcrr ) optimizationz.pyz<4slrbzCompiling {!r}...)r)Fz*** Error compiling {!r}...z*** )endbackslashreplace)errors:r@)%r rrrrbasenamersearchisfile importlibutilcache_from_sourcedirnameintstatst_mtimestructpack MAGIC_NUMBERopenreadrrr py_compilecompilePyCompileErrormsgencodesysstdoutencodingdecode SyntaxError UnicodeError __class____name__)r r r&r'r r(r)r2rr!mocfileopt cache_dirheadtailmtimeexpectchandleactualokerrrSer"r"r#rbsx                  $ c CsXd}xNtjD]D}| s |tjkr6|r6|dkrPtdq |oNt||d||||d}q W|S)NTrzSkipping current directory)r r(r))rUrrrrr) skip_curdirr r&r r(r)r2rr"r"r#rs    c Cszddl}|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/d0td1d2|j}|j}|jrddl}|j|j|_|j dk r|j }n|j }|j ryJ|j d3kr4t j nt|j $}x|D]}|j|jqFWWdQRXWn2tk r|jd4krtd5j|j d6SX|jdk r|jpd|_d7}y|r4xj|D]b} tjj| rt| |j|j|j|j|js*d6}n*t| ||j|j|j|j|j|jd8sd6}qW|St|j|j|jd9SWn*tk rt|jd4krptd:d6SXd7S);Nrz1Utilities 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.)typerorpz-f store_truer&z/force rebuild even if timestamps are up to date)rmrorpz-qcountr zIoutput only error messages; -qq will suppress the error messages as well.)rmror*rpz-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)metavarror*rpz-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)rvrorp compile_destzFILE|DIR*zrzero or more file and directory names to compile; if no arguments given, defaults to the equivalent of -l sys.path)rvnargsrpz-jz --workersr zRun compileall concurrently)r*rrrp-rzError reading file list {}FT)r0)r(r&r z [interrupted]) argparseArgumentParser add_argumentrH parse_argsrzr'rerQrqr ryrUstdinrNappendstriprr rrr0rrrCrr r&r(rrKeyboardInterrupt) r~parserargs compile_destsrr fliner2ror"r"r#mains~             "        r__main__)Nrr)rNFNrFrr r)NFNrFrr)r rFrFr)rrUimportlib.utilrDrPrK functoolsr__all__rrrrrr\rH exit_statusexitr"r"r"r# s"    / R [