o
     JAf1                     @   sF  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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r^d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Z/dZ0zesej1Z0W n	 e2y   Y nw dd Z3dddZ4dddZ5d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   B   s   r   T)Z
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 rt|| }n>||v rd}n7|tjv rtj| }n,||v r|dr|dd |v rd
}nd| |v rd}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 )zParse 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)Zstrip_commentsZskip_blanksZ
join_lineserrorsNTr   z$$ $)CFLAGSLDFLAGSCPPFLAGSFZPY_   )Z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    doneZnotdonelinemnvZtmpvZrenamed_variablesnamevaluefounditemZafterkr"   r"   r#   parse_makefileM   s   




2
rL   r'   c              	   C   s  | j dkrtjdkrtdsddl}|t dtd< tddd	d
dddd\}}}}}}}}	dtj	v rTtj	d }
tjdkrRdtj	vrR|
|rR|
|t|d  }|
}dtj	v r^tj	d }dtj	v rhtj	d }dtj	v rstj	d }n|d }dtj	v r|d tj	d  }d	tj	v r|d tj	d	  }|d tj	d	  }dtj	v r|d tj	d  }|d tj	d  }|d tj	d  }dtj	v rtj	d }dtj	v r|d tj	d  }n|d |	 }|d | }| j|||d | ||||d || _dS dS )zDo 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.
    ZunixdarwinZCUSTOMIZED_OSX_COMPILERr   NTrueZCCZCXXr)   ZCCSHAREDZLDSHAREDZSHLIB_SUFFIXZARZARFLAGSZCPPz -Er*    r+   )ZpreprocessorcompilerZcompiler_soZcompiler_cxxZ	linker_soZ
linker_exearchiver)Zcompiler_typesysplatform_config_varsget_osx_supportcustomize_compilerr   r8   r9   r:   lenZset_executablesZshared_lib_extension)rP   rV   ZccZcxxZcflagsZccsharedZldsharedZshlib_suffixarZar_flagsZnewccZcpprQ   Zcc_cmdr"   r"   r#   rW      sf   


	


















	rW   c                 C   s   |du r
| rt p	t}tjdkr5tr&| rtptS tjt	dd}tj
|S dt  t }tj|d|S tjdkrUtrNt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posixZsrcdirZIncludepythonZincluder   ZPCzFI don't know where Python installs its C header files on platform '%s')BASE_EXEC_PREFIXBASE_PREFIXr8   rG   python_buildr   project_basepathjoinr   normpathr   build_flagspathsepr   )plat_specificprefixZincdirZ
python_dirr"   r"   r#   get_python_inc  s*   

rg   c                 C   s   |du r|r| r
t pt}n| rtpt}tjdkr8| s|r tj}nd}tj	||dt
  }|r1|S tj	|dS tjdkrN|rFt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'.
    NrZ   libr[   zsite-packagesr   ZLibz?I don't know where Python installs its library on platform '%s')r\   r]   EXEC_PREFIXPREFIXr8   rG   rR   
platlibdirr`   ra   r   r   )re   Zstandard_librf   libdirZ	libpythonr"   r"   r#   get_python_lib5  s.   


rm   )N)r   N)r   r   N)6__doc___impr8   r.   rR   warnings	functoolsr   r&   r   Z	sysconfigr   rj   r   r]   r   ri   r   r\   r	   r_   r
   r^   r   Zsysconfig_init_posixr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rT   rG   r   warnDeprecationWarningZ_python_buildZ_init_ntrL   rc   abiflagsAttributeErrorrW   rg   rm   r"   r"   r"   r#   <module>   sB    \




o
G(