U ��.eTi� @s�dZddlZddlZddlZddlZddlmZmZz ddlZWne k r\ddl ZYnXdddddd d d d d dg Z dd�Z ej r�ej�e ej ��Zn e e���Zejdkr�dedd���kr�e ej�ee��Zejdk�r dedd���k�r e ej�eee��Zejdk�rBdedd���k�rBe ej�eee��Zdd�Ze�Zdadd�Ze��Ze�d�Zdd�Zej��dZ ejdd �Z!e de d!Z"ej�#ej$�Z%ej�#ej&�Z'da(dZ)d"d#�Z*d$d%�Z+d&d'�Z,d(d)�Z-d*d+�Z.d,d-�Z/dEd.d/�Z0d0d�Z1d1d2�Z2d3d4�Z3dFd5d�Z4d6d�Z5d7d �Z6d8d �Z7e.�dd9fd:d �Z8e.�dd9fd;d�Z9dd �ZdBdC�Z?e@dDk�r�e?�dS)Gz-Access to Python's configuration information.�N)�pardir�realpath�get_config_h_filename�get_config_var�get_config_vars�get_makefile_filename�get_path�get_path_names� get_paths� get_platform�get_python_version�get_scheme_names�parse_config_hcCs(z t|�WStk r"|YSXdS�N)r�OSError)�path�r�K/usr/lib/python3.8/site-packages/pip/_vendor/distlib/_backport/sysconfig.py�_safe_realpath"s r�ntZpcbuildi����z\pc\vi����z\pcbuild\amd64i����cCs,dD]"}tj�tj�td|��rdSqdS)N)z Setup.distz Setup.localZModulesTF)�osr�isfile�join� _PROJECT_BASE)�fnrrr�is_python_build:srFc Cs�ts~ddlm}t�dd�d}||�}|�d�}|���}t�|�W5QRXt rzdD] }t� |dd �t� |d d �qXd adS) N�)�finder�.�rz sysconfig.cfg)� posix_prefixZ posix_home�includez{srcdir}/Include� platincludez{projectbase}/.T) � _cfg_readZ resourcesr�__name__�rsplit�findZ as_stream�_SCHEMESZreadfp� _PYTHON_BUILD�set)rZbackport_packageZ_finderZ_cfgfile�s�schemerrr�_ensure_cfg_readDs   r,z \{([^{]*?)\}c s�t�|�d�r|�d�}nt�}|��}|D]8}|dkr._replacer) r,Z has_section�items�tuple�sectionsZ has_optionr)Zremove_section�dict� _VAR_REPL�sub)�configr-r8ZsectionZoption�valuer5rr3r�_expand_globalsYs$       r>�rcs�fdd�}t�||�S)z�In the string `path`, replace tokens like {some.thing} with the corresponding value from the map `local_vars`. If there is no corresponding value, leave the token unchanged. cs8|�d�}|�kr�|S|tjkr.tj|S|�d�Sr.)r0r�environr1�� local_varsrrr5�s    z_subst_vars.._replacer�r:r;)rrBr5rrAr� _subst_vars�s rDcCs0|��}|��D]\}}||kr"q|||<qdSr)�keysr6)Z target_dictZ other_dictZ target_keys�keyr=rrr� _extend_dict�s rGcCs`i}|dkri}t|t��t�|�D]4\}}tjdkrDtj�|�}tj�t ||��||<q&|S)N)�posixr) rGrr'r6rr2r� expanduser�normpathrD)r+�vars�resrFr=rrr� _expand_vars�s   rMcs�fdd�}t�||�S)Ncs$|�d�}|�kr�|S|�d�Sr.r/r1�rKrrr5�s zformat_value.._replacerrC)r=rKr5rrNr� format_value�s rOcCstjdkrdStjS)NrHr )rr2rrrr�_get_default_scheme�s rPcCs�tj�dd�}dd�}tjdkrBtj�d�p.d}|r8|S||d�Stjdkr|td �}|r||r`|S|dd |d tjdd ��S|r�|S|dd �SdS)N�PYTHONUSERBASEcWstj�tjj|��Sr)rrrIr)�argsrrr�joinuser�sz_getuserbase..joinuserr�APPDATA�~�Python�darwinZPYTHONFRAMEWORK�Libraryz%d.%drz.local)rr@�getr2�sys�platformr� version_info)�env_baserS�baseZ frameworkrrr� _getuserbase�s$     �r_c Cst�d�}t�d�}t�d�}|dkr*i}i}i}tj|ddd��}|��}W5QRX|D]�} | �d�sZ| ��d krvqZ|�| �} | rZ| �d d �\} } | ��} | � d d �} d | kr�| || <qZz t | �} Wn$t k r�| � d d �|| <YqZX| || <qZt |� ��}d}t|�dk�r�t|�D�]�}||}|�|��p>|�|�} | dk �r�| �d �} d}| |k�rpt|| �}n�| |k�r�d}nx| tjk�r�tj| }n`| |k�r�|�d��r�|dd�|k�r�d }n$d| |k�r�d}nt|d| �}n d || <}|�r�|| ��d�}|d| ���||}d |k�r:|||<n~z t |�}Wn"t k �rh|��||<Yn X|||<|�|�|�d��r�|dd�|k�r�|dd�}||k�r�|||<n|||<|�|��q�q|��D]"\}} t| t��r�| ��||<�q�|�|�|S)z�Parse a Makefile-style file. A dictionary containing name/value pairs is returned. If an optional dictionary is passed in as the second argument, it is used instead of a new dictionary. z"([a-zA-Z][a-zA-Z0-9_]+)\s*=\s*(.*)z\$\(([A-Za-z][A-Za-z0-9_]*)\)z\${([A-Za-z][A-Za-z0-9_]*)}Nzutf-8�surrogateescape)�encoding�errors�#�rrz$$�$)�CFLAGS�LDFLAGSZCPPFLAGSrTFZPY_r?)�re�compile�codecs�open� readlines� startswith�strip�matchr0�replace�int� ValueError�listrE�lenr7�search�strrr@�end�start�remover6� isinstance�update)�filenamerKZ _variable_rxZ _findvar1_rxZ _findvar2_rxZdoneZnotdone�f�lines�line�m�n�vZtmpvr4Zrenamed_variablesr2r=�found�itemZafter�krrr�_parse_makefile�s�                 �      �     r�cCsDtrtj�td�Sttd�r,dttjf}nd}tj�t d�|d�S)z Return the path of the Makefile.ZMakefile�abiflagsz config-%s%sr<�stdlib) r(rrrr�hasattrrZ�_PY_VERSION_SHORTr�r)Zconfig_dir_namerrrrMs  c Cs�t�}zt||�WnJtk r^}z,d|}t|d�rF|d|j}t|��W5d}~XYnXt�}z"t|��}t||�W5QRXWnJtk r�}z,d|}t|d�r�|d|j}t|��W5d}~XYnXtr�|d|d<dS)z7Initialize the module as appropriate for POSIX systems.z.invalid Python installation: unable to open %s�strerrorz (%s)N� BLDSHAREDZLDSHARED) rr��IOErrorr�r�rrkrr()rKZmakefile�e�msgZconfig_hr}rrr� _init_posixXs&   r�cCsVtd�|d<td�|d<td�|d<d|d<d |d <t|d <tj�ttj��|d <d S)z+Initialize the module as appropriate for NTr�ZLIBDESTZ platstdlibZ BINLIBDESTr!Z INCLUDEPYz.pydZSOz.exeZEXEZVERSIONZBINDIRN)r�_PY_VERSION_SHORT_NO_DOTrr�dirnamerrZ� executablerNrrr�_init_non_posixts   r�cCs�|dkr i}t�d�}t�d�}|��}|s.q�|�|�}|rx|�dd�\}}z t|�}Wntk rlYnX|||<q |�|�}|r d||�d�<q |S)z�Parse a config.h-style file. A dictionary containing name/value pairs is returned. If an optional dictionary is passed in as the second argument, it is used instead of a new dictionary. Nz"#define ([A-Z][A-Za-z0-9_]+) (.*) z&/[*] #undef ([A-Z][A-Za-z0-9_]+) [*]/ rrr)rhri�readlineror0rqrr)�fprKZ define_rxZundef_rxrr�r�r�rrrr�s&      cCs:tr$tjdkrtj�td�}q,t}ntd�}tj�|d�S)zReturn the path of pyconfig.h.rZPCr"z pyconfig.h)r(rr2rrrr)Zinc_dirrrrr�s  cCsttt����S)z,Return a tuple containing the schemes names.)r7�sortedr'r8rrrrr �scCs t�d�S)z*Return a tuple containing the paths names.r )r'Zoptionsrrrrr �sTcCs&t�|rt||�Stt�|��SdS)z�Return a mapping containing an install scheme. ``scheme`` is the install scheme name. If not provided, it will return the default scheme for the current platform. N)r,rMr9r'r6)r+rK�expandrrrr �s cCst|||�|S)z[Return a path corresponding to the scheme. ``scheme`` is the install scheme name. )r )r2r+rKr�rrrr�scGs�tdk�rziattd<ttd<ttd<ttd<tdtdtd<ttd <ttd <ttd <ztjtd <Wntk r�d td <YnXt j dkr�t t�t j dkr�t t�tj dkr�t�td<dtkr�ttd<nttd�td<t�r\t j dk�r\t}z t ��}Wntk �rd}YnXt j�td��s\||k�r\t j�|td�}t j�|�td<tjdk�rzt ��d}t|�d�d�}|dk�r�dD]2}t|}t�dd|�}t�dd|�}|t|<�q�n�dt jk�rt jd}dD]0}t|}t�dd|�}|d|}|t|<�q�t�dd �} t�d| �} | dk �rz| � d�} t j�!| ��szdD]$}t|}t�dd|�}|t|<�qT|�r�g} |D]} | �"t�| ���q�| StSdS)ayWith no arguments, return a dictionary of all configuration variables relevant for the current platform. On Unix, this means every variable defined in Python's installed Makefile; On Windows and Mac OS it's a much smaller set. With arguments, return a list of values that result from looking up each argument in the configuration variable dictionary. N�prefix� exec_prefixZ py_versionZpy_version_shortrrZpy_version_nodotr^ZplatbaseZ projectbaser�rd)rZos2rHz2.6�userbase�srcdirrWr�)rgZ BASECFLAGSrfZ PY_CFLAGSr�z -arch\s+\w+\s� z-isysroot [^ ]*Z ARCHFLAGSrfz-isysroot\s+(\S+)rz-isysroot\s+\S+(\s|$))#� _CONFIG_VARS�_PREFIX� _EXEC_PREFIX� _PY_VERSIONr�rrZr��AttributeErrorrr2r�r��versionr_rr(�getcwdrr�isabsrrJr[�unamerq�splitrhr;r@rYrur0�exists�append)rRr^�cwdr�Zkernel_versionZ major_versionrF�flagsZarchrfr�ZsdkZvalsr2rrrr�s�        �           cCs t��|�S)z�Return the value of a single variable using the dictionary returned by 'get_config_vars()'. Equivalent to get_config_vars().get(name) )rrY)r2rrrrRscCs^tjdkrnd}tj�|�}|dkr(tjStj�d|�}tj|t|�|���}|dkr\dS|dkrhdStjStjd ks�ttd �s�tjSt� �\}}}}}|��� d d �}|� d d�}|� d d�}|dd�dkr�d||fS|dd�dk�r&|ddk�rPd}dt |d�d|dd�f}�n*|dd�dk�rDd||fS|dd�dk�rdd|||fS|dd�d k�r�d }t � d!�} | �|�} | �rP| ��}�n�|dd�d"k�rPt�} | �d#�} | } z td$�}Wntk �r�YnJXzt �d%|���} W5|��X| dk �r2d&�| �d'��d&�dd��} | �s<| } | �rP| }d(}| d&d)k�rd*t��d+d ���k�rd,}t��d+�}t �d-|�}ttt|���}t|�d'k�r�|d}n^|d.k�r�d,}nN|d/k�r�d0}n>|d1k�r�d2}n.|d3k�r�d4}n|d5k�rd6}ntd7|f��n<|d8k�r0tjd9k�rPd:}n |d;k�rPtjd9k�rLd<}nd=}d>|||fS)?a�Return a string that identifies the current platform. This is used mainly to distinguish platform-specific build directories and platform-specific built distributions. Typically includes the OS name and version and the architecture (as supplied by 'os.uname()'), although the exact information included depends on the OS; eg. for IRIX the architecture isn't particularly important (IRIX only runs on SGI hardware), but for Linux the kernel version isn't particularly important. Examples of returned values: linux-i586 linux-alpha (?) solaris-2.6-sun4u irix-5.3 irix64-6.2 Windows will return one of: win-amd64 (64bit Windows on AMD64 (aka x86_64, Intel64, EM64T, etc) win-ia64 (64bit Windows on Itanium) win32 (all others - specifically, sys.platform is returned) For other non-POSIX platforms, currently just returns 'sys.platform'. rz bit (������)Zamd64z win-amd64Zitaniumzwin-ia64rHr��/rdr��_�-N�Zlinuxz%s-%sZsunosr�5Zsolarisz%d.%sr?r�ZirixZaixz%s-%s.%s��cygwinz[\d.]+rWZMACOSX_DEPLOYMENT_TARGETz0/System/Library/CoreServices/SystemVersion.plistz=ProductUserVisibleVersion\s*(.*?)rrZmacosxz10.4.z-archrfZfatz -arch\s+(\S+))�i386�ppc)r��x86_64Zintel)r�r�r�Zfat3)�ppc64r�Zfat64)r�r�r�r�Z universalz%Don't know machine value for archs=%rr�lr�)ZPowerPCZPower_Macintoshr�r�z%s-%s-%s) rr2rZr�r&r[rt�lowerr�r�rprqrhriror0rrYrkr��closeru�readrr�rn�findallr7r�r)rr�maxsize)r��i�jZlookZosnameZhost�releaser��machineZrel_rer�ZcfgvarsZmacverZ macreleaser}ZcflagsZarchsrrrr [s�     $      �  �        �    cCstSr)r�rrrrr �scCsFtt|����D]0\}\}}|dkr0td|�td||f�qdS)Nrz%s: z %s = "%s")� enumerater�r6�print)�title�data�indexrFr=rrr� _print_dicts r�cCsRtdt��tdt��tdt��t�tdt��t�tdt��dS)z*Display all information sysconfig detains.zPlatform: "%s"zPython version: "%s"z!Current installation scheme: "%s"ZPathsZ VariablesN)r�r r rPr�r rrrrr�_mains r��__main__)N)N)A�__doc__rjrrhrZZos.pathrrZ configparser� ImportErrorZ ConfigParser�__all__rr�rr�rr�r2r�rrr(r#r,ZRawConfigParserr'rir:r>r�r�r�r�r�rJr�r�r�r�r�Z _USER_BASErDrGrMrOrPr_r�rr�r�rrr r r rrrr r r�r�r$rrrr�s� � "" #   v     #