a ضZg�c� @sddlZddlZddlmZmZgd�ZdhZddddd d d d d �ddddddd d d �dddddddd d �dddddddd�dddddd dd�d!d!d"d"d#d dd�d$�Zd%Ze ed&�s�ej ej ks�d'ej vr�d(Z dZej��dZd)ejdd*�Zd+ejdd*�Zej�ej �Zej�ej �Zej�ej�Zej�ej�ZdadZd,d-�Zej �rhej�!eej ��Z"n ee�#��Z"ej$d.k�r�e"�%��&d/��r�eej�'e"ee��Z"d0ej v�r�eej d0�Z"d1d2�Z(e)ed3d�Z*ej$d.k�r�d4d5�Z+e+e"�Z"e+e*�Z*dmd6d7�Z,e,d8�Z-e-�r2d9D]Z.d:ee.d;<dd?�Z/d@dA�Z0dBdC�Z1dDdE�Z2dFdG�Z3dndHdI�Z4dJdK�Z5dLdM�Z6dNdO�Z7dPdQ�Z8dRdS�Z9dodTdU�Z:dVdW�Z;dXdY�Ze2�dd8fd^d_�Z?d`da�Z@dbdc�ZAddde�ZBdfdg�ZCdhdi�ZDdjdk�ZEeFdlk�reE�dS)p�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_hZMACOSX_DEPLOYMENT_TARGETz6{installed_base}/{platlibdir}/python{py_version_short}z0{platbase}/{platlibdir}/python{py_version_short}z1{base}/lib/python{py_version_short}/site-packagesz>{platbase}/{platlibdir}/python{py_version_short}/site-packagesz;{installed_base}/include/python{py_version_short}{abiflags}z?{installed_platbase}/include/python{py_version_short}{abiflags}z {base}/binz{base})�stdlib� platstdlib�purelib�platlib�include� platinclude�scripts�dataz{installed_base}/lib/pythonz{base}/lib/pythonz{installed_base}/include/pythonz{installed_base}/Libz {base}/Libz{base}/Lib/site-packagesz{installed_base}/Includez{base}/Scriptsz#{userbase}/Python{py_version_nodot}z1{userbase}/Python{py_version_nodot}/site-packagesz+{userbase}/Python{py_version_nodot}/Includez+{userbase}/Python{py_version_nodot}/Scriptsz {userbase})rrrrrrrz0{userbase}/{platlibdir}/python{py_version_short}z5{userbase}/lib/python{py_version_short}/site-packagesz>{userbase}/{platlibdir}/python{py_version_short}/site-packagesz+{userbase}/include/python{py_version_short}z{userbase}/binz{userbase}/lib/pythonz#{userbase}/lib/python/site-packagesz{userbase}/include)� posix_prefix� posix_home�ntZnt_userZ posix_userZosx_framework_userFZ real_prefix�RPM_BUILD_ROOTz/local�%d.%d�z%d%dcCs&z t|�WSty |YS0dS�N)r�OSError)�path�r �!/usr/lib64/python3.9/sysconfig.py�_safe_realpathxs  r"r)z\pcbuild\win32z\pcbuild\amd64Z_PYTHON_PROJECT_BASEcCs,dD]"}tj�tj�|d|��rdSqdS)N)ZSetupz Setup.localZModulesTF)�osr�isfile�join)�d�fnr r r!�_is_python_source_dir�sr(�_homecCs0|r,tj�|��tj�tj�td���r,tS|S)NZPCbuild)r#r�normcase� startswithr%�_PREFIX)r&r r r!� _fix_pcbuild�s �r-cCs|rtrtt�Stt�Sr)� _sys_homer(� _PROJECT_BASE)Z check_homer r r!�is_python_build�sr0T)rrz{srcdir}/Includerz{projectbase}/.rc Csvz|jfi|��WStypz|jfitj��WYStyj}ztd|�d�WYd}~n d}~00Yn0dS)Nz{%s})�format�KeyErrorr#�environ�AttributeError)�sZ local_vars�varr r r!� _subst_vars�s r7cCs0|��}|��D]\}}||vr"q|||<qdSr)�keys�items)Z target_dictZ other_dictZ target_keys�key�valuer r r!� _extend_dict�s r<cCsbi}|duri}t|t��t|��D]4\}}tjdvrFtj�|�}tj�t ||��||<q(|S)N)�posixr) r<r�_INSTALL_SCHEMESr9r#�namer� expanduser�normpathr7)�scheme�vars�resr:r;r r r!� _expand_vars�s   rEcCstjdkrdStjS)Nr=r)r#r?r r r r!�_get_default_scheme�s rFcCsztj�dd�}|r|Sdd�}tjdkrBtj�d�p6d}||d�Stjdkrptjrp|dd tjd tjdd ��S|dd �S) N�PYTHONUSERBASEcWstj�tjj|��Sr)r#rr@r%)�argsr r r!�joinuser�sz_getuserbase..joinuserr�APPDATA�~�Python�darwin�Libraryrrz.local)r#r3�getr?�sys�platform� _framework� version_info)�env_baserI�baser r r!� _getuserbase�s   �rVc Csrddl}|�d�}|�d�}|�d�}|dur2i}i}i}t|dd��}|��} Wd�n1sd0Y| D]�} | �d�sr| ��dkr�qr|�| �} | rr| �d d �\} } | ��} | �d d�}d |vr�| || <qrz| t vr�t �t | �} Wn$t �y| �d d �|| <Yqr0| || <qrt |� ��}d }t|�dk�r8t|�D�]�}||}|�|�}|�|�}|�r�|�r�|��|��k�r�|n|} n|�r�|n|} | du�r| �d �} d}| |v�r�t|| �}n�| |v�r�d}nx| tjv�r�tj| }n`| |v�rD|�d��r|dd�|v�rd}n$d| |v�r2d}nt|d| �}n d|| <}|�r0|| ��d�}|d| ���||}d |v�r�|||<n�z|t v�r�t �t |�}Wn t �y�|��||<Yn 0|||<|�|�|�d��r0|dd�|v�r0|dd�}||v�r0|||<n|||<|�|��q@�q*|��D]"\}} t| t��r@| ��||<�q@|�|�|S)Nrz"([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_]*)}�surrogateescape)�errors�#��rz$$�$)ZCFLAGSZLDFLAGSZCPPFLAGSTFZPY_�)�re�compile�open� readlinesr+�strip�match�group�replace� _ALWAYS_STR� ValueError�int�listr8�len�tuple�search�start�strr#r3�end�remover9� isinstance�update)�filenamerCr^Z _variable_rxZ _findvar1_rxZ _findvar2_rx�doneZnotdone�f�lines�line�m�n�vZtmpvZ variablesZrenamed_variablesr?r;Zm1Zm2�found�itemZafter�kr r r!�_parse_makefile�s�    &                 �       �     r~cCsdtrtj�tptd�Sttd�r0dttj f}nd}ttj d�rP|dtj j 7}tj�t d�|d�S)NZMakefile�abiflagsz config-%s%sZconfig� _multiarchz-%sr) � _PYTHON_BUILDr#rr%r.r/�hasattrrP�_PY_VERSION_SHORTr�implementationr�r)Zconfig_dir_namer r r!rfs  rc Cs(tj�ddjtjtjttjdd�d��S)NZ_PYTHON_SYSCONFIGDATA_NAMEz+_sysconfigdata_{abi}_{platform}_{multiarch}r�rZ)ZabirQZ multiarch) r#r3rOr1rPrrQ�getattrr�r r r r!�_get_sysconfigdata_namess ��r�c Csddl}i}t�}zt||�WnLtyl}z4d|}t|d�rP|d|j}t|��WYd}~n d}~00t�}z6t|��}t||�Wd�n1s�0YWnLty�}z4d|}t|d�r�|d|j}t|��WYd}~n d}~00t �r |d|d<t �}dt j v�r>ddl }|�|�} || _| t j|<dt�tf} tt d ��r`| d 7} tj| d d �tj�| |d �} t| ddd��2}|�d�|�d�|j||d�Wd�n1�s�0Ytdddd��}|�| �Wd�n1�s0YdS)Nrz.invalid Python installation: unable to open %s�strerrorz (%s)ZLDSHAREDZ BLDSHAREDrMzbuild/lib.%s-%sZgettotalrefcountz-pydebugT)�exist_okz.py�w�utf8)�encodingzB# system configuration generated and used by the sysconfig module zbuild_time_vars = )�streamzpybuilddir.txt)�pprintrr~rr�r�rr`rr�r�rPrQ�types� ModuleType�build_time_vars�modulesr r�r#�makedirsrr%�write) r�rC�makefile�e�msgZconfig_hrur?r��moduleZ pybuilddirZdestfiler r r!�_generate_posix_vars|sL  ,        .r�cCs0t�}t|t�t�dgd�}|j}|�|�dS)Nr�r)r�� __import__�globals�localsr�rr)rCr?Z_tempr�r r r!� _init_posix�sr�cCsfddl}td�|d<td�|d<td�|d<|��d|d<d |d <t|d <tj�ttj ��|d <dS) NrrZLIBDESTrZ BINLIBDESTrZ INCLUDEPY� EXT_SUFFIXz.exeZEXE�VERSIONZBINDIR) �_impr�extension_suffixes�_PY_VERSION_SHORT_NO_DOTr#r�dirnamer"rP� executable)rCr�r r r!�_init_non_posix�s   r�c Cs�|dur i}ddl}|�d�}|�d�}|��}|s6q�|�|�}|r�|�dd�\}}z|tvrbt�t|�}Wnty~Yn0|||<q(|�|�}|r(d||�d�<q(|S)Nrz"#define ([A-Z][A-Za-z0-9_]+) (.*) z&/[*] #undef ([A-Z][A-Za-z0-9_]+) [*]/ r[r)r^r_�readlinercrdrfrgrh) �fprCr^Z define_rxZundef_rxrwrxryrzr r r!r�s,       rcCsBtr,tjdkr"tj�tptd�}q4tp(t}ntd�}tj�|d�S)NrZPCrz pyconfig-64.h)r�r#r?rr%r.r/r)Zinc_dirr r r!r�s   rcCs ttt��Sr)rk�sortedr>r r r r!r sr cCstSr)� _SCHEME_KEYSr r r r!r sr cCs|rt||�St|SdSr)rEr>)rBrC�expandr r r!r s r cCst|||�|Sr)r )r?rBrCr�r r r!rsrcGs�tdu�rViattd<ttd<ttd<ttd<ttd<ttd<ttd<ttd<ttd <ttd <t j td <zt j td <Wnt y�d td <Yn0t jdkr�tt�d td<t jdkr�tt�t�d�}|dur�|td<t�td<t�dt�}t jdk�r,t�rt j�t��}t j�||�}nt j�t��}t|�td<t jdk�rVddl}|�t�|�r�g}|D]}|�t�|���qd|StSdS)N�prefix� exec_prefixZ py_versionZpy_version_shortZpy_version_nodotZinstalled_baserUZinstalled_platbaseZplatbaseZ projectbase� platlibdirrrZrZTZPATHr=r��SO�userbase�srcdirrMr)� _CONFIG_VARSr,� _EXEC_PREFIX� _PY_VERSIONr�r�� _BASE_PREFIX�_BASE_EXEC_PREFIXr/rPr�rr4r#r?r�r�rOrVr�rr�rr%r"rQ� _osx_supportZcustomize_config_vars�append)rHr�r�rUr�Zvalsr?r r r!r sT            rcCs*|dkrddl}|�dtd�t��|�S)Nr�rz SO is deprecated, use EXT_SUFFIXr)�warnings�warn�DeprecationWarningrrO)r?r�r r r!rosrc Cs�tjdkrFdtj��vrdSdtj��vr.dSdtj��vr@dStjStjdksZttd �s`tjSd tjvrttjd St��\}}}}}|��� 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!}ddl}|�d"�}|�|�} | �r�| ��}n2|dd �d#k�r�ddl} | �t�|||�\}}}d$|||fS)%NrZamd64z win-amd64z(arm)z win-arm32z(arm64)z win-arm64r=�unameZ_PYTHON_HOST_PLATFORM�/rZ� �_�-��linuxz%s-%sZsunosr�5Zsolarisz%d.%sr]rZ32bitZ64bit)i���l����z.%sZaix)� aix_platform��cygwinz[\d.]+rMz%s-%s-%s)r#r?rP�version�lowerrQr�r3r�rerh�maxsizeZ _aix_supportr�r^r_rcrdr�Zget_platform_osxr) Zosname�host�releaser��machineZbitnessr�r^Zrel_rerxr�r r r!r {sR            � r cCstSr)r�r r r r!r �sr cCsFtt|����D]0\}\}}|dkr0td|�td||f�qdS)Nrz%s: z %s = "%s")� enumerater�r9�print)�titler�indexr:r;r r r!� _print_dict�s r�cCsfdtjvrt�dStdt��tdt��tdt��t�tdt��t�tdt ��dS)Nz--generate-posix-varszPlatform: "%s"zPython version: "%s"z!Current installation scheme: "%s"ZPathsZ Variables) rP�argvr�r�r r rFr�r rr r r r!�_main�s  r��__main__)F)N)N)Gr#rPZos.pathrr�__all__rfr>Z_PIP_USE_SYSCONFIGr�r�� base_prefixr3Z_prefix_additionr�r��splitr�rSr�r�rrAr,r�r�r��base_exec_prefixr�r�Z _USER_BASEr"r�r�r/�getcwdr?r��endswithr%r(r�r.r-r0r�rBr7r<rErFrVr~rr�r�r�r�rrr r r rrrr r r�r��__name__r r r r!�s��� � � � � ��A  ��   �           ? "  O Q