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se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 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)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 rtj	d }dtj	v rt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 )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.
    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
+