/ lib / setuptools / _distutils / sysconfig.pyc
sysconfig.pyc
  1  o

  2  ���c�I�@sdZddlZddlZddlZddlZddlZddlmZddlm	Z	ddl
  3  mZdejvZ
ej�ej�Zej�ej�Zej�ej�Zej�ej�ZdejvrXej�ejd�Znejrgej�ej�ej��Zne��Zd	d
  4  �Zeedd�Z dd
�Z!ej"dkr�edd��Z#e#e�Ze#e �Z dd�Z$e$�Z%dZ&ze%s�ej'Z&Wn	e(y�Ynwdd�Z)d9dd�Z*dd�Z+dd�Z,dd�Z-dd�Z.d d!�Z/d"d#�Z0d:d$d%�Z1d&d'�Z2d(d)�Z3d*d+�Z4d;d,d-�Z5e�6d.�Z7e�6d/�Z8e�6d0�Z9d;d1d2�Z:d3d4�Z;da<d5d6�Z=d7d8�Z>dS)<a�Provide access to Python's configuration information.  The specific
  5  configuration variables available depend heavily on the platform and
  6  configuration.  The values may be retrieved using
  7  get_config_var(name), and the list of variables is available via
  8  get_config_vars().keys().  Additional convenience functions are also
  9  available.
 10  
 11  Written by:   Fred L. Drake, Jr.
 12  Email:        <fdrake@acm.org>
 13  �N�)�DistutilsPlatformError)�
 14  py39compat)�	pass_none�__pypy__�_PYTHON_PROJECT_BASEcs&t�|��d��t�fdd�dD��S)z]
 15      Return True if the target directory appears to point to an
 16      un-installed Python.
 17      �Modulesc3s�|]
 18  }��|���VqdS�N)�joinpath�is_file)�.0�fn��modules���C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2800.0_x64__qbz5n2kfra8p0\lib\site-packages\setuptools\_distutils\sysconfig.py�	<genexpr>2s�z(_is_python_source_dir.<locals>.<genexpr>)�SetupzSetup.local)�pathlib�Pathr
 19  �any��drrr�_is_python_source_dir,sr�_homecCstj�|��tj�|��S)z,
 20      Return True if a is a parent of b.
 21      )�os�path�normcase�
 22  startswith)�dir_a�dir_brrr�
 23  _is_parent8sr!�ntcs$ttf}�fdd�|D�}t|��S)Nc3s(�|]}t�tj�|d��r|VqdS)�PCbuildN)r!rr�join)r�prefixrrrrEs��
 24  �z_fix_pcbuild.<locals>.<genexpr>)�PREFIX�BASE_PREFIX�next)r�prefixes�matchedrrr�_fix_pcbuildAs
 25  
 26  �
 27  r+cCstrtt�Stt�Sr	)�	_sys_homer�project_baserrrr�
_python_buildPsr.�cCsdtjdd�S)z�Return a string containing the major and minor Python version,
 28      leaving off the patchlevel.  Sample return values could be '1.5'
 29      or '2.2'.
 30      z%d.%dN�)�sys�version_inforrrr�get_python_versionfsr3cCs\|rtnt}|dur|n|}zt�dtj��}Wnty'tdtj��w||||�S)a�Return the directory containing installed Python header files.
 31  
 32      If 'plat_specific' is false (the default), this is the path to the
 33      non-platform-specific header files, i.e. Python.h and so on;
 34      otherwise, this is the path to platform-specific header files
 35      (namely pyconfig.h).
 36  
 37      If 'prefix' is supplied, use it instead of sys.base_prefix or
 38      sys.base_exec_prefix -- i.e., ignore 'plat_specific'.
 39      N�_get_python_inc_zFI don't know where Python installs its C header files on platform '%s')�BASE_EXEC_PREFIXr'�globalsr�name�KeyErrorr)�
