Yf- @ s> d Z d d l Z d d l Z d d l Z d d l Z d d l Z y d d l m Z Wn e k rp d Z Yn Xd d l m Z d d d g Z d d d d d Z d d d d d d d d d d Z d d d d d d d d Z d d d d d d d d Z d d Z e d k r:e e Z e j e d S)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)ProcessPoolExecutor)partialcompile_dircompile_filecompile_path c c sa | s t d j | y t j | } Wn7 t k re | d k r[ t d j | g } Yn X| j x | D] } | d k r qw t j j | | } | d k r t j j | | } n d } t j j | s | Vqw | d k rw | t j k rw | t j k rw t j j | rw t j j | rw t | d | d | d d | Ed Hqw Wd S) NzListing {!r}... zCan't list {!r}__pycache__r ddir maxlevels quiet) printformatoslistdirOSErrorsortpathjoinisdircurdirpardirislink _walk_dir)dirr r r namesnamefullnamedfile r //opt/alt/python35/lib64/python3.5/compileall.pyr s, *%r Fr c C s | d k r$ | d k r$ t d t | d | d | d | } d } | d k r | d k r t d k r | pu d } t d | U } | j t t d | d | d | d | d | d | | } t | d d } Wd QRXn5 x2 | D]* } t | | | | | | | s d } q W| 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 Nr z%workers must be greater or equal to 0r r r r Zmax_workersforcerxlegacyoptimizedefault) ValueErrorr r mapr r min)r r r r" r# r r$ r% workersfilessuccessZexecutorZresultsfiler r r! r 4 s( $ c C s' d } t j j | } | d k r<