o
    ä§Êhæh  ã                   @   s”  d Z ddlZddlZddlZddlZddlmZmZ zddlZW n e	y-   ddl
ZY nw g d¢Zdd„ ZejrCej eejƒ¡Znee ¡ ƒZejdkraded	d…  ¡ v raeej ee¡ƒZejdkrzd
edd…  ¡ v rzeej eee¡ƒZejdkr“dedd…  ¡ v r“eej eee¡ƒZdd„ Zeƒ Zdadd„ Ze ¡ Ze d¡Zdd„ Zdejdd…  Zdejdd…  Z dejdd…  Z!ej "ej#¡Z$ej "ej%¡Z&da'dZ(dd„ Z)dd„ Z*dd „ Z+d!d"„ Z,d#d$„ Z-d%d&„ Z.dId'd(„Z/d)d*„ Z0d+d,„ Z1d-d.„ Z2dId/d0„Z3d1d2„ Z4d3d4„ Z5d5d6„ Z6e-ƒ dd7fd8d9„Z7e-ƒ dd7fd:d;„Z8d<d=„ Z9d>d?„ Z:d@dA„ Z;dBdC„ Z<dDdE„ Z=dFdG„ Z>e?dHk�rHe>ƒ  dS dS )Jz-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_hc                 C   s"   zt | ƒW S  ty   |  Y S w ©N)r   ÚOSError)Úpath© r   úM/var/www/html/env/lib/python3.10/site-packages/distlib/_backport/sysconfig.pyÚ_safe_realpath"   s
   
ÿr   ÚntÚpcbuildiøÿÿÿz\pc\viöÿÿÿz\pcbuild\amd64iòÿÿÿc                  C   s,   dD ]} t j t j td| ¡¡r dS qdS )N)z
Setup.distzSetup.localÚModulesTF)Úosr   ÚisfileÚjoinÚ_PROJECT_BASE)Úfnr   r   r   Úis_python_build:   s
   ÿr   Fc                  C   s¦   t sQddlm}  t dd¡d }| |ƒ}| d¡}|sJ dƒ‚| ¡ �}t |¡ W d   ƒ n1 s3w   Y  t	rMdD ]}t 
|d	d
¡ t 
|dd¡ q<da d S d S )Né   )ÚfinderÚ.é   r   zsysconfig.cfgzsysconfig.cfg exists)Úposix_prefixÚ
posix_homeÚincludez{srcdir}/IncludeÚplatincludez{projectbase}/.T)Ú	_cfg_readÚ	resourcesr   Ú__name__ÚrsplitÚfindÚ	as_streamÚ_SCHEMESÚreadfpÚ_PYTHON_BUILDÚset)r   Úbackport_packageÚ_finderÚ_cfgfileÚsÚschemer   r   r   Ú_ensure_cfg_readD   s   

ÿór5   z\{([^{]*?)\}c              
      sÈ   t ƒ  |  d¡r|  d¡}ntƒ }|  ¡ }|D ]}|dkrq|D ]\}}|  ||¡r+q |  |||¡ q q|  d¡ |  ¡ D ]$}t|  |¡ƒ‰ ‡ fdd„}|  |¡D ]\}}|  ||t	 
||¡¡ qQq=d S )NÚglobalsc                    ó$   |   d¡}|ˆ v rˆ | S |   d¡S ©Nr!   r   ©Úgroup©ÚmatchobjÚname©Ú	variablesr   r   Ú	_replacero   ó   

z"_expand_globals.<locals>._replacer)r5   Úhas_sectionÚitemsÚtupleÚsectionsÚ
has_optionr/   Úremove_sectionÚdictÚ	_VAR_REPLÚsub)Úconfigr6   rE   ÚsectionÚoptionÚvaluer@   r   r>   r   Ú_expand_globalsY   s*   
ý
ÿ÷rO   z%s.%s.%sé   z%s.%sr   z%s%sc                    ó   ‡ fdd„}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.
    c                    s8   |   d¡}|ˆ v rˆ | S |tjv rtj| S |   d¡S r8   )r:   r   Úenvironr;   ©Ú
local_varsr   r   r@   ‰   s   



