o
    Š�bcu6  ã                   @   sV  d Z ddlZddlZddlZddlZddlZddlZddlmZ ddl	m
Z
 ddlmZmZmZmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z( e&ƒ Z)ej*dkrbddlm+Z+ ej,d	e-d
d� ddd„Zee#dd�Z.eee)ƒZeee)ƒZ/ddd„Z0dZ1zesŒej2Z1W n	 e3y–   Y nw dd„ Z4dd„ Z5ddd„Z6ddd„Z7dS )a�  Provide access to Python's configuration information.  The specific
configuration variables available depend heavily on the platform and
configuration.  The values may be retrieved using
get_config_var(name), and the list of variables is available via
get_config_vars().keys().  Additional convenience functions are also
available.

Written by:   Fred L. Drake, Jr.
Email:        <fdrake@acm.org>
é    N)Úpartialé   )ÚDistutilsPlatformError)Ú_PREFIXÚ_BASE_PREFIXÚ_EXEC_PREFIXÚ_BASE_EXEC_PREFIXÚ_PROJECT_BASEÚ_PYTHON_BUILDÚ_init_posixÚparse_config_hÚ_init_non_posixÚ_is_python_source_dirÚ	_sys_homeÚ_variable_rxÚ_findvar1_rxÚ_findvar2_rxÚexpand_makefile_varsÚis_python_buildÚget_config_h_filenameÚget_config_varÚget_config_varsÚget_makefile_filenameÚget_python_versionÚnt)Ú_fix_pcbuildzCThe distutils.sysconfig module is deprecated, use sysconfig insteadé   )Ú
stacklevelc                 C   s   t | |d�S )N)Úvars)Úsysconfig_parse_config_h)ÚfpÚg© r"   ú*/usr/lib/python3.10/distutils/sysconfig.pyr   C   s   r   T)Ú
check_homec              	   C   sª  ddl m} || ddddd�}|du ri }i }i }	 | ¡ }|du r#n@t t|¡}|rb| dd¡\}}	|	 ¡ }	|	 d	d
¡}
d|
v rF|	||< nzt	|	ƒ}	W n t
y]   |	 d	d¡||< Y nw |	||< qd}|�r4t|ƒD ]Å}|| }t t|¡p}t t|¡}|�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ñ|||< qlzt	|ƒ}W n t
�y   | ¡ ||< Y nw |||< ||= | d¡�r-|dd… |v �r-|dd… }||v�r-|||< ql||= ql|sh| ¡  | ¡ D ]\}}	t|	tƒ�rL|	 ¡ ||< �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.
    r   )ÚTextFiler   Úsurrogateescape)Ústrip_commentsÚskip_blanksÚ
join_linesÚerrorsNTr   z$$Ú ú$)ÚCFLAGSÚLDFLAGSÚCPPFLAGSFÚPY_é   )Údistutils.text_filer%   ÚreadlineÚreÚmatchr   ÚgroupÚstripÚreplaceÚintÚ
ValueErrorÚlistÚsearchr   r   ÚstrÚosÚenvironÚ
startswithÚendÚstartÚcloseÚitemsÚ
isinstanceÚupdate)Úfnr!   r%   r    ÚdoneÚnotdoneÚlineÚmÚnÚvÚtmpvÚrenamed_variablesÚnameÚvalueÚfoundÚitemÚafterÚkr"   r"   r#   Úparse_makefileN   sŽ   
þì


ÿ
€Ð2€
rV   r+   c                 C   s’  | j dk�rGtjdkrt d¡sddl}| t¡ dtd< tddd	d
dddddddƒ\}}}}}}}}	}
}}dtj	v r[tj	d }tjdkrYdtj	vrY| 
|¡rY||t|ƒd…  }|}dtj	v retj	d }t ||gd¡r| dd¡}| dd¡}| dd¡}dtj	v r‰tj	d }dtj	v r”tj	d }n|d }dtj	v r§|d tj	d  }n|r¯|d | }d	tj	v rÇ|d tj	d	  }|d tj	d	  }n|rÕ|d | }|d | }dtj	v rö|d tj	d  }|d tj	d  }|d tj	d  }n|
�r|d |
 }|d |
 }|d |
 }dtj	v �rtj	d }dtj	v �r&|d tj	d  }n|d |	 }|d | }| j|||d | ||||d� || _dS dS )zÄDo any platform-specific customization of a CCompiler instance.

    Mainly needed on Unix, so we can plug in the information that
    varies across Unices and is stored in Python's Makefile.
    ÚunixÚdarwinÚCUSTOMIZED_OSX_COMPILERr   NÚTrueÚCCÚCXXr-   ÚCCSHAREDÚLDSHAREDÚSHLIB_SUFFIXÚARÚARFLAGSÚCONFIGURE_CPPFLAGSÚCONFIGURE_CFLAGSÚCONFIGURE_LDFLAGSz	*-4.[0-8]z-fstack-protector-strongz-fstack-protectorÚCPPz -Er.   ú r/   )ÚpreprocessorÚcompilerÚcompiler_soÚcompiler_cxxÚ	linker_soÚ