plat_specificr%�default_prefix�resolved_prefix�getterrrr�get_python_incns���r=cCs6trtjdkrtj�|d�St|�pt||�pt|�S)N����include)	�IS_PYPYr1r2rrr$�_get_python_inc_posix_python�_get_python_inc_from_config�_get_python_inc_posix_prefix�r%�spec_prefixr9rrr�_get_python_inc_posix�s��rHcCs2tsdS|r
 40  tp	tStj�td�d�}tj�|�S)z�
 41      Assume the executable is in the build directory. The
 42      pyconfig.h file should be in the same directory. Since
 43      the build directory may not be the source directory,
 44      use "srcdir" from the makefile to find the "Include"
 45      directory.
 46      N�srcdir�Include)�python_buildr,r-rrr$�get_config_var�normpath)r9�incdirrrrrC�srCcCs|durtd|d�SdS)aj
 47      If no prefix was explicitly specified, provide the include
 48      directory from the config vars. Useful when
 49      cross-compiling, since the config vars may come from
 50      the host
 51      platform Python installation, while the current Python
 52      executable is from the build platform installation.
 53  
 54      >>> monkeypatch = getfixture('monkeypatch')
 55      >>> gpifc = _get_python_inc_from_config
 56      >>> monkeypatch.setitem(gpifc.__globals__, 'get_config_var', str.lower)
 57      >>> gpifc(False, '/usr/bin/')
 58      >>> gpifc(False, '')
 59      >>> gpifc(False, None)
 60      'includepy'
 61      >>> gpifc(True, None)
 62      'confincludepy'
 63      N�CONF�	INCLUDEPY)rL)r9rGrrrrD�s�rDcCs*trdnd}|t�t}tj�|d|�S)N�pypy�pythonrA)rBr3�build_flagsrrr$)r%�implementation�
 64  python_dirrrrrE�srEcCs6trtj�|d�tjjtj�|d�Stj�|d�S)NrA�PC)rKrrr$�pathseprFrrr�_get_python_inc_nt�s���rXcCs|r|Stj�|d�S)N�
site-packages)rrr$)�standard_lib�	libpython�early_prefixr%rrr�
 65  _posix_lib�sr]cCs�tr!tjdkr!|dur
