a �DOg�Q�@sddlZddlZddlZddlZddlZddlmZddlm Z ddl m Z ddl m Z ddlmZdd�Zd d �Zd d �Zd d�Zdadd�Zdd�Zd)dd�Zdaaadd�Zdd�Zd*dd�Zdd�Zd+dd �Zd!d"�Zd,d#d$�Z d-d%d&�Z!Gd'd(�d(�Z"dS).�N)�DistutilsPlatformError)�newer)�spawn)�log)�DistutilsByteCompileErrorc Cs�tjdkrFdtj��vrdSdtj��vr.dSdtj��vr@dStjSdtjvrZtjdStjd ksnttd �sttjSt��\}}}}}|��� d d �}|� d d�}|� d d�}|dd�dkr�d||fS|dd�dk�r,|ddk�r�d}dt |d�d|dd�f}ddd�}|d|tj 7}n�|dd�dk�rPddl m }|�S|dd �d!k�r�d!}t�d"tj�}|�|�}|�r�|��}n>|dd �d#k�r�ddl} ddl} | �| j��|||�\}}}d$|||fS)%N�ntZamd64� win-amd64z(arm)� win-arm32z(arm64)z win-arm64Z_PYTHON_HOST_PLATFORM�posix�uname�/�� �_�-��linuxz%s-%sZsunosr�5Zsolarisz%d.%s��Z32bitZ64bit)i���l����z.%sZaix)� aix_platform��cygwinz[\d.]+�darwinz%s-%s-%s)�os�name�sys�version�lower�platform�environ�hasattrr �replace�int�maxsizeZ _aix_supportr�re�compile�ASCII�match�group� _osx_supportZdistutils.sysconfigZget_platform_osxZ sysconfigZget_config_vars) Zosname�host�releaser�machineZbitnessrZrel_re�mr*� distutils�r0�&/usr/lib64/python3.9/distutils/util.py�get_host_platformsP           � r2cCs8tjdkr.dddd�}|�tj�d��p,t�St�SdS)Nr�win32rr )Zx86Zx64ZarmZVSCMD_ARG_TGT_ARCH)rr�getr r2)ZTARGET_TO_PLATr0r0r1� get_platformbs �r5cCsztjdkr|S|s|S|ddkr.td|��|ddkrFtd|��|�d�}d|vrd|�d�qP|sntjStjj|�S)Nr rzpath '%s' cannot be absolute�����zpath '%s' cannot end with '/'�.)r�sep� ValueError�split�remove�curdir�path�join)�pathname�pathsr0r0r1� convert_pathms       rAcCs�tjdkr� splitdriver)Znew_rootr?�driver=r0r0r1� change_root�s     rGc CsvtrdStjdkrXdtjvrXz$ddl}|�t���dtjd<WnttfyVYn0dtjvrnt �tjd<dadS)Nr �HOMErrZPLATrB) �_environ_checkedrrr �pwd�getpwuid�getuid� ImportError�KeyErrorr5)rJr0r0r1� check_environ�s   rOc CsXt�|fdd�}zt�d||�WStyR}ztd|��WYd}~n d}~00dS)NcSs,|�d�}||vrt||�Stj|SdS)NrB)r)�strrr )r(� local_varsZvar_namer0r0r1�_subst�s  zsubst_vars.._substz\$([a-zA-Z_][a-zA-Z_0-9]*)zinvalid variable '$%s')rOr%�subrNr9)�srQrR�varr0r0r1� subst_vars�s  rV�error: cCs |t|�S�N)rP)�exc�prefixr0r0r1�grok_environment_error�sr[cCs(t�dtj�at�d�at�d�adS)Nz [^\\\'\"%s ]*z'(?:[^'\\]|\\.)*'z"(?:[^"\\]|\\.)*")r%r&�string� whitespace� _wordchars_re� _squote_re� _dquote_rer0r0r0r1� _init_regex�s racCs�tdurt�|��}g}d}|�r�t�||�}|��}|t|�krZ|�|d|���q�||tjvr�|�|d|��||d�� �}d}n�||dkr�|d|�||dd�}|d}n�||dkr�t �||�}n*||dkr�t �||�}nt d||��|du�r t d||��|��\}}|d|�||d|d�||d�}|��d}|t|�kr|�|��q�q|S) NrrCrB�'�"z!this can't happen (bad char '%c')z"bad string (mismatched %s quotes?)r)r^ra�stripr(�end�len�appendr\r]�lstripr_r`� RuntimeErrorr9�span)rT�words�posr.reZbegr0r0r1� split_quoted�s>        ,   rmcCsP|dur6d|j|f}|dd�dkr6|dd�d}t�|�|sL||�dS)Nz%s%r�����z,)r�))�__name__r�info)�func�args�msg�verbose�dry_runr0r0r1�execute s  rwcCs2|��}|dvrdS|dvr dStd|f��dS)N)�yZyes�t�trueZon�1rB)�n�no�fZfalseZoff�0rzinvalid truth value %r)rr9)�valr0r0r1� strtobool3s r�rBc Csjddl}tjrtd��|dur*do(|dk}|�sVzddlm} | d�\} } Wn,tyxddlm} d| d�} } Yn0t� d| �|�s| dur�t � | d�} n t | d�} | �L| � d �| � d �tt|��d �| � d |||||f�Wd�n1�s0Ytjg}|�|���|�| �t||d �tt j| fd| |d ��nddlm}|D]�}|dd�dk�r��qf|dk�r�|dk�r�dn|}tjj||d�}n tj�|�}|}|�r�|dt|��|k�r�td||f��|t|�d�}|�rt j�||�}t j� |�}|�rf|�s2t!||��rTt� d||�|�sb||||�nt�"d||��qfdS)Nrzbyte-compiling is disabled.F)�mkstemp�.py)�mktempz$writing byte-compilation script '%s'�wz2from distutils.util import byte_compile files = [ z, z] z� byte_compile(files, optimize=%r, force=%r, prefix=%r, base_dir=%r, verbose=%r, dry_run=0, direct=1) )rvz removing %s)r&�����r )� optimizationz1invalid prefix: filename %r doesn't start with %rzbyte-compiling %s to %sz%skipping byte-compilation of %s to %s)#� subprocessr�dont_write_bytecoder�tempfiler�rMr�rrqr�fdopen�open�writer>�map�repr� executable�extend�"_optim_args_from_interpreter_flagsrgrrwr;� py_compiler&� importlib�util�cache_from_sourcerfr9r=�basenamer�debug)Zpy_files�optimize�forcerZ�base_dirrurvZdirectr�r�Z script_fd� script_namer�Zscript�cmdr&�file�opt�cfile�dfileZ cfile_baser0r0r1� byte_compileCst$         �&  �   � � �r�cCs|�d�}d}|�|�S)N� z )r:r>)�header�linesr8r0r0r1� rfc822_escape�s r�cCsV|sdSddlm}m}Gdd�d|�}|dur8|d�}|||d�}|j|dd�dS) Nr)�RefactoringTool�get_fixers_from_packagec@s$eZdZdd�Zdd�Zdd�ZdS)z*run_2to3..DistutilsRefactoringToolc_stj|g|�R�dSrX)r�error)�selfrtrs�kwr0r0r1� log_error�sz4run_2to3..DistutilsRefactoringTool.log_errorcWstj|g|�R�dSrX)rrq�r�rtrsr0r0r1� log_message�sz6run_2to3..DistutilsRefactoringTool.log_messagecWstj|g|�R�dSrX)rr�r�r0r0r1� log_debug�sz4run_2to3..DistutilsRefactoringTool.log_debugN)rp� __module__� __qualname__r�r�r�r0r0r0r1�DistutilsRefactoringTool�sr�z lib2to3.fixes)�optionsT)r�)Zlib2to3.refactorr�r�Zrefactor)�files� fixer_namesr��explicitr�r�r��rr0r0r1�run_2to3�s  r�c Csddlm}ddlm}ddlm}|�} t��} t�|�z| � �Wt�| �n t�| �0| j | j dd�<|r�|� �D]} | � �} | s�q|| �| �q|g} | j D]L} tj�|| �}|tj�|��|tj�|| �|dd�}|dr�| �|�q�tdd�| D�|||d �| S) Nr)�mkpath)� copy_file)�FileListrB)�updatecSsg|]}|���d�r|�qS)r�)r�endswith)�.0�fnr0r0r1� �z$copydir_run_2to3..)r�r�r�)Zdistutils.dir_utilr�Zdistutils.file_utilr�Zdistutils.filelistr�r�getcwd�chdir�findallZallfilesr�� splitlinesrdZprocess_template_liner=r>�dirnamergr�)�src�dest�templater�r�r�r�r�r�Zfilelistr<�lineZcopied�filenameZoutname�resr0r0r1�copydir_run_2to3�s2        �r�c@s eZdZdZdZdZdd�ZdS)� Mixin2to3NcCst||j|j|j�SrX)r�r�r�r�)r�r�r0r0r1r�.szMixin2to3.run_2to3)rpr�r�r�r�r�r�r0r0r0r1r�sr�)rW)Nrr)rrNNrBrN)NNN)NNNN)#rr%�importlib.utilr�r\rZdistutils.errorsrZdistutils.dep_utilrZdistutils.spawnrr/rrr2r5rArGrIrOrVr[r^r_r`rarmrwr�r�r�r�r�r�r0r0r0r1�sD     P   = �  � !