linker_exeÚarchiver)Úcompiler_typeÚsysÚplatformÚ_config_varsÚgetÚ_osx_supportÚcustomize_compilerr   r>   r?   r@   ÚlenÚfnmatchÚfilterr8   Úset_executablesÚshared_lib_extension)rh   rs   ÚccÚcxxÚcflagsÚccsharedÚldsharedÚshlib_suffixÚarÚar_flagsÚconfigure_cppflagsÚconfigure_cflagsÚconfigure_ldflagsÚnewccÚcpprm   Úcc_cmdr"   r"   r#   rt   Ç   s„   

	

þþ



ÿ









ù
	³rt   c                   C   s   t jt jkp
tt dƒS )NÚreal_prefix)ro   Úbase_prefixÚprefixÚhasattrr"   r"   r"   r#   Úis_virtual_environment  s   rŒ   c                 C   sÒ   |du r
| rt p	t}tjdkrBtr&| rtptS tj t	dƒd¡}tj 
|¡S dtƒ  t }ts:| r:ddl}| d¡S tj |d|¡S tjd	krbtr[tj |d¡tjj tj |d
¡ S tj |d¡S tdtj ƒ‚)a¤  Return the directory containing installed Python header files.

    If 'plat_specific' is false (the default), this is the path to the
    non-platform-specific header files, i.e. Python.h and so on;
    otherwise, this is the path to platform-specific header files
    (namely pyconfig.h).

    If 'prefix' is supplied, use it instead of sys.base_prefix or
    sys.base_exec_prefix -- i.e., ignore 'plat_specific'.
    NÚposixÚsrcdirÚIncludeÚpythonr   ÚplatincludeÚincluder   ÚPCzFI don't know where Python installs its C header files on platform '%s')ÚBASE_EXEC_PREFIXÚBASE_PREFIXr>   rP   Úpython_buildr   Úproject_baseÚpathÚjoinr   Únormpathr   Úbuild_flagsÚ	sysconfigÚget_pathÚpathsepr   )Úplat_specificrŠ   ÚincdirÚ
python_dirrœ   r"   r"   r#   Úget_python_inc!  s0   


ÿÿÿr¢   c                 C   sÜ   | p
t j |¡dv }|du r|r| rtpt}n| rtpt}t jdkrQ| s'|r+tj	}nd}t j 
||dtƒ  ¡}|r<|S |rJtƒ sJt j 
|ddd¡S t j 
|d¡S t jd	krg|r_t j 
|d
¡S t j 
|d
d¡S tdt j ƒ‚)aS  Return the directory containing the Python library (standard or
    site additions).

    If 'plat_specific' is true, return the directory containing
    platform-specific modules, i.e. any module from a non-pure-Python
    module distribution; otherwise, return the platform-shared library
    directory.  If 'standard_lib' is true, return the directory
    containing standard Python library modules; otherwise, return the
    directory for site-specific modules.

    If 'prefix' is supplied, use it instead of sys.base_prefix or
    sys.base_exec_prefix -- i.e., ignore 'plat_specific'.
    )z/usrz
/usr/localNr�   Úlibr�   Úpython3zdist-packageszsite-packagesr   ÚLibz?I don't know where Python installs its library on platform '%s')r>   r˜   rš   r”   r•   ÚEXEC_PREFIXÚPREFIXrP   ro   Ú
platlibdirr™   r   rŒ   r   )rŸ   Ústandard_librŠ   Úis_default_prefixÚlibdirÚ	libpythonr"   r"   r#   Úget_python_libL  s4   

ÿ

ÿÿr­   )N)r   N)r   r   N)8Ú__doc__Ú_impr>   r4   ro   Úwarningsrv   Ú	functoolsr   r*   r   rœ   r   r§   r   r•   r   r¦   r   r”   r	   r—   r
   r–   r   Úsysconfig_init_posixr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rq   rP   r   ÚwarnÚDeprecationWarningÚ_python_buildÚ_init_ntrV   r›   ÚabiflagsÚAttributeErrorrt   rŒ   r¢   r­   r"   r"   r"   r#   Ú<module>   sF    \
ý



o€ýV
+