B 5$D @ s d Z ddlZddlZddlZddlZddlZddlmZ dddgZ ddd Z dd dZdd ZdddZ dddZdd Zedkree Zee dS )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, if 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)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} |dk rP|dk rt dn2|dkrPyddlm} W n tk rN d}Y nX t| |||d}d}|dk r|dkr| dk r|pd}| |d0} | tt|||||| d |}t|dd }W dQ R X n,x*|D ]"\}}t |||||||| sd}qW |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 10) 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: optimization level or -1 for level of the interpreter workers: maximum number of parallel workers invalidation_mode: how the up-to-dateness of the pyc will be checked Nr z%workers must be greater or equal to 0r )ProcessPoolExecutor)r r r T)Zmax_workers)forcerxr legacyoptimizeinvalidation_mode)defaultF) ValueErrorZconcurrent.futuresr% ImportErrorr mapr _compile_file_tupleminr )r r r r&