a XC?h�N� @s�ddlZddlZddlZddlZddlZddlZddlmZddl m Z gd�Z ddd�Z dddddd �d d �Z dddddd �d d�Zddd�Zdd�Zedkr�ee� �Ze�e�dS)�N)�partial)�Path)� compile_dir� compile_file� compile_pathccs�|dkrt|tj�rt�|�}|s0td�|��zt�|�}Wn,tyj|dkrbtd�|��g}Yn0|��|D]|}|dkr�qxtj � ||�}tj � |�s�|Vqx|dkrx|tj krx|tj krxtj � |�rxtj �|�sxt||d|d�EdHqxdS)N�zListing {!r}...zCan't list {!r}� __pycache__r�)� maxlevels�quiet)� isinstance�os�PathLike�fspath�print�format�listdir�OSError�sort�path�join�isdir�curdir�pardir�islink� _walk_dir)�dirr r �names�name�fullname�r �//opt/alt/python39/lib64/python3.9/compileall.pyrs2     � � �rF�����r ��stripdir� prependdir� limit_sl_dest�hardlink_dupesc CsNd}|dur$| dus| dur$td��|dur8|} |} d}|dkrHtd��|dkrxzddlm}Wntyvd}Yn0|dur�t��}t|||d�}d}|dk�r|du�r|p�d}||d��D}|�tt ||||||| | | | | d � |�}t |dd �}Wd�n1�s 0Yn2|D],}t |||||||| | | | | d � �sd }�q|S) N�PDestination dir (ddir) cannot be used in combination with stripdir or prependdirrz%workers must be greater or equal to 0r )�ProcessPoolExecutor)r r T)Z max_workers) �ddir�force�rxr �legacy�optimize�invalidation_moder$r%r&r')�defaultr#F) � ValueErrorZconcurrent.futuresr)� ImportError�sys�getrecursionlimitr�maprr�min)rr r*r+r,r r-r.�workersr/r$r%r&r'r)�files�successZexecutorZresults�filer r r!r0sX   � � . �rc& Cs�|dur |dus| dur td��d} |dkrBt|tj�rBt�|�}tj�|�} d}|durhtj�|| �}|dur�|�tjj �}|�tjj �}t |�}t ||�D]\}}||kr�|� |�q�tjj|�}| dur�|dur�tj�| |�}ntj�| |�}t|t ��r|g}tt|��}| �r.t|�dk�r.td��|du�rL|�|�}|�rL| S| du�r�tj�|��r�t| ���t|���jv�r�| Si}tj�|��r�|D]d}|�r�|d||<nJ|dk�r�|dk�r�|nd}tjj||d �}|||<ntj�|�}|||<�q�| dd �| d d�}}|d k�r�|�s�z�t t�|�j�}t�d tjjd|d @�}|��D]L}t |d��}|�!d�}Wd�n1�s�0Y||k�r\�q��q\| WSWnt"�y�Yn0|�s�t#d�$|��z�t%|�D]p\}}||}t&j'|||d||d�} |dk�r�| �r�|||d}!t(j)||!dd��r�t�*|�t�+|!|��q�W�nt&j,�y�}"z|d} |dk�r�| WYd}"~"S|�r�t#d�$|��n t#ddd�t-j.j/�p�t-�0�}#|"j1j2|#dd��3|#�}$t#|$�WYd}"~"n�d}"~"0t4t5t"f�yp}%z^d} |dk�r(| WYd}%~%S|�r>t#d�$|��n t#ddd�t#|%j6j7d|%�WYd}%~%nd}%~%00| dk�r�d} | S)Nr(TrzXHardlinking of duplicated bytecode makes sense only for more than one optimization level�crr �)� optimization�����z.pyz<4sLLl���rb� zCompiling {!r}...)r.r/F)Zshallowz*** Error compiling {!r}...z*** )�end�backslashreplace)�errors�:)8r1r r rrr�basenamer�split�sep�list�zip�remove�int�sorted�set�len�searchrrZresolve�parents�isfile� importlib�util�cache_from_source�stat�st_mtime�structZpack� MAGIC_NUMBER�values�open�readrrr� enumerate� py_compile�compile�filecmpZcmp�unlink�link�PyCompileErrorr3�stdout�encoding�getdefaultencoding�msg�encode�decode� SyntaxError� UnicodeError� __class__�__name__)&rr*r+r,r r-r.r/r$r%r&r'r9r�dfileZfullname_partsZstripdir_partsZ ddir_partsZspartZopartZmoZ opt_cfiles� opt_level�opt�cfile�head�tail�mtimeZexpectZchandleZactual�index�okZprevious_cfile�errrdrf�er r r!r{s�         �     �  *    �     ( rc CsTd}tjD]D}|r|tjkr2|r2|dkrNtd�q |oLt||d|||||d�}q |S)NTrzSkipping current directory)r r-r.r/)r3rr rrr) Z skip_curdirr r+r r-r.r/r9rr r r!rs   � rc Cs�ddl}|jdd�}|jddddddd�|jd td d d �|jd dddd�|jdddddd�|jddddd�|jdddddd�|jdd d!dd"d�|jd#d$d%dd&d�|jd'd(d)dd*d�|jd+d,d-d.d/�|jd0d1d2d3d4�|jd5d6d7td8d9�d:d;�tjD�}|jd�|jd?d@tdAdBdC�|jdDdEdFdGd/�|jdHddIdJd�|��}|j}|j �r�ddl }|� |j �|_ |j dKk�r�d|_ |j du�r�|j }n|j}|jdu�r�dLg|_t|j�d7k�r�|j�r�|�dM�|jdu�r|jdu�s |jdu�r|�dN�|j�r�z\|jdOk�r0tjnt|j��*}|D]}|�|����q@Wd�n1�sl0YWn2t�y�|jdPk�r�tdQ�|j��YdRS0|j �r�|j �!dOdS��"�} tj| } nd} dT} z�|�r~|D]�} t#j$�%| ��r4t&| |j|j'|j |j|j(| |j|j|j|j |jdU� �stdR} n@t)| ||j|j'|j |j|j(|j*| |j|j|j|j |jdV��s�dR} �q�| WSt+|j(|j'|j| dW�WSWn*t,�y�|jdPk�r�tdX�YdRS0dTS)YNrz1Utilities to support installing Python libraries.)Z descriptionz-lZ store_constr z!don't recurse into subdirectories)�actionZconstr0�dest�helpz-r� recursionzhcontrol the maximum recursion level. if `-l` and `-r` options are specified, then `-r` takes precedence.)�typeryrzz-f� store_truer+z/force rebuild even if timestamps are up to date)rxryrzz-q�countr zIoutput only error messages; -qq will suppress the error messages as well.)rxryr0rzz-br-z0use legacy (pre-PEP3147) compiled file locationsz-dZDESTDIRr*z�directory to prepend to file paths for use in compile-time tracebacks and in runtime tracebacks in cases where the source file is unavailable)�metavarryr0rzz-sZSTRIPDIRr$z�part of path to left-strip from path to source file - for example buildroot. `-d` and `-s` options cannot be specified together.z-pZ PREPENDDIRr%z�path to add as prefix to path to source file - for example / to make it absolute when some part is removed by `-s` option. `-d` and `-p` options cannot be specified together.z-xZREGEXPr,zskip files matching the regular expression; the regexp is searched for in the full path of each file considered for compilationz-iZFILE�flistzzadd all the files and directories listed in FILE to the list considered for compilation; if "-", names are read from stdin)rryrz� compile_destzFILE|DIR�*zrzero or more file and directory names to compile; if no arguments given, defaults to the equivalent of -l sys.path)r�nargsrzz-jz --workersr zRun compileall concurrently)r0r|rzcSsg|]}|j���dd��qS)�_�-)r�lower�replace)�.0�moder r r!� gs�zmain..z--invalidation-modez�set .pyc invalidation mode; defaults to "checked-hash" if the SOURCE_DATE_EPOCH environment variable is set, and "timestamp" otherwise.)�choicesrzz-o�append� opt_levelsz�Optimization levels to run compilation with. Default is -1 which uses the optimization level of the Python interpreter itself (see -O).)rxr|ryrzz-eZDIRr&z+Ignore symlinks pointing outsite of the DIRz--hardlink-dupesr'zHardlink duplicated pyc filesr<r"zYHardlinking of duplicated bytecode makes sense only for more than one optimization level.z.-d cannot be used in combination with -s or -pr�rzError reading file list {}Fr�T)r/r$r%r.r&r')r7r/r$r%r.r&r')r-r+r r/z [interrupted])-�argparse�ArgumentParser� add_argumentrKr]�PycInvalidationModerL� parse_argsr�r,�rer^r&r{r r�rNr'�errorr*r$r%r�r3�stdinrZr��striprr rrr/r��upperr rrQrr+r-rr7r�KeyboardInterrupt) r��parserZinvalidation_modes�argsZ compile_destsr�r �f�lineZivl_moder/r9ryr r r!�main2s� � � � � � � � � � � � ��� � ��     �� 6  �  �  �  r��__main__)r) NNFNrFr"r N)NFNrFr"N)r rFrFr"N)r r3�importlib.utilrRr]rWr_� functoolsr�pathlibr�__all__rrrrr�rlrKZ exit_status�exitr r r r!� sB   �� K�� � "