t}|rtj�|dtjd�Stj�|d�S|}|dur6|r0|r-tp.t	}n|r4t
 66  p5t}tjdkr`|s?|rFttdd�}nd}trLd	nd
 67  }tj�|||t
��}t||||�Stjdkrv|rntj�|d�Stj�|dd�Std
tj��)aSReturn the directory containing the Python library (standard or
 68      site additions).
 69  
 70      If 'plat_specific' is true, return the directory containing
 71      platform-specific modules, i.e. any module from a non-pure-Python
 72      module distribution; otherwise, return the platform-shared library
 73      directory.  If 'standard_lib' is true, return the directory
 74      containing standard Python library modules; otherwise, return the
 75      directory for site-specific modules.
 76  
 77      If 'prefix' is supplied, use it instead of sys.base_prefix or
 78      sys.base_exec_prefix -- i.e., ignore 'plat_specific'.
 79      r>Nz
 80  lib-pythonrrY�posix�
 81  platlibdir�librQrRr"�Libz?I don't know where Python installs its library on platform '%s')rBr1r2r&rrr$�versionr5r'�EXEC_PREFIXr7�getattrr3r]r)r9rZr%r\�libdirrTr[rrr�get_python_lib�s6
 82  
 83  ��rfc	Cs|jdk�rtjdkrtd�sddl}|�t�dtd<tddd	d
 84  ddd
d�\}}}}}}}}	dtj	vrOtj	d}
 85  dtj	vrM|�
 86  |�rM|
 87  |t|�d�}|
 88  }dtj	vrYtj	d}dtj	vrctj	d}dtj	vrntj	d}n|d}dtj	vr�|dtj	d}d	tj	vr�|dtj	d	}|dtj	d	}dtj	vr�|dtj	d}|dtj	d}|dtj	d}d
tj	vr�tj	d
}dtj	vr�|dtj	d}n|d|	}|d|}
|j||
|
d|||||d�dtj	v�r|j
�dd��r|jtj	dd�||_dSdS)z�Do any platform-specific customization of a CCompiler instance.
 89  
 90      Mainly needed on Unix, so we can plug in the information that
 91      varies across Unices and is stored in Python's Makefile.
 92      �unix�darwin�CUSTOMIZED_OSX_COMPILERrN�True�CC�CXX�CFLAGS�CCSHARED�LDSHARED�SHLIB_SUFFIX�AR�ARFLAGS�CPPz -E�LDFLAGS� �CPPFLAGS)�preprocessor�compiler�compiler_so�compiler_cxx�	linker_so�
 93  linker_exe�archiver�RANLIB�ranlib)r)�
compiler_typer1�platformrL�_osx_support�customize_compiler�_config_vars�get_config_varsr�environr�len�set_executables�executables�get�shared_lib_extension)rxr��cc�cxx�cflags�ccshared�ldshared�shlib_suffix�ar�ar_flags�newcc�cppr}�cc_cmdrrrr�s�
 94  
 95  ��
 96  
 97  
 98  
 99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  �
110  
111  �r�cCs@trtjdkrtj�tp
td�}ntpt}tj�|d�St��S)z2Return full pathname of installed pyconfig.h file.r"rVz
112  pyconfig.h)	rKrr7rr$r,r-�	sysconfig�get_config_h_filename)�inc_dirrrrr�bs
113  r�cCst��S)zAReturn full pathname of installed Makefile from the Python build.)r��get_makefile_filenamerrrrr�nsr�cCstj||d�S)z�Parse a config.h-style file.
114  
115      A dictionary containing name/value pairs is returned.  If an
116      optional dictionary is passed in as the second argument, it is
117      used instead of a new dictionary.
118      )�vars)r��parse_config_h)�fp�grrrr�ssr�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_]*)}c	Cs�ddlm}||ddddd�}|duri}i}i}	|��}|dur#n?t�|�}|ra|�dd�\}}	|	��}	|	�d	d
119  �}
120  d|
121  vrE|	||<nzt|	�}	Wnt	y\|	�d	d�||<Ynw|	||<qd}|�r1t
122  |�D]�}||}
t�|
�pzt
�|
�}|�r+|�d�}d}||vr�t||�}n>||vr�d
}n7|tjvr�tj|}n,||vr�|�d�r�|dd�|vr�d
123  }nd||vr�d
}nt|d|�}nd
124  ||<}|�r*|
|��d�}|
d|���||}
d|vr�|
||<qkzt|
�}
Wnt	�y|
��||<Ynw|
||<||=|�d��r*|dd�|v�r*|dd�}||v�r*|
||<qk||=qk|sg|��|��D]\}}	t|	t��rI|	��||<�q9|�|�|S)z�Parse a Makefile-style file.
125  
126      A dictionary containing name/value pairs is returned.  If an
127      optional dictionary is passed in as the second argument, it is
128      used instead of a new dictionary.
129      r)�TextFiler�surrogateescape)�strip_comments�skip_blanks�
130  join_lines�errorsNTr0z$$r/�$)rmrtrvF�PY_r?)�distutils.text_filer��readline�_variable_rx�match�group�strip�replace�int�
131  ValueError�list�_findvar1_rx�search�_findvar2_rx�strrr�r�end�start�close�items�
132  isinstance�update)r
r�r�r��done�notdone�line�m�n�v�tmpv�renamed_variablesr7�value�found�item�after�krrr�parse_makefile�s�
133  �
134  
135  ��
136  
137  
138  �
139  ��2�
140  r�cCsX	t�|�p
141  t�|�}|r(|��\}}|d|�|�|�d��||d�}n	|Sq)a�Expand Makefile-style variables -- "${foo}" or "$(foo)" -- in
142      'string' according to 'vars' (a dictionary mapping variable names to
143      values).  Variables not present in 'vars' are silently expanded to the
144      empty string.  The variable values in 'vars' should not contain further
145      variable expansions; if 'vars' is the output of 'parse_makefile()',
146      you're fine.  Returns a variable-expanded version of 's'.
147      TrrN)r�r�r��spanr�r�)�sr�r��begr�rrr�expand_makefile_vars�s*�r�cGsHtdurt����at�t�|r"g}|D]
148  }|�t�|��q|StS)a�With no arguments, return a dictionary of all configuration
149      variables relevant for the current platform.  Generally this includes
150      everything needed to build extensions and install both pure modules and
151      extensions.  On Unix, this means every variable defined in Python's
152      installed Makefile; on Windows it's a much smaller set.
153  
154      With arguments, return a list of values that result from looking up
155      each argument in the configuration variable dictionary.
156      N)r�r�r��copyr�add_ext_suffix�appendr�)�args�valsr7rrrr�
s
157  r�cCs*|dkrddl}|�dtd�t��|�S)z�Return the value of a single variable using the dictionary
158      returned by 'get_config_vars()'.  Equivalent to
159      get_config_vars().get(name)
160      �SOrNz SO is deprecated, use EXT_SUFFIXr0)�warnings�warn�DeprecationWarningr�r�)r7r�rrrrL%srL)rN)rrNr	)?�__doc__r�rer1r�rr�rr/r�
161  _functoolsr�builtin_module_namesrBrrMr%r&�exec_prefixrc�base_prefixr'�base_exec_prefixr5r��abspathr-�
162  executable�dirname�getcwdrrdr,r!r7r+r.rKrS�abiflags�AttributeErrorr3r=rHrCrDrErXr]rfr�r�r�r��compiler�r�r�r�r�r�r�rLrrrr�<module>st
163  
164  	
165  
166  
167  ��
168  
169  
170  6\
171  
172  
173  
174  
175  m