z_subst_vars.<locals>._replacer©rI   rJ   )r   rT   r@   r   rS   r   Ú_subst_varsƒ   s   rV   c                 C   s0   |   ¡ }| ¡ D ]\}}||v rq|| |< qd S r   )ÚkeysrC   )Útarget_dictÚ
other_dictÚtarget_keysÚkeyrN   r   r   r   Ú_extend_dict“   s   
ýr\   c                 C   s`   i }|d u ri }t |tƒ ƒ t | ¡D ]\}}tjdv r"tj |¡}tj t	||ƒ¡||< q|S )N)Úposixr   )
r\   r   r,   rC   r   r=   r   Ú
expanduserÚnormpathrV   )r4   ÚvarsÚresr[   rN   r   r   r   Ú_expand_vars›   s   
rb   c                    rQ   )Nc                    r7   r8   r9   r;   ©r`   r   r   r@   ©   rA   zformat_value.<locals>._replacerrU   )rN   r`   r@   r   rc   r   Úformat_value¨   s   rd   c                   C   s   t jdkrdS t jS )Nr]   r"   )r   r=   r   r   r   r   Ú_get_default_scheme±   s   
re   c                  C   sŽ   t j dd ¡} dd„ }t jdkr!t j d¡pd}| r| S ||dƒS tjdkr>td	ƒ}|r>| r0| S |dd
|dtjd d…  ƒS | rB| S |ddƒS )NÚPYTHONUSERBASEc                  W   s   t j t jj| Ž ¡S r   )r   r   r^   r   )Úargsr   r   r   Újoinuser»   s   z_getuserbase.<locals>.joinuserr   ÚAPPDATAú~ÚPythonÚdarwinÚPYTHONFRAMEWORKÚLibraryz%d.%dr   z.local)r   rR   Úgetr=   ÚsysÚplatformr   Úversion_info)Úenv_baserh   ÚbaseÚ	frameworkr   r   r   Ú_getuserbase¸   s$   



ÿ
rv   c              	   C   s  t  d¡}t  d¡}t  d¡}|du ri }i }i }tj| ddd��}| ¡ }W d  ƒ n1 s0w   Y  |D ]L}	|	 d¡sD|	 ¡ d	krEq7| |	¡}
|
rƒ|
 d
d¡\}}| ¡ }| 	dd	¡}d|v rg|||< q7zt
|ƒ}W n ty~   | 	dd¡||< Y q7w |||< q7t| ¡ ƒ}d}t|ƒdk�rlt|ƒD ]Î}|| }| |¡p¦| |¡}
|
du�r\|
 d
¡}d}||v r¾t|| ƒ}n>||v rÅd}n7|tjv rÐtj| }n,||v rö| d¡rä|dd… |v räd	}nd| |v ríd}nt|d|  ƒ}nd	 ||< }|�r[||
 ¡ d… }|d|
 ¡ … | | }d|v �r|||< q—zt
|ƒ}W n t�y3   | ¡ ||< Y nw |||< | |¡ | d¡�r[|dd… |v �r[|dd… }||v�r[|||< q—|||< | |¡ q—t|ƒdks“| ¡ D ]\}}t|tƒ�r€| ¡ ||< �qp| |¡ |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_]*)}Nzutf-8Úsurrogateescape)ÚencodingÚerrorsú#Ú r!   r   z$$ú$)ÚCFLAGSÚLDFLAGSÚCPPFLAGSr   TFÚPY_rP   )ÚreÚcompileÚcodecsÚopenÚ	readlinesÚ
startswithÚstripÚmatchr:   ÚreplaceÚintÚ
ValueErrorÚlistrW   ÚlenrD   ÚsearchÚstrr   rR   ÚendÚstartÚremoverC   Ú
isinstanceÚupdate)Úfilenamer`   Ú_variable_rxÚ_findvar1_rxÚ_findvar2_rxÚdoneÚnotdoneÚfÚlinesÚlineÚmÚnÚvÚtmpvr?   Úrenamed_variablesr=   rN   ÚfoundÚitemÚafterÚkr   r   r   Ú_parse_makefileÕ   sš   
	


ÿ

þ€





ÿ

€É:€
r§   c                  C   sD   t r	tj td¡S ttdƒrdttjf } nd} tj t	dƒ| d¡S )z Return the path of the Makefile.ÚMakefileÚabiflagszconfig-%s%srK   Ústdlib)
r.   r   r   r   r   Úhasattrrp   Ú_PY_VERSION_SHORTr©   r   )Úconfig_dir_namer   r   r   r   K  s   
r   c              
   C   sì   t ƒ }zt|| ƒ W n  ty* } zd| }t|dƒr"|d|j  }t|ƒ‚d}~ww tƒ }zt|ƒ�}t|| ƒ W d  ƒ n1 sCw   Y  W n  tyi } zd| }t|dƒra|d|j  }t|ƒ‚d}~ww trt| d | d< dS dS )z7Initialize the module as appropriate for POSIX systems.z.invalid Python installation: unable to open %sÚstrerrorz (%s)NÚ	BLDSHAREDÚLDSHARED)	r   r§   ÚIOErrorr«   r®   r   r„   r   r.   )r`   ÚmakefileÚeÚmsgÚconfig_hr›   r   r   r   Ú_init_posixV  s4   
€ü
ÿ€
€üÿr¶   c                 C   sV   t dƒ| d< t dƒ| d< t dƒ| d< d| d< d	| d
< t| d< tj ttjƒ¡| d< dS )z+Initialize the module as appropriate for NTrª   ÚLIBDESTÚ
platstdlibÚ
BINLIBDESTr$   Ú	INCLUDEPYz.pydÚSOz.exeÚEXEÚVERSIONÚBINDIRN)r   Ú_PY_VERSION_SHORT_NO_DOTr   r   Údirnamer   rp   Ú
executablerc   r   r   r   Ú_init_non_posixr  s   rÂ   c                 C   sš   |du ri }t  d¡}t  d¡}	 |  ¡ }|s	 |S | |¡}|r>| dd¡\}}zt|ƒ}W n	 ty8   Y nw |||< n| |¡}|rLd|| d¡< q)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_]+) [*]/
Tr!   r   r   )r�   r‚   Úreadlinerˆ   r:   rŠ   r‹   )Úfpr`   Ú	define_rxÚundef_rxr�   rž   rŸ   r    r   r   r   r   ‚  s,   


ôÿ

ñr   c                  C   s:   t rtjdkrtj td¡} nt} ntdƒ} tj | d¡S )zReturn the path of pyconfig.h.r   ÚPCr%   z
pyconfig.h)r.   r   r=   r   r   r   r   )Úinc_dirr   r   r   r   ¡  s   
r   c                   C   s   t tt ¡ ƒƒS )z,Return a tuple containing the schemes names.)rD   Úsortedr,   rE   r   r   r   r   r   ­  s   r   c                   C   s
   t  d¡S )z*Return a tuple containing the paths names.r"   )r,   Úoptionsr   r   r   r   r	   ²  s   
r	   Tc                 C   s"   t ƒ  |r
t| |ƒS tt | ¡ƒS )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.
    )r5   rb   rH   r,   rC   )r4   r`   Úexpandr   r   r   r
   ¸  s   
r
   c                 C   s   t |||ƒ|  S )z[Return a path corresponding to the scheme.

    ``scheme`` is the install scheme name.
    )r
   )r=   r4   r`   rË   r   r   r   r   Å  s   r   c                  G   s”  t du �r3i a tt d< tt d< tt d< tt d< td td  t d< tt d	< tt d
< tt d< ztjt d< W n tyA   dt d< Y nw t	j
dv rKtt ƒ t	j
dkrTtt ƒ tjdkr^tƒ t d< dt vrgtt d< ntt d ƒt d< tr§t	j
dkr§t}zt	 ¡ }W n ty‰   d}Y nw t	j t d ¡s§||kr§t	j |t d ¡}t	j |¡t d< tjdk�r3t	 ¡ d }t| d¡d ƒ}|dk rÜdD ]}t | }t dd|¡}t dd|¡}|t |< qÂnWdt	jv �rt	jd }dD ]}t | }t dd|¡}|d | }|t |< qét  dd¡}	t d|	¡}
|
du�r3|
  d¡}t	j !|¡�s3dD ]}t | }t dd|¡}|t |< �q | �rHg }| D ]}| "t  |¡¡ �q:|S t S )ay  With 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_prefixÚ
py_versionÚpy_version_shortr   r   Úpy_version_nodotrt   ÚplatbaseÚprojectbaser©   r{   )r   Úos2r]   z2.6ÚuserbaseÚsrcdirrl   r    é   )r~   Ú
BASECFLAGSr}   Ú	PY_CFLAGSr¯   z-arch\s+\w+\sú z-isysroot [^ 	]*Ú	ARCHFLAGSr}   z-isysroot\s+(\S+)r!   z-isysroot\s+\S+(\s|$))#Ú_CONFIG_VARSÚ_PREFIXÚ_EXEC_PREFIXÚ_PY_VERSIONr¬   r   rp   r©   ÚAttributeErrorr   r=   rÂ   r¶   Úversionrv   r   r.   Úgetcwdr   r   Úisabsr   r_   rq   ÚunamerŠ   Úsplitr�   rJ   rR   ro   rŽ   r:   ÚexistsÚappend)rg   rt   ÚcwdrÕ   Úkernel_versionÚmajor_versionr[   ÚflagsÚarchr}   rž   ÚsdkÚvalsr=   r   r   r   r   Í  s†   
þ




ÿ
ù



r   c                 C   s   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)
    )r   ro   )r=   r   r   r   r   P  s   r   c                  C   sT  t jdkr7d} tj | ¡}|dkrtjS tj d|¡}tj|t| ƒ |…  ¡ }|dkr.dS |dkr4dS tjS t jd	ksAtt d
ƒsDtjS t  	¡ \}}}}}| ¡  
dd¡}| 
dd¡}| 
dd¡}|dd… dkrod||f S |dd… dkr‘|d dkr�d}dt|d ƒd |dd… f }�n|dd… dkrŸd||f S |dd… dkr®d|||f S |dd… d krÉd }t d!¡}	|	 |¡}
|
rÈ|
 ¡ }nÚ|dd… d"k�r£tƒ }| d#¡}	 |}ztd%ƒ}W n	 tyì   Y n)w zt d&| ¡ ¡}
W | ¡  n| ¡  w |
du�rd' |
 d(¡ d'¡dd… ¡}|�s|}|�r£|}d)}|d' d*k�r…d+tƒ  d,d¡ ¡ v �r…d-}tƒ  d,¡}t d.|¡}ttt|ƒƒƒ}t|ƒd(k�rV|d }nM|d/k�r^d-}nE|d0k�rfd1}n=|d2k�rnd3}n5|d4k�rvd5}n-|d6k�r~d7}n%td8|f ƒ‚|d9k�r“tjd:k�r’d;}n|d<v �r£tjd:k�r¡d=}nd>}d?|||f S )@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'.
    r   z bit (éÿÿÿÿú)Úamd64z	win-amd64Úitaniumzwin-ia64r]   rã   ú/r{   rÙ   Ú_ú-Né   Úlinuxz%s-%sÚsunosr   Ú5Úsolarisz%d.%srP   r   é   ÚirixÚaixz%s-%s.%sé   Úcygwinz[\d.]+rl   ÚMACOSX_DEPLOYMENT_TARGETTz0/System/Library/CoreServices/SystemVersion.plistz=<key>ProductUserVisibleVersion</key>\s*<string>(.*?)</string>r    r!   Úmacosxz10.4.z-archr}   Úfatz-arch\s+(\S+))Úi386Úppc)r  Úx86_64Úintel)r  r  r  Úfat3)Úppc64r  Úfat64)r  r  r  r  Ú	universalz%Don't know machine value for archs=%rr  l        r  )ÚPowerPCÚPower_Macintoshr  r  z%s-%s-%s) r   r=   rp   rà   r*   rq   r�   Úlowerr«   rã   r‰   rŠ   r�   r‚   rˆ   r:   r   ro   r„   r±   rŽ   ÚreadÚcloser   rä   r‡   ÚfindallrD   rÉ   r/   r‹   Úmaxsize)rÌ   ÚiÚjÚlookÚosnameÚhostÚreleaserà   ÚmachineÚrel_rerž   ÚcfgvarsÚmacverÚ
macreleaser›   ÚcflagsÚarchsr   r   r   r   Y  s°   
 €

€
ýÿ






ÿ
€
r   c                   C   s   t S r   )r¬   r   r   r   r   r   û  s   r   c                 C   sF   t t| ¡ ƒƒD ]\}\}}|dkrtd|  ƒ td||f ƒ qd S )Nr   z%s: z
	%s = "%s")Ú	enumeraterÉ   rC   Úprint)ÚtitleÚdataÚindexr[   rN   r   r   r   Ú_print_dictÿ  s
   ýr#  c                   C   sR   t dtƒ  ƒ t dtƒ  ƒ t dtƒ  ƒ t ƒ  tdtƒ ƒ t ƒ  tdtƒ ƒ dS )z*Display all information sysconfig detains.zPlatform: "%s"zPython version: "%s"z!Current installation scheme: "%s"ÚPathsÚ	VariablesN)r  r   r   re   r#  r
   r   r   r   r   r   Ú_main  s   r&  Ú__main__r   )@Ú__doc__rƒ   r   r�   rp   Úos.pathr   r   ÚconfigparserÚImportErrorÚConfigParserÚ__all__r   rÁ   r   rÀ   r   rá   r=   r  r   r   r.   r&   r5   ÚRawConfigParserr,   r‚   rI   rO   rr   rÞ   r¬   r¿   r_   rÌ   rÜ   rÍ   rÝ   rÛ   Ú
_USER_BASErV   r\   rb   rd   re   rv   r§   r   r¶   rÂ   r   r   r   r	   r
   r   r   r   r   r   r#  r&  r(   r   r   r   r   Ú<module>   s~   ÿ
!	
v
 	 #

ÿ