/ lib / numpy / distutils / misc_util.pyc
misc_util.pyc
   1  o

   2  [��c�f�@s^ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
   3  Z
   4  ddlZddl
mZddlmZddlZddlmZe�ZgZdd�Ze�e�gd�ZGdd	�d	�Zd
   5  d�Zdd
�Zdd�Zdd�Zd�dd�Zdd�Z d�dd�Z!dd�Z"dd�Z#dd�Z$d�d d!�Z%d�d"d#�Z&d$d%�Z'e'�r�e(dd&d'd(d)d*d+d,d-d.�	Z)d�d0d1�Z*nd�d2d1�Z*d3d4�Z+d5d6�Z,d7d8�Z-d9d:�Z.d;d<�Z/d=d>�Z0d?e1d@e1fdAdB�Z2dCdD�Z3dEdF�Z4dGdH�Z5dIdJ�Z6e�7dKej8�j9Z:e�7dLej8�j9Z;e�7dMej8�j9Z<e�7dNej8�j9Z=dOdP�Z>dQdR�Z?dSdT�Z@dUdV�ZAdWdX�ZBdYdZ�ZCd[d\�ZDd]d^�ZEd_d`�ZFdadb�ZGdcdd�ZHdedf�ZIdgdh�ZJdidj�ZKdkdl�ZLdmdn�ZMdodp�ZNdqdr�ZOdsdt�ZPdudv�ZQd�dwdx�ZRdydz�ZSd{d|�ZTd�d}d~�ZUGdd��d��ZVifd�d��ZWd�d��ZXd�d��ZYd�d�d��ZZd�d�d��Z[d�d��Z\d�d�d��Z]d�d��Z^d�d��Z_d�d��Z`d�d��Zad�d��Zbd�d�hZcd�d��Zdd�d��ZedS)��N)�local)�reduce)�DistutilsErrorc	Cs:tdurtD]}zt�|�WqtyYqwdSdS�N)�_tmpdirs�shutil�rmtree�OSError)�d�r��C:\Users\Jacks.GUTTSPC\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\numpy\distutils\misc_util.py�clean_up_temporary_directorys��r
)*�
Configuration�get_numpy_include_dirs�default_config_dict�dict_append�
   6  appendpath�generate_config_py�get_cmd�allpath�get_mathlibs�terminal_has_colors�red_text�
   7  green_text�yellow_text�	blue_text�	cyan_text�	cyg2win32�mingw32�all_strings�
has_f_sources�has_cxx_sources�filter_sources�get_dependencies�is_local_src_dir�get_ext_source_files�get_script_files�get_lib_source_files�get_data_files�dot_join�	get_frame�
   8  minrelpath�njoin�is_sequence�	is_string�as_list�gpaths�get_language�get_build_architecture�get_info�get_pkg_info�get_num_build_jobs�sanitize_cxx_flags�exec_mod_from_locationc@seZdZdZdd�ZdS)�InstallableLiba�
   9      Container to hold information on an installable library.
  10  
  11      Parameters
  12      ----------
  13      name : str
  14          Name of the installed library.
  15      build_info : dict
  16          Dictionary holding build information.
  17      target_dir : str
  18          Absolute path specifying where to install the library.
  19  
  20      See Also
  21      --------
  22      Configuration.add_installed_library
  23  
  24      Notes
  25      -----
  26      The three parameters are stored as attributes with the same names.
  27  
  28      cCs||_||_||_dSr)�name�
  29  build_info�
  30  target_dir)�selfr9r:r;rrr�__init__Fs
  31  zInstallableLib.__init__N)�__name__�
  32  __module__�__qualname__�__doc__r=rrrrr80sr8cCs�ddlm}z	tt�d��}Wn
tyt��}Ynwt|d�}t	tj
  33  �d|��}|�}|dur4|St|�
d�dd�t|�
d�dd�t|�
d	�dd�f}td
  34  d�|D��rY|Stdd�|D��S)
a�
  35      Get number of parallel build jobs set by the --parallel command line
  36      argument of setup.py
  37      If the command did not receive a setting the environment variable
  38      NPY_NUM_BUILD_JOBS is checked. If that is unset, return the number of
  39      processors on the system, with a maximum of 8 (to prevent
  40      overloading the system if there a lot of CPUs).
  41  
  42      Returns
  43      -------
  44      out : int
  45          number of parallel jobs that can be run
  46  
  47      r��get_distribution�ZNPY_NUM_BUILD_JOBSN�build�parallel�	build_ext�
  48  build_clibcss�|]}|duVqdSrr��.0�xrrr�	<genexpr>ks�z%get_num_build_jobs.<locals>.<genexpr>css�|]	}|dur|VqdSrrrIrrrrLns�)�numpy.distutils.corerC�len�osZsched_getaffinity�AttributeError�multiprocessing�	cpu_count�min�int�environ�get�getattr�get_command_obj�all�max)rCrRZenvjobs�distZcmdattrrrrr5Ls$�
  49  �r5cCs^ddl}|jdtdd�t|�}tt|��D]}||}d|vr,|ddvr,d|||<q|S)	z8Quote list of arguments.
  50  
  51      .. deprecated:: 1.22.
  52      rNz"quote_args" is deprecated.���
  53  stacklevel� z"'z"%s")�warnings�warn�DeprecationWarning�list�rangerN)�argsr`�i�arrr�
  54  quote_argsps��rhcCs|�d�}tjj|�S)zDConvert a /-separated pathname to one using the OS's path separator.�/)�splitrO�path�join)r9rjrrrr�s
  55  rcCs�tj�tj�|��}tj�tj�|��}t|�t|�kr|S||kr$dS||dt|��krN|t|�tjfvsDJt||t|�f���|t|�dd�}|S)z$Return path relative to parent_path.�N�)rOrk�realpath�abspathrN�sep�repr)rk�parent_path�pd�apathrrr�rel_path�s,rvcCs�ztd|j|j�}tj�tj�|��}Wn1tyEtd|j|j�}t|�t	j
  56  |}t|d�r=tj�tj�|j��}ntj�d�}Ynw|durOt
||�}|pRdS)z�Return path of the module given a frame object from the call stack.
  57  
  58      Returned path is relative to parent_path when given,
  59      otherwise it is absolute path.
  60      �__file__r>�.N)�eval�	f_globals�f_localsrOrk�dirnamerp�	NameError�
  61  __import__�sys�modules�hasattrrwrv)�framersZcaller_filer
  62  �caller_name�modrrr�get_path_from_frame�s
  63  
  64  ��
  65  r�cGszg}|D]}t|�r|�t|��qt|�sJ�|�|�q|}|s%d}ntjj|�}tjjdkr9|�dtjj�}t	|�S)a2Join two or more pathname components +
  66      - convert a /-separated pathname to one using the OS's path separator.
  67      - resolve `..` and `.` from path.
  68  
  69      Either passing n arguments as in njoin('a','b'), or a sequence
  70      of n names as in njoin(['a','b']) is handled, or a mixture of such arguments.
  71      rmri)
  72  r-�appendr,r.rOrkrlrq�replacer+)rk�paths�p�joinedrrrr,�sr,c	Cs�|durtj�|d�}n t�}|D]}tj�|d�}tj�|�r$|}nqtd|f��t|��+}g}d}|D]}|�|�rR|t|�d��	�}|rR|�
  73  |�d��q7Wd�|S1s^wY|S)z/Return the MATHLIB line from numpyconfig.h
  74      Nz_numpyconfig.hz1_numpyconfig.h not found in numpy include dirs %rz#define MATHLIB�,)rOrkrlr�existsr�open�
  75  startswithrN�strip�extendrj)	rk�config_file�dirs�fn�fid�mathlibs�s�line�valuerrrr�s4��
  76  
  77  ��
  78  ��rcCs�t|�s|Sd|vr|S|�tj�}|r+z|�dd�}Wn	ty%Ynw||=|sd}|rZz|�d|�}Wn	ty@Ynw||ddkrN|d7}n
  79  ||=||d=d}|s/|s^dStj�|�S)z$Resolve `..` and '.' from path.
  80      rxrnz..rm)r.rjrOrq�index�
  81  ValueErrorrl)rk�lrf�jrrrr+�s8���
  82  �
  83  r+cCstt�|��S)z}sorts output of python glob for https://bugs.python.org/issue30461
  84      to allow extensions to have reproducible build results)�sorted�glob)Zfileglobrrr�sorted_globsr�cCsBt|�sJtt|����g}t|�rJt|���|D]}t|�r�d|vs(d|vrSt|�}tt||��}|r;|�|�q|rC|�|�q|rJ|�|�td||f�qt||�}t	j
  85  �|�rd|�|�qt	j
  86  �|�rp|�|�n|rw|�|�t	j
  87  �|�s�td||f�qt|�r�|�t|||��q|�|�qdd�|D�S)N�*�?z#could not resolve pattern in %r: %rznon-existing path in %r: %rcSsg|]}t|��qSr)r+�rJr�rrr�
  88  <listcomp>-�z_fix_paths.<locals>.<listcomp>)
r-rr�typer.r�r,r�r��printrOrkr��
  89  _fix_paths)r��
  90  local_path�include_non_existingZ	new_paths�nr��p2�n2rrrr�
  91  sB
  92  �
  93  
  94  ��r�rmTcCst|�r|f}t|||�S)z:Apply glob to paths and prepend local_path if needed.
  95      )r.r�)r�r�r�rrrr0/sr0cCsLttd�st��t_t�tj�tj||tj|d�\}}t�	|d�}||fS)N�tempdir)�suffix�prefix�dir�text�w)
  96  r��_tdata�tempfile�mkdtempr�rr��mkstemprO�fdopen)r�r�r�r�r9�forrr�make_temp_file6s
  97  
  98  
  99  �r�cCs�tjdkrdtjvrdSttjd�rgtj��rgzEddl}|��|�	d�dkrT|�	d�dkrW|�
 100  d�dur<|�
 101  d�dusQ|�
 102  d	�durJ|�
 103  d
 104  �dusQ|�
 105  d�durZWdSWdSWdSWdStyfYdSwdS)
N�cygwinZ	USE_COLORr�isatty�colors�pairs�setf�setb�setafZsetabZscprn)r�platformrOrUr��stdoutr��curses�	setupterm�tigetnum�tigetstr�	Exception)r�rrrrCs2	�
 106  �	���rrnr\������	)	�black�red�green�yellow�blue�magenta�cyan�white�defaultFcCsxg}|r	|�d�|rdt�|��d�}|�t|��|r/dt�|��d�}|�t|��|r:dd�|�|fS|S)N�1�r�(r�z[%sm%s�;)r��
_colour_codesrV�lower�strrl)r��fg�bg�bold�seqZfgcodeZbgcoderrr�colour_textas
 107  r�cCs|Srr)r�r�r�rrrr�pscC�
 108  t|d�S)Nr��r��r�rrr�default_texts�
 109  r�cCr�)Nr�r�r�rrrrur�rcCr�)Nr�r�r�rrrrwr�rcCr�)Nr�r�r�rrrryr�rcCr�)Nr�r�r�rrrr{r�rcCr�)Nr�r�r�rrrr}r�rrk�returncCs"tjdkr|Stjdd|gdd�S)a(Convert a path from Cygwin-native to Windows-native.
 110  
 111      Uses the cygpath utility (part of the Base install) to do the
 112      actual conversion.  Falls back to returning the original path if
 113      this fails.
 114  
 115      Handles the default ``/cygdrive`` mount prefix as well as the
 116      ``/proc/cygdrive`` portable prefix, custom cygdrive prefixes such
 117      as ``/`` or ``/mnt``, and absolute paths such as ``/usr/src/`` or
 118      ``/home/username``
 119  
 120      Parameters
 121      ----------
 122      path : str
 123         The path to convert
 124  
 125      Returns
 126      -------
 127      converted_path : str
 128          The converted path
 129  
 130      Notes
 131      -----
 132      Documentation for cygpath utility:
 133      https://cygwin.com/cygwin-ug-net/cygpath.html
 134      Documentation for the C function it wraps:
 135      https://cygwin.com/cygwin-api/func-cygwin-conv-path.html
 136  
 137      r�z/usr/bin/cygpathz	--windowsT)r�)rr��
 138  subprocess�check_output)rkrrrr�s
 139  
 140  
 141  �rcCs:tjdkrtj�dd�dkrdStj�dd�dkrdSdS)	z0Return true when using mingw32 environment.
 142      �win32ZOSTYPErmZmsysTZMSYSTEMZMINGW32F)rr�rOrUrVrrrrr�s
 143  rcCs:tj�d�}|dkrttj|d|d��}|Sd}|S)zGReturn version of MSVC runtime library, as defined by __MSC_VER__ macrozMSC v.�����r��
 144  N)r�version�findrT)�msc_pos�msc_verrrr�msvc_runtime_version�s�r�cCs&t�}|r|dkr
d|Sd|SdS)zFReturn name of MSVC runtime library if Python was built with MSVC >= 7�zmsvcr%izvcruntime%iN)�msvc_runtime_major)�verrrr�msvc_runtime_library�sr�cCs ddddddd��t�d�}|S)	zFReturn major version of MSVC runtime coded like get_build_msvc_version�F�G�P�Z�dr�)iiixi�i@ilN)rVr�)�majorrrrr��s�
 145  �r�z.*\.(cpp|cxx|cc)\Zz.*\.(f90|f95|f77|for|ftn|f)\Zz.*\.(f90|f95)\Zz\s*module\s*(?P<name>[\w_]+)cCsjt|�sgSg}t|d��}|D]}t|�}|r"|�d�}|�|�qWd�|S1s.wY|S)zRReturn a list of Fortran f90 module names that
 146      given source file defines.
 147      �rr9N)�
f90_ext_matchr��f90_module_name_match�groupr�)�sourcer��fr��mr9rrr�_get_f90_modules�s
 148  
 149  ��
 150  ��rcCs
 151  t|t�Sr)�
 152  isinstancer�r�rrrr.�r�r.cCs|D]	}t|�sdSqdS)z4Return True if all items in lst are string objects. FT�r.)�lst�itemrrrr��
 153  �rcCs0t|�rdSzt|�WdStyYdSw)NFT)r.rNr��r�rrrr-�s
 154  ��r-cCst|�od|vpd|vS)Nr�r�rr�rrr�is_glob_pattern�srcCst|�rt|�S|gSr)r-rcr
 155  rrrr/�sr/cCs:d}|D]}t|t�rt|�rd}|St|�rd}q|S)z2Determine language value (c,f77,f90) from sources N�f90�f77)rr�r��fortran_ext_match)�sources�languagerrrrr1s
 156  ��r1cC�|D]	}t|�rdSqdS)z.Return True if sources contains Fortran files TF)r�rrrrrr r	r cCr)z*Return True if sources contains C++ files TF)�
cxx_ext_matchrrrrr!r	r!cCspg}g}g}g}|D]'}t|�r"t|�}|r|�|�q
 157  |�|�q
 158  t|�r,|�|�q
 159  |�|�q
 160  ||||fS)ztReturn four lists of filenames containing
 161      C, C++, Fortran, and Fortran 90 module sources,
 162      respectively.
 163      )rrr�r)r�	c_sources�cxx_sources�	f_sources�fmodule_sourcesrr�rrrr"sr"cCs.g}|D]}ttj�|d��}|�|�q|S)Nz*.h)r�rOrkrlr�)�directory_list�headersr
 164  �headrrr�_get_headers5s
 165  rcCsDg}|D]}tj�|�}|ddkr|d|vr|�|d�q|S)Nrrm)rOrkrjr�)Zlist_of_sourcesZdirecsrr
 166  rrr�_get_directories=s�rcCs6d}|d�|�7}|d�|�7}|d�|�d7}|S)zb
 167      Return commandline representation used to determine if a file needs
 168      to be recompiled
 169      z
commandline: r_�
 170  �rl)�cc_args�extra_postargs�pp_opts�cmdlinerrr�_commandline_dep_stringFs
 171  r#cCstt|��Sr)rr)rrrrr#Rsr#cCs�t|�sdStj�|�}tj�t��|g�}|t|�d��tj�}|r.|ds.|dd�}|r8|ddkr8dStj�	|�}tj�
 172  |�S)z1Return true if directory is local directory.
 173      FNrrnrE)r.rOrkrp�commonprefix�getcwdrNrjrqrl�isdir)�	directoryZabs_dir�c�new_dirrrrr$Vsr$c#sx�dddd��t�d�}tj|dd�D]&\}}}�fdd�|D�}||dd�<|D]}|�|�s8tj�||�Vq)qdS)Nrn��CVS�.svnrE�(?:[~#]|\.py[co]|\.o)$T��topdownc�g|]}|�vr|�qSrr�rJr
 174  ��pruned_directoriesrrr�i�z(general_source_files.<locals>.<listcomp>)�re�compilerO�walk�searchrkrl)�top_path�prune_file_pat�dirpath�dirnames�	filenames�prunedrrr2r�general_source_fileses�
 175  
 176  ���r?c
 177  #s��gd��t�d��tj|dd�D]K\}}}�fdd�|D�}||dd�<|D]4}tj�||��t�|�}g}t���D]}tj��|�}	tj�|	�rU��	|	�sU|�
 178  |	�q<||fVq'q|�t�|�}��fdd�t���D�}d	d�|D�}||fVdS)
 179  zJReturn a directory name relative to top_path and
 180      files contained.
 181      r*r-Tr.cr0rrr1r2rrr�vr4z4general_source_directories_files.<locals>.<listcomp>Ncs$g|]}��|�stj��|��qSr)r8rOrkrl�rJr)�dpathr:rrr��s�cS�g|]
 182  }tj�|�r|�qSr)rOrk�isfiler@rrrr���)r5r6rOr7rkrlrv�listdirrCr8r�)
 183  r9r;r<r=r>r
 184  �rpath�filesrr�r)rAr:r3r� general_source_directories_filesos,�
 185  
 186  
 187  ��	
 188  rHcCsng}dd�|jD�}|�|�|�t|��|jD]}t|�r)|�tt|���qtj�	|�r4|�
 189  |�q|S)NcS�g|]}t|�r|�qSrr�rJ�_mrrrr��r4z(get_ext_source_files.<locals>.<listcomp>)rr�r#�dependsr$rcr?rOrkrCr�)�extr=rr
 190  rrrr%�s
 191  
 192  
 193  �r%cCsdd�|D�}|S)NcSrIrrrJrrrr��r4z$get_script_files.<locals>.<listcomp>r)�scriptsrrrr&�sr&cCs�g}|d�dg�}dd�|D�}|�|�|�t|��|d�dg�}|D]}t|�r7|�tt|���q'tj�|�rB|�	|�q'|S)NrnrcSrIrrrJrrrr��r4z(get_lib_source_files.<locals>.<listcomp>rL)
 194  rVr�r#r$rcr?rOrkrCr�)�libr=rrLr
 195  rrrr'�s
 196  
 197  �r'cCs�tj��}|�dd�}|sAtj�d�stj�d�rd}|Stj�d�r'd}|Stj�d�r1d	}|Sd
 198  |vrA|�d|�d
 199  �dd�}|S)
a�Return the correct file extension for shared libraries.
 200  
 201      Parameters
 202      ----------
 203      is_python_ext : bool, optional
 204          Whether the shared library is a Python extension.  Default is False.
 205  
 206      Returns
 207      -------
 208      so_ext : str
 209          The shared library extension.
 210  
 211      Notes
 212      -----
 213      For Python shared libs, `so_ext` will typically be '.so' on Linux and OS X,
 214      and '.pyd' on Windows.  For Python >= 3.2 `so_ext` has a tag prepended on
 215      POSIX systems according to PEP 3149.
 216  
 217 218  EXT_SUFFIXrm�linux�gnukfreebsdz.so�darwinz.dylib�winz.dll�SOABIrxrn)�	distutils�	sysconfig�get_config_varsrVrr�r�r�)�
is_python_extZconfvars�so_extrrr�get_shared_lib_extension�s"
 219  
 220  ��
 221  ��r[cCs�t|�r|gS|d}g}|D]1}t|d�rqt|�r%|�tt|���qt|�r;tj�|�r5|�	|�qt
 222  d|�qtt|���|S)Nrn�__call__zNot existing data file:)
r.r�r$r�rcr?rOrkrCr�r��	TypeErrorrr)�datarr=r�rrrr(�s
 223  r(cGsd�dd�|D��S)NrxcSsg|]}|r|�qSrr)rJrgrrrr��r�zdot_join.<locals>.<listcomp>r)rerrrr)�sr)cCsNzt�|d�WSty&t��dj}t|d�D]}|j}q|YSw)z:Return frame object from call stack with given level.
 224      rnr\)r�	_getframerP�exc_info�tb_framerd�f_back)�levelr��_rrrr*�s�r*c@s�eZdZgd�ZddgZddgZgZ						dXd	d
 225  �Zdd�Zd
d�Z	dd�Z
 226  dd�Zdd�Z	dYdd�Z
	dYdd�Z			dZdd�Z		d[dd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd\d4d5�Zd\d6d7�Zd8d9�Zd:d;�Zd<d=�Z d>d?�Z!d@dA�Z"dBdC�Z#dDdE�Z$dFdG�Z%dHdI�Z&dJdK�Z'd]dLdM�Z(d^dOdP�Z)d^dQdR�Z*d_dTdU�Z+dVdW�Z,dS)`r)
 227  �packages�ext_modules�
 228  data_files�include_dirs�	librariesrrN�
 229  py_modules�installed_libraries�
define_macros�package_dir�installed_pkg_configr9r�Nrn�setup.pyc	Ks|t||�|_d|_t|�}t||�|_|dur|j}d|_|dur%|j}ntj�t	|j|��r5t	|j|�}tj�|p;d�sDt
 230  d|f��||_||_tjj
|j�d��|_|jdd�|_|jdd�|_|jD]}	t�|�|	g��}
 231  t||	t|
 232  ��qh|jD]}	t�|�|	i��}
 233  t||	|
 234  �q|j|j}|jdd�|_|��D]/}	|	|vr�q�||	}t||	|�t|t�r�|j�|	�q�t|t�r�|j�|	�q�|j�|	�q�tj�t	|d��r�|j �|j�||j!|j<tddddd�|_"d}
t#dd	�D])}zt|�}Wnt
 235  �yYnwzt$d
 236  |j%|j&�}
Wn
 237  t'�y"Yq�wt|
|j(��r9|
j"d�r9|j)di|
j"��||_*dS)
a�Construct configuration instance of a package.
 238  
 239          package_name -- name of the package
 240                          Ex.: 'distutils'
 241          parent_name  -- name of the parent package
 242                          Ex.: 'numpy'
 243          top_path     -- directory of the toplevel package
 244                          Ex.: the directory where the numpy package source sits
 245          package_path -- directory of package. Will be computed by magic from the
 246                          directory of the caller module if not specified
 247                          Ex.: the directory where numpy.distutils is
 248          caller_level -- frame level to caller namespace, internal parameter.
 249          Nrmrxz%r is not a directory�__init__.pyF)�ignore_setup_xxx_py�assume_default_configuration�delegate_options_to_subpackages�quietrnr�r<rsr)+r)r9r�r*r�r�rOrkr&r,r�r9�package_pathrlrj�path_in_package�
 250  _list_keys�	list_keys�
 251  _dict_keys�	dict_keys�copyrV�setattrr/�_extra_keys�
 252  extra_keys�keysrrcr��dictr�rerm�optionsrdryrzr{r}�	__class__�set_options�
 253  setup_name)r<�package_name�parent_namer9ru�caller_levelr��attrs�caller_framer��v�
 254  known_keysrgZcaller_instancerfrrrrr=s|
 255  
 256  
 257  
 258  ���
 259  zConfiguration.__init__cCsB|��i}|j|j|j}|D]
}t||�}|r|||<q|S)z�
 260          Return a dictionary compatible with the keyword arguments of distutils
 261          setup function.
 262  
 263          Examples
 264          --------
 265          >>> setup(**config.todict())                           #doctest: +SKIP
 266          )�_optimize_data_filesrxrzr~rW)r<r
 267  r�r�rgrrr�todictbs
 268  
 269  �zConfiguration.todictcCs|jdst|�dSdS)Nrt)r�r��r<�messagerrr�infous
 270  �zConfiguration.infocCstj�d|f�dS)NzWarning: %s
 271  )r�stderr�writer�rrrrayszConfiguration.warncKs6|��D]\}}||jvr||j|<qtd|��dS)z�
 272          Configure Configuration instance.
 273  
 274          The following options are available:
 275           - ignore_setup_xxx_py
 276           - assume_default_configuration
 277           - delegate_options_to_subpackages
 278           - quiet
 279  
 280          zUnknown option: N)�itemsr�r�)r<r��keyr�rrrr�|s
 281  
 282  �zConfiguration.set_optionscCsddlm}|�S)z2Return the distutils distribution object for self.rrB)rMrC)r<rCrrrrC�szConfiguration.get_distributioncCs�|�d�}t|jg|�}dd�t|�D�}g}|D]4}tj�t|d��s&qd|�tj�vr/qd�|�tj�t	|�d��}	|j
 283  |	||dd�}
 284  |�|
 285  �q|S)NrxcSrBr)rOrkr&rJrrrr��rDz:Configuration._wildcard_get_subpackage.<locals>.<listcomp>rprErn�r�r�)rjr,r�r�rOrkrCrqrlrN�get_subpackager�)r<�subpackage_namer�r�r��subpackage_pathr��config_listr
 286  r�r(rrr�_wildcard_get_subpackage�s 
 287   �z&Configuration._wildcard_get_subpackagecCs&tj�dtj�|��z�tj�tj�|��d}t|j||�}t	d�
 288  |�d��|�}t|d�sH|j
ds;|�d|�t|||j||dd�}	n#t|g|�d�dd	��}
 289  |
 290  f}|jjjdkrf||jf}|j|�}	|	jt||�kr�|�d
 291  t||�|	jf�Wtjd=|	SWtjd=|	Stjd=w)Nrrdrx�
configurationrrzCAssuming default configuration (%s does not define configuration())rn�r�r�z*Subpackage %r configuration returned as %r)rrk�insertrOr|�splitext�basenamer)r9r7rlrjr�r�rarr9r��__code__�co_argcount)r<�setup_pyr�r�r�r�r�r��setup_module�configZpnrerrr� _get_configuration_from_setup_py�s>�
 292  
 293  ��
 294  ��
 295  �z.Configuration._get_configuration_from_setup_pycCsL|dur|durtd��tj�|�}|�d�}|dur)d|vr)|j|||dd�Sd|vs6Jt|||f���|durCt|jg|�}nt|g|dd��}|�	|g�d}t||j
 296  �}|jd	sntj�|�snt|d
 297  |�}tj�|�s�|jds�|�
dtj�|�|f�t|||j||dd�}n|j|||||dd�}|r�|gSgS)
aReturn list of subpackage configurations.
 298  
 299          Parameters
 300          ----------
 301          subpackage_name : str or None
 302              Name of the subpackage to get the configuration. '*' in
 303              subpackage_name is handled as a wildcard.
 304          subpackage_path : str
 305              If None, then the path is assumed to be the local path plus the
 306              subpackage_name. If a setup.py file is not found in the
 307              subpackage_path, then a default configuration is used.
 308          parent_name : str
 309              Parent name.
 310          Nz;either subpackage_name or subpackage_path must be specifiedrxr�rnr�r�rrqzsetup_%s.pyrrzEAssuming default configuration (%s/{setup_%s,setup}.py was not found))r�rOrkr�rjr�rrr,r�r�r�r�rCrar|rr9r�)r<r�r�r�r�r�r�r�rrrr��sT�
 311  �
 312  �
 313  ���zConfiguration.get_subpackageFc	Cs�|rd}n|j}|j|||dd�}|s|�d�|D]/}|}t|t�r'|��}t|t�s4Jtt|����|�	d|�
 314  d�|jf�|jdi|��q|��}|dur[|�d|�dSdS)	aAdd a sub-package to the current Configuration instance.
 315  
 316          This is useful in a setup.py script for adding sub-packages to a
 317          package.
 318  
 319          Parameters
 320          ----------
 321          subpackage_name : str
 322              name of the subpackage
 323          subpackage_path : str
 324              if given, the subpackage path such as the subpackage is in
 325              subpackage_path / subpackage_name. If None,the subpackage is
 326              assumed to be located in the local path / subpackage_name.
 327          standalone : bool
 328          Nr\r�z0No configuration returned, assuming unavailable.z Appending %s configuration to %sr9zTdistutils distribution has been initialized, it may be too late to add a subpackage r)
r9r�rarrr�r�rrr�r�rVrrC)	r<r�r��
 329  standaloner�r�r�r
 330  r[rrr�add_subpackages0�
 331  
 332  �
 333  ��zConfiguration.add_subpackagec
 334  s�t|�r	|\�}nd�t|�r��fdd�|D�dSt|�s&td|f���durBtj�|�r;��tj�|�|f�S��||f�S�j|dd�}t	|��rt	��r�t
 335  ���tj�}|�
�ttt|�d��}|�
�|D]	}||sw||=qn|D]|}tj�|�s�td|�qzt|�j�}|�tj�}|�
�g}	d	}|D]9}
 336  t	|
 337  �r�|t|�kr�td
 338  �|f��|	�||�n|
 339  ||ks�Jt|
 340  |||�||f���|	�|
 341  �|d7}q�||d�r��d||f�|	�
���tj�|	�|f�qzdS|D]	}���|f�q�dSt	���rJt�������}|du�r%|jdu�r%|j}n�j}|D]}tt|��D]\}
}tj��j�|
�}|�||f��q2�q*dS)a�Recursively add files under data_path to data_files list.
 342  
 343          Recursively add files under data_path to the list of data_files to be
 344          installed (and distributed). The data_path can be either a relative
 345          path-name, or an absolute path-name, or a 2-tuple where the first
 346          argument shows where in the install directory the data directory
 347          should be installed to.
 348  
 349          Parameters
 350          ----------
 351          data_path : seq or str
 352              Argument can be either
 353  
 354                  * 2-sequence (<datadir suffix>, <path to data directory>)
 355                  * path to data directory where python datadir suffix defaults
 356                    to package dir.
 357  
 358          Notes
 359          -----
 360          Rules for installation paths::
 361  
 362              foo/bar -> (foo/bar, foo/bar) -> parent/foo/bar
 363              (gun, foo/bar) -> parent/gun
 364              foo/* -> (foo/a, foo/a), (foo/b, foo/b) -> parent/foo/a, parent/foo/b
 365              (gun, foo/*) -> (gun, foo/a), (gun, foo/b) -> gun
 366              (gun/*, foo/*) -> parent/gun/a, parent/gun/b
 367              /foo/bar -> (bar, /foo/bar) -> parent/bar
 368              (gun, /foo/bar) -> parent/gun
 369              (fun/*/gun/*, sun/foo/bar) -> parent/fun/foo/gun/bar
 370  
 371          Examples
 372          --------
 373          For example suppose the source directory contains fun/foo.dat and
 374          fun/bar/car.dat:
 375  
 376          >>> self.add_data_dir('fun')                       #doctest: +SKIP
 377          >>> self.add_data_dir(('sun', 'fun'))              #doctest: +SKIP
 378          >>> self.add_data_dir(('gun', '/full/path/to/fun'))#doctest: +SKIP
 379  
 380          Will install data-files to the locations::
 381  
 382              <package install directory>/
 383                fun/
 384                  foo.dat
 385                  bar/
 386                    car.dat
 387                sun/
 388                  foo.dat
 389                  bar/
 390                    car.dat
 391                gun/
 392                  foo.dat
 393                  car.dat
 394  
 395          Ncsg|]	}���|f��qSr)�add_data_dirr��r
 396  r<rrr�ksz.Configuration.add_data_dir.<locals>.<listcomp>znot a string: %rF�r�rnzNot a directory, skippingrzcannot fill pattern %r with %rz,mismatch of pattern_list=%s and path_list=%s)r-r.r]rOrk�isabsr�r�r�rrrjrq�reversercrdrNr&r�rvr�r�r�rrrarlrCrgrHrv)r<�	data_pathr��pattern_list�rlrfrkrF�	path_list�target_listr�r[rg�d1r�target_pathrr�rr�.s|8
 397  
 398  �
 399  �(
 400  
 401  ����zConfiguration.add_data_dircCs^i}|jD]\}}||vrt�||<|D]	}||�|�qqdd�|��D�|jdd�<dS)NcSsg|]
 402  \}}|t|�f�qSr)rc)rJr�rGrrrr��rDz6Configuration._optimize_data_files.<locals>.<listcomp>)rg�set�addr�)r<�	data_dictr�rGrrrrr��s
 403  � z"Configuration._optimize_data_filescGst|�dkr|D]}|�|�qdSt|�dksJ�t|d�r'|d\}}nd}t|�r0|}n%t|�rMt|�dkr?|d}n|D]	}|�||f�qAdSttt|����|duryt|d�rad}ntj	�
 404  |�rjd}ntj	�|�}|�||f�dS|j|dd�}t
|�r�t
|�r�|�tj�}|��|D]=}|�tj�}|��|��g}	d}
 405  |D]}t
|�r�|	�||
 406  �|
 407  d7}
 408  q�|	�|�q�|	��|�tj�|	�|f�q�dS|�||f�dSt
|�r�Jt||f���|��}|dur�|jdur�|j}
n|j}
|
�tj	�|j|�|f�dS)a�Add data files to configuration data_files.
 409  
 410          Parameters
 411          ----------
 412          files : sequence
 413              Argument(s) can be either
 414  
 415                  * 2-sequence (<datadir prefix>,<path to data file(s)>)
 416                  * paths to data files where python datadir prefix defaults
 417                    to package dir.
 418  
 419          Notes
 420          -----
 421          The form of each element of the files sequence is very flexible
 422          allowing many combinations of where to get the files from the package
 423          and where they should ultimately be installed on the system. The most
 424          basic usage is for an element of the files argument sequence to be a
 425          simple filename. This will cause that file from the local path to be
 426          installed to the installation path of the self.name package (package
 427          path). The file argument can also be a relative path in which case the
 428          entire relative path will be installed into the package directory.
 429          Finally, the file can be an absolute path name in which case the file
 430          will be found at the absolute path name but installed to the package
 431          path.
 432  
 433          This basic behavior can be augmented by passing a 2-tuple in as the
 434          file argument. The first element of the tuple should specify the
 435          relative path (under the package install directory) where the
 436          remaining sequence of files should be installed to (it has nothing to
 437          do with the file-names in the source distribution). The second element
 438          of the tuple is the sequence of files that should be installed. The
 439          files in this sequence can be filenames, relative paths, or absolute
 440          paths. For absolute paths the file will be installed in the top-level
 441          package installation directory (regardless of the first argument).
 442          Filenames and relative path names will be installed in the package
 443          install directory under the path name given as the first element of
 444          the tuple.
 445  
 446          Rules for installation paths:
 447  
 448            #. file.txt -> (., file.txt)-> parent/file.txt
 449            #. foo/file.txt -> (foo, foo/file.txt) -> parent/foo/file.txt
 450            #. /foo/bar/file.txt -> (., /foo/bar/file.txt) -> parent/file.txt
 451            #. ``*``.txt -> parent/a.txt, parent/b.txt
 452            #. foo/``*``.txt`` -> parent/foo/a.txt, parent/foo/b.txt
 453            #. ``*/*.txt`` -> (``*``, ``*``/``*``.txt) -> parent/c/a.txt, parent/d/b.txt
 454            #. (sun, file.txt) -> parent/sun/file.txt
 455            #. (sun, bar/file.txt) -> parent/sun/file.txt
 456            #. (sun, /foo/bar/file.txt) -> parent/sun/file.txt
 457            #. (sun, ``*``.txt) -> parent/sun/a.txt, parent/sun/b.txt
 458            #. (sun, bar/``*``.txt) -> parent/sun/a.txt, parent/sun/b.txt
 459            #. (sun/``*``, ``*``/``*``.txt) -> parent/sun/c/a.txt, parent/d/b.txt
 460  
 461          An additional feature is that the path to a data-file can actually be
 462          a function that takes no arguments and returns the actual path(s) to
 463          the data-files. This is useful when the data files are generated while
 464          building the package.
 465  
 466          Examples
 467          --------
 468          Add files to the list of data_files to be included with the package.
 469  
 470              >>> self.add_data_files('foo.dat',
 471              ...     ('fun', ['gun.dat', 'nun/pun.dat', '/tmp/sun.dat']),
 472              ...     'bar/cat.dat',
 473              ...     '/full/path/to/can.dat')                   #doctest: +SKIP
 474  
 475          will install these data files to::
 476  
 477              <package install directory>/
 478               foo.dat
 479               fun/
 480                 gun.dat
 481                 nun/
 482                   pun.dat
 483               sun.dat
 484               bar/
 485                 car.dat
 486               can.dat
 487  
 488          where <package install directory> is the package (or sub-package)
 489          directory such as '/usr/lib/python2.4/site-packages/mypackage' ('C:
 490          \Python2.4 \Lib \site-packages \mypackage') or
 491          '/usr/lib/python2.4/site- packages/mypackage/mysubpackage' ('C:
 492          \Python2.4 \Lib \site-packages \mypackage \mysubpackage').
 493          rnNrr\rmFr�)rN�add_data_filesr-r.r]rrr�r�rOrkr�r|r�rrjrqr��popr�rlrCrgrv)r<rGrr
 494  Zfilepatr�r�rkr�r�rfr�r[rgrrrr��shX
 495  
 496  
 497  �zConfiguration.add_data_filescCs@|��}|durt|d�sg|_|j�|�dS|j�|�dS)z�Add define macros to configuration
 498  
 499          Add the given sequence of macro name and value duples to the beginning
 500          of the define_macros list This list will be visible to all extension
 501          modules of the current package.
 502          Nrl)rCr�rlr�)r<�macrosr[rrr�add_define_macrosIs
 503  zConfiguration.add_define_macroscG�J|�|�}|��}|dur|jdurg|_|j�|�dS|j�|�dS)z�Add paths to configuration include directories.
 504  
 505          Add the given sequence of paths to the beginning of the include_dirs
 506          list. This list will be visible to all extension modules of the
 507          current package.
 508          N)r�rCrhr�)r<r�rhr[rrr�add_include_dirsY�
 509  
 510  zConfiguration.add_include_dirscs�g�|D]6�t��r��fdd�����D�qt�ttf�r%t��dkr+tt������fdd����d�D�q���}|durS|j	durKg|_	|j	�
 511  ��dS�j	�
 512  ��dS)a�Add installable headers to configuration.
 513  
 514          Add the given sequence of files to the beginning of the headers list.
 515          By default, headers will be installed under <python-
 516          include>/<self.name.replace('.','/')>/ directory. If an item of files
 517          is a tuple, then its first argument specifies the actual installation
 518          location relative to the <python-include> path.
 519  
 520          Parameters
 521          ----------
 522          files : str or seq
 523              Argument(s) can be either:
 524  
 525                  * 2-sequence (<includedir suffix>,<path to header file(s)>)
 526                  * path(s) to header file(s) where python includedir suffix will
 527                    default to package name.
 528          csg|]
 529  }���j|f��qSr)r�r9r�)rr<rrr�~rDz-Configuration.add_headers.<locals>.<listcomp>r\csg|]}���d|f��qS�r)r�r�)rrkrrr��srnN)r.r�r�tuplercrNr]rrrCrr�)r<rGr[r)rrkr<r�add_headersis 
 530  zConfiguration.add_headerscOs|�dd�}t||j|d�S)a�Apply glob to paths and prepend local_path if needed.
 531  
 532          Applies glob.glob(...) to each path in the sequence (if needed) and
 533          pre-pends the local_path if needed. Because this is called on all
 534          source lists, this allows wildcard characters to be specified in lists
 535          of sources for extension modules and libraries and scripts and allows
 536          path-names be relative to the source directory.
 537  
 538          r�T)r�r�)rVr0r�)r<r��kwsr�rrrr��s
 539  
 540  �zConfiguration.pathscCs4|��D]}||}|dvr|�|�}|||<qdS)N)rrLrh�library_dirs�module_dirs�
extra_objects)rr�)r<�kw�kr��new_vrrr�_fix_paths_dict�s
 541  ��zConfiguration._fix_paths_dictcKs�t�|�}t|j|�|d<||d<d|vr<|d}|d=t|t�r$|g}|D]}t|t�s3Jt|���t|fi|��q&|�|�|�dg�}g}g|d<|D]k}	t|	t	�r]|�|	d�d|	vr�|	�
 542  dd�\}
 543  }tj�
t|j|��}tj�|�r�|jd|dd	�}t|t�r�|��}d
 544  d�|�dg�D�D]}
|
�
 545  dd�d
}||
 546  kr�|�dd�t|fi|��nq�qO|�|	�qO||d|d<|j|�dg�|d<d
dlm}|di|��}|j�|�|��}|dur�|�d|�|S)a�Add extension to configuration.
 547  
 548          Create and add an Extension instance to the ext_modules list. This
 549          method also takes the following optional keyword arguments that are
 550          passed on to the Extension constructor.
 551  
 552          Parameters
 553          ----------
 554          name : str
 555              name of the extension
 556          sources : seq
 557              list of the sources. The list of sources may contain functions
 558              (called source generators) which must take an extension instance
 559              and a build directory as inputs and return a source file or list of
 560              source files or None. If None is returned then no sources are
 561              generated. If the Extension instance has no sources after
 562              processing all source generators, then no extension module is
 563              built.
 564          include_dirs :
 565          define_macros :
 566          undef_macros :
 567          library_dirs :
 568          libraries :
 569          runtime_library_dirs :
 570          extra_objects :
 571          extra_compile_args :
 572          extra_link_args :
 573          extra_f77_compile_args :
 574          extra_f90_compile_args :
 575          export_symbols :
 576          swig_opts :
 577          depends :
 578              The depends list contains paths to files or directories that the
 579              sources of the extension module depend on. If any path in the
 580              depends list is newer than the extension module, then the module
 581              will be rebuilt.
 582          language :
 583          f2py_options :
 584          module_dirs :
 585          extra_info : dict or list
 586              dict or list of dict of keywords to be appended to keywords.
 587  
 588          Notes
 589          -----
 590          The self.paths(...) method is applied to all lists that may contain
 591          paths.
 592          r9r�
 593  extra_inforirn�@Nr\r�cSsg|]}|d�qSr�r)rJr�rrrr��r�z/Configuration.add_extension.<locals>.<listcomp>Z__OF__rrl��	ExtensionzTdistutils distribution has been initialized, it may be too late to add an extension r)r{r)r9rr�rrrr�rVr�rjrOrkrpr,r�r&r�rr�r�r�rlrMr�rfrCra)r<r9rr��ext_argsr�r�ri�libnames�libname�lnameZlpathr(r�Zllnamer�rMr[rrr�
add_extension�s`
 594  0
 595  
 596  
 597  �
 598  ���zConfiguration.add_extensioncKs6|�||d|�|��}|dur|�d|�dSdS)a�
 599          Add library to configuration.
 600  
 601          Parameters
 602          ----------
 603          name : str
 604              Name of the extension.
 605          sources : sequence
 606              List of the sources. The list of sources may contain functions
 607              (called source generators) which must take an extension instance
 608              and a build directory as inputs and return a source file or list of
 609              source files or None. If None is returned then no sources are
 610              generated. If the Extension instance has no sources after
 611              processing all source generators, then no extension module is
 612              built.
 613          build_info : dict, optional
 614              The following keys are allowed:
 615  
 616                  * depends
 617                  * macros
 618                  * include_dirs
 619                  * extra_compiler_args
 620                  * extra_f77_compile_args
 621                  * extra_f90_compile_args
 622                  * f2py_options
 623                  * language
 624  
 625          NzQdistutils distribution has been initialized, it may be too late to add a library )�_add_libraryrCra)r<r9rr:r[rrr�add_library	s
 626  ��zConfiguration.add_librarycCs@t�|�}||d<d|vrg|d<|�|�|j�||f�dS)z\Common implementation for add_library and add_installed_library. Do
 627          not use directlyrrLN)r{r�rir��r<r9r�install_dirr:rrrr�-s
 628  
 629  zConfiguration._add_librarycCs@|si}tj�|j|�}|�||||�|j�t|||��dS)aQ
 630          Similar to add_library, but the specified library is installed.
 631  
 632          Most C libraries used with `distutils` are only used to build python
 633          extensions, but libraries built through this method will be installed
 634          so that they can be reused by third-party packages.
 635  
 636          Parameters
 637          ----------
 638          name : str
 639              Name of the installed library.
 640          sources : sequence
 641              List of the library's source files. See `add_library` for details.
 642          install_dir : str
 643              Path to install the library, relative to the current sub-package.
 644          build_info : dict, optional
 645              The following keys are allowed:
 646  
 647                  * depends
 648                  * macros
 649                  * include_dirs
 650                  * extra_compiler_args
 651                  * extra_f77_compile_args
 652                  * extra_f90_compile_args
 653                  * f2py_options
 654                  * language
 655  
 656          Returns
 657          -------
 658          None
 659  
 660          See Also
 661          --------
 662          add_library, add_npy_pkg_config, get_info
 663  
 664          Notes
 665          -----
 666          The best way to encode the options required to link against the specified
 667          C libraries is to use a "libname.ini" file, and use `get_info` to
 668          retrieve the required options (see `add_npy_pkg_config` for more
 669          information).
 670  
 671          N)rOrkrlrur�rkr�r8r�rrr�add_installed_library=s
 672  ,z#Configuration.add_installed_librarycCs\|duri}tj�|j|�}|j|jvr"|j|j�|||f�dS|||fg|j|j<dS)a 
 673          Generate and install a npy-pkg config file from a template.
 674  
 675          The config file generated from `template` is installed in the
 676          given install directory, using `subst_dict` for variable substitution.
 677  
 678          Parameters
 679          ----------
 680          template : str
 681              The path of the template, relatively to the current package path.
 682          install_dir : str
 683              Where to install the npy-pkg config file, relatively to the current
 684              package path.
 685          subst_dict : dict, optional
 686              If given, any string of the form ``@key@`` will be replaced by
 687              ``subst_dict[key]`` in the template file when installed. The install
 688              prefix is always available through the variable ``@prefix@``, since the
 689              install prefix is not easy to get reliably from setup.py.
 690  
 691          See also
 692          --------
 693          add_installed_library, get_info
 694  
 695          Notes
 696          -----
 697          This works for both standard installs and in-place builds, i.e. the
 698          ``@prefix@`` refer to the source directory for in-place builds.
 699  
 700          Examples
 701          --------
 702          ::
 703  
 704              config.add_npy_pkg_config('foo.ini.in', 'lib', {'foo': bar})
 705  
 706          Assuming the foo.ini.in file has the following content::
 707  
 708              [meta]
 709              Name=@foo@
 710              Version=1.0
 711              Description=dummy description
 712  
 713              [default]
 714              Cflags=-I@prefix@/include
 715              Libs=
 716  
 717          The generated file will have the following content::
 718  
 719              [meta]
 720              Name=bar
 721              Version=1.0
 722              Description=dummy description
 723  
 724              [default]
 725              Cflags=-Iprefix_dir/include
 726              Libs=
 727  
 728          and will be installed as foo.ini in the 'lib' subpath.
 729  
 730          When cross-compiling with numpy distutils, it might be necessary to
 731          use modified npy-pkg-config files.  Using the default/generated files
 732          will link with the host libraries (i.e. libnpymath.a).  For
 733          cross-compilation you of-course need to link with target libraries,
 734          while using the host Python installation.
 735  
 736          You can copy out the numpy/core/lib/npy-pkg-config directory, add a
 737          pkgdir value to the .ini files and set NPY_PKG_CONFIG_PATH environment
 738          variable to point to the directory with the modified npy-pkg-config
 739          files.
 740  
 741          Example npymath.ini modified for cross-compilation::
 742  
 743              [meta]
 744              Name=npymath
 745              Description=Portable, core math library implementing C99 standard
 746              Version=0.1
 747  
 748              [variables]
 749              pkgname=numpy.core
 750              pkgdir=/build/arm-linux-gnueabi/sysroot/usr/lib/python3.7/site-packages/numpy/core
 751              prefix=${pkgdir}
 752              libdir=${prefix}/lib
 753              includedir=${prefix}/include
 754  
 755              [default]
 756              Libs=-L${libdir} -lnpymath
 757              Cflags=-I${includedir}
 758              Requires=mlib
 759  
 760              [msvc]
 761              Libs=/LIBPATH:${libdir} npymath.lib
 762              Cflags=/INCLUDE:${includedir}
 763              Requires=mlib
 764  
 765          N)rOrkrlrur9rnr�)r<�templater��
 766  subst_dictrrr�add_npy_pkg_configps_
 767  ��z Configuration.add_npy_pkg_configcGr�)z�Add scripts to configuration.
 768  
 769          Add the sequence of files to the beginning of the scripts list.
 770          Scripts will be installed under the <prefix>/bin/ directory.
 771  
 772          N)r�rCrNr�)r<rGrNr[rrr�add_scripts�r�zConfiguration.add_scriptsc
 773  Ks|jD]}t||�}|�|�|g��q|jD]}t||�}|�|�|i��q|j|j|j}|��D]S}||vrit||d�}|rJ|||krJq5|�d||||�dd�f�t	||||�|j�
 774  |�q5||jvr~|�d|t||�||f�q5||vr�q5td|��dS)Nz"Inheriting attribute %r=%r from %rr9r�z*Ignoring attempt to set %r (from %r to %r)zDon't know about key=%r)
rxrWr�rVrz�updater~rrar|r�r�r�)r<r�r�rgr�rrrr�s0
 775  
 776  
 777  
 778  �
 779  ��zConfiguration.dict_appendcCsvddlm}|j|j|j}d}|d|jd7}|��|D]}t||d�}|r4|d|||�f7}q |d7}|S)Nr)�pformatz<-----
 780  zConfiguration of z:
 781  z%s = %s
 782  z----->)�pprintr�rxrzr~r9�sortrW)r<r�r�r�r�rgrrr�__str__s�zConfiguration.__str__cCsJtd�}|��d|_d|_tj�d�}|r#tj�d|g�}|tjd<|S)zF
 783          Returns the numpy.distutils config command instance.
 784          r�r�PATHrx)	r�ensure_finalized�dump_source�noisyrOrUrV�pathseprl)r<�cmd�old_pathrkrrr�get_config_cmds
 785  zConfiguration.get_config_cmdcCstd�}|��|jS)zh
 786          Return a path to a temporary directory where temporary files should be
 787          placed.
 788          rE)rr��
 789  build_temp)r<r�rrr�get_build_temp_dirsz Configuration.get_build_temp_dircC�d}|��}|j|dd�}|S)aSCheck for availability of Fortran 77 compiler.
 790  
 791          Use it inside source generating function to ensure that
 792          setup distribution instance has been initialized.
 793  
 794          Notes
 795          -----
 796          True if a Fortran 77 compiler is available (because a simple Fortran 77
 797          code was able to be compiled successfully).
 798          �/
 799          subroutine simple
 800          end
 801          r
��lang�r��try_compile�r<Zsimple_fortran_subroutine�
 802  config_cmd�flagrrr�	have_f77c(�zConfiguration.have_f77ccCr�)aRCheck for availability of Fortran 90 compiler.
 803  
 804          Use it inside source generating function to ensure that
 805          setup distribution instance has been initialized.
 806  
 807          Notes
 808          -----
 809          True if a Fortran 90 compiler is available (because a simple Fortran
 810          90 code was able to be compiled successfully)
 811          r�rr�r�r�rrr�	have_f90c;r�zConfiguration.have_f90ccCsht|�r|\}}t||j|jd�dSddlm}t||�s$Jt|���|j�|j�|j�|j�dS)zEAppend libraries, include_dirs to extension or library item.
 812          )rirhrr�N)	r-rrirhrMr�rrrr�)r<Zextlib�lib_namer:r�rrr�	append_toNs
 813  �zConfiguration.append_toc	Csz
 814  tjdg|d�}WntjtfyYnwt�d|�}|r&t|�d��Stj	dkr9t
 815  j�dd�r9t
|dd	�}nt
|d
 816  d	�}t
 817  j�|�r�t|��}|��}Wd�n1sXwY|dd�dkrvt�d
|�}|rtt|�d��SdSt�d|�}|r�t|�d��SdS)z+Return path's SVN revision number.
 818          Z
 819  svnversion��cwd�(?P<revision>\d+)�revisionr�ZSVN_ASP_DOT_NET_HACKNZ_svn�entriesr,r�z<?xmlzrevision="(?P<revision>\d+)"zdir[\n\r]+(?P<revision>\d+))r�r��CalledProcessErrorr	r5�matchrTrrr�rOrUrVr,rkrCr��readr8)r<rk�outputrr�rZfstrrrr�_get_svn_revision\s0�
 820  
 821  ��zConfiguration._get_svn_revisionc

 822  Cs8ztjgd�|d�}WntjtfyYnwt�d|�}|r't|�d��St|dd�}t|dd�}t	j
 823  �|�r�d}t|��}|�
���}Wd�n1sPwYi}	t|d	��1}|D]&}
 824  |
 825  ��dd
 826  �\}}||krq|}zt|�}Wn	ty�Yq_w||	|<q_Wd�n1s�wY|	�|�SdS)z1Return path's Mercurial revision number.
 827          )�hg�identifyz--numr�r�r�z.hg�branchzbranch.cacheNr�r\)r�r�r�r	r5r�rTrr,rOrkrCr�r�r�rjr�rV)
r<rkrrZ	branch_fnZbranch_cache_fnZbranch0rZ	revision0Z
 828  branch_mapr�Zbranch1Z	revision1rrr�_get_hg_revisionysB
 829  ��
 830  ��
 831  ��
 832  zConfiguration._get_hg_revisioncCs�t|dd�}|dur|S|dur d|j�d�ddddd	g}n|g}|dur5dd
 833  |j�d�ddg}n|g}|D]y}t|j|�}tj�|�r�d}tj�tj�	|��d
}	t
 834  |j|	�}
 835  z
td�|
 836  �d��|�}Wnt
y�}z|�t|��d}WYd}~nd}~ww|dur�q:|D]}
t||
d�}|dur�nq�z|��d}Wn	ty�Ynw|dur�nq:|dur�||_|S|�|j�}|dur�|�|j�}|dur�t|�}||_|S)a�Try to get version string of a package.
 837  
 838          Return a version string of the current package or None if the version
 839          information could not be detected.
 840  
 841          Notes
 842          -----
 843          This method scans files named
 844          __version__.py, <packagename>_version.py, version.py, and
 845          __svn_version__.py for string variables version, __version__, and
 846          <packagename>_version, until a version number is found.
 847          r�Nz__version__.pyrxr�z_version.pyz
 848  version.py�__svn_version__.py�__hg_version__.py�__version__�_version)z.py�Urnrrd)rWr9rjr,r�rOrkrCr�r�r)r7rl�ImportErrorrar��get_versionsrPr�rr)r<Zversion_fileZversion_variabler�rGZversion_varsrr�r�r9r��version_module�ergr�rrr�get_version�sr
��������zConfiguration.get_versionTc�Vt�jd�����j��tj���s�durdS����fdd�}��d|�f�dS)aAppends a data function to the data_files list that will generate
 849          __svn_version__.py file to the current package directory.
 850  
 851          Generate package __svn_version__.py file from SVN revision number,
 852          it will be removed after python exits but will be available
 853          when sdist, etc commands are executed.
 854  
 855          Notes
 856          -----
 857          If __svn_version__.py existed before, nothing is done.
 858  
 859          This is
 860          intended for working with source directories that are in an SVN
 861          repository.
 862          rNc�tj���s/t��}��d�|f�t�d��}|�d|�Wd�n1s*wY��jf�fdd�	}t�|��S)N�Creating %s (version=%r)r��
version = %r
 863  c�p�r6z
t�|�|d|�Wn	tyYnwzt�|d�|d|d�WdSty5YdSwdS�Nzremoved r(�rO�remover	�rr���deleterr�rm_file�&�zSConfiguration.make_svn_version_py.<locals>.generate_svn_version_py.<locals>.rm_file�	rOrkrCr�r�r�r��atexit�register�r�rr�rr�r<�targetrr�generate_svn_version_py��
 864  zBConfiguration.make_svn_version_py.<locals>.generate_svn_version_pyrm)r,r�rrOrkrCr�)r<rr#rr!r�make_svn_version_py�sz!Configuration.make_svn_version_pycr)aAppends a data function to the data_files list that will generate
 865          __hg_version__.py file to the current package directory.
 866  
 867          Generate package __hg_version__.py file from Mercurial revision,
 868          it will be removed after python exits but will be available
 869          when sdist, etc commands are executed.
 870  
 871          Notes
 872          -----
 873          If __hg_version__.py existed before, nothing is done.
 874  
 875          This is intended for working with source directories that are
 876          in an Mercurial repository.
 877          rNcr)Nrr�rcrrrrrrrr/rzQConfiguration.make_hg_version_py.<locals>.generate_hg_version_py.<locals>.rm_filerr r!rr�generate_hg_version_py(r$z@Configuration.make_hg_version_py.<locals>.generate_hg_version_pyrm)r,r�rrOrkrCr�)r<rr&rr!r�make_hg_version_pysz Configuration.make_hg_version_py�
 878  __config__cCs|j�|j|tf�dS)z�Generate package __config__.py file containing system_info
 879          information used during building the package.
 880  
 881          This file is installed to the
 882          package installation directory.
 883  
 884          N)rjr�r9r)r<r9rrr�make_config_py<szConfiguration.make_config_pycGs6ddlm}m}i}|D]}||fi||���q|S)z�Get resources information.
 885  
 886          Return information (from system_info.get_info) for all of the names in
 887          the argument list in a single dictionary.
 888          rn)r3r)�system_infor3r)r<�namesr3r�	info_dictrgrrrr3Fs
 889  zConfiguration.get_info)NNNNrnro)rn)NNrn)NFr�NN)T)r()-r>r?r@rwryr}�numpy_include_dirsr=r�r�rar�rCr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr�r�r�r�r�r�rrrr%r'r)r3rrrrr�sr
 890  �a
 891  �
 892  �"
 893  �>
 894  �+y	"g$
 895  
 896  3k
	
 897  &
 898  L
 899  )
 900  (
 901  rcCsN||vr#ddl}|jj}|durddlm}|d��|�|�}|||<||S)Nr)�DistutilsInternalErrorz+setup distribution instance not initialized)�distutils.core�core�_setup_distribution�distutils.errorsr/rX)�cmdname�_cacherVr[r/r�rrrrSs�
 902  rcCs(tjdd�}|sddl}|��g}|S)Nr)rr.�numpy�get_include)rhr6rrrr_s
 903  
 904  rcCsDtj�d�}|dur|Stj�d�}tj�tj�|j	�ddd�}|S)a�Return the path where to find the npy-pkg-config directory.
 905  
 906      If the NPY_PKG_CONFIG_PATH environment variable is set, the value of that
 907      is returned.  Otherwise, a path inside the location of the numpy module is
 908      returned.
 909  
 910      The NPY_PKG_CONFIG_PATH can be useful when cross-compiling, maintaining
 911      customized npy-pkg-config .ini files for the cross-compilation
 912      environment, and using them when cross-compiling.
 913  
 914      �NPY_PKG_CONFIG_PATHNr6r1rOznpy-pkg-config)
 915  rOrUrV�	importlib�util�	find_specrkrlr|�origin)r
 916  �specrrr�get_npy_pkg_dirhs�r>cCs0ddlm}|r|�t��nt�g}|||�S)a�
 917      Return library info for the given package.
 918  
 919      Parameters
 920      ----------
 921      pkgname : str
 922          Name of the package (should match the name of the .ini file, without
 923          the extension, e.g. foo for the file foo.ini).
 924      dirs : sequence, optional
 925          If given, should be a sequence of additional directories where to look
 926          for npy-pkg-config files. Those directories are searched prior to the
 927          NumPy directory.
 928  
 929      Returns
 930      -------
 931      pkginfo : class instance
 932          The `LibraryInfo` instance containing the build information.
 933  
 934      Raises
 935      ------
 936      PkgNotFound
 937          If the package is not found.
 938  
 939      See Also
 940      --------
 941      Configuration.add_npy_pkg_config, Configuration.add_installed_library,
 942      get_info
 943  
 944      r)�read_config)�numpy.distutils.npy_pkg_configr?r�r>)�pkgnamer�r?rrrr4|s
 945  
 946  r4cCsfddlm}t||�}||���}||�����D]\}}||�|�q|d|d<|d=|d=|S)a9
 947      Return an info dict for a given C library.
 948  
 949      The info dict contains the necessary options to use the C library.
 950  
 951      Parameters
 952      ----------
 953      pkgname : str
 954          Name of the package (should match the name of the .ini file, without
 955          the extension, e.g. foo for the file foo.ini).
 956      dirs : sequence, optional
 957          If given, should be a sequence of additional directories where to look
 958          for npy-pkg-config files. Those directories are searched prior to the
 959          NumPy directory.
 960  
 961      Returns
 962      -------
 963      info : dict
 964          The dictionary with build information.
 965  
 966      Raises
 967      ------
 968      PkgNotFound
 969          If the package is not found.
 970  
 971      See Also
 972      --------
 973      Configuration.add_npy_pkg_config, Configuration.add_installed_library,
 974      get_pkg_info
 975  
 976      Examples
 977      --------
 978      To get the necessary information for the npymath library from NumPy:
 979  
 980      >>> npymath_info = np.distutils.misc_util.get_info('npymath')
 981      >>> npymath_info                                    #doctest: +SKIP
 982      {'define_macros': [], 'libraries': ['npymath'], 'library_dirs':
 983      ['.../numpy/core/lib'], 'include_dirs': ['.../numpy/core/include']}
 984  
 985      This info dict can then be used as input to a `Configuration` instance::
 986  
 987        config.add_extension('foo', sources=['foo.c'], extra_info=npymath_info)
 988  
 989      r)�parse_flagsr�rl�ignored)r@rBr4�cflags�libsr�r�)rAr�rB�pkg_infor�r�r�rrrr3�s-
 990  r3cCs*ddl}z|jWdStyYdSw)NrTF)�builtins�__NUMPY_SETUP__rP)rGrrr�is_bootstrapping�s�rIcCs:ddl}|jd||||||fdd�t|||�}|��S)zqReturn a configuration dictionary for usage in
 991      configuration() function defined in file setup_<name>.py.
 992      rNzXUse Configuration(%r,%r,top_path=%r) instead of deprecated default_config_dict(%r,%r,%r)r\r])r`rarr�)r9r�r�r`r(rrrr�s���rcKsR|��D]"\}}||vr"||}t|t�r|||<q||�|�q|||<qdSr)r�rr�r�)r
 993  r�r�r��ovrrrr�s
 994  
 995  
 996  �rcCs(tjjdkr|�dtjj�}|�dtjj�}d}tj�|�r�tj�|�d}tj�tj�|��d}tj�|�\}}tj�||g�}tj�|dt	|��|t	|�d��|ksltj�|dt	|��|t	|�d��|krrtj�
 997  |�}|t	|�d�}tj�|�r�|dd�}n|}tj�t|||��S)Nrirmrrn)
rOrkrqr�r��
 998  splitdriverpr$rlrNr|�normpathr,)r�rk�driveZ	absprefixZ	pathdriver
 999  �subpathrrrr	s$**�rcCs�ddlm}ddlm}|tj�|��t|d��D}|�dtj�	t
1000  jd��|�d�|�d�|�t�
d��|j��D]
\}}|�d	||f�q?|�t�
d
1001  ��Wd�|S1s`wY|S)z�Generate config.py file containing system_info information
1002      used during building the package.
1003  
1004      Usage:
1005          config['py_modules'].append((packagename, '__config__',generate_config_py))
1006      r)r*)�mkpathr�z'# This file is generated by numpy's %s
1007  zH# It contains system_info results at the time of building this package.
1008  z__all__ = ["get_info","show"]
1009  
1010  a
1011              import os
1012              import sys
1013  
1014              extra_dll_dir = os.path.join(os.path.dirname(__file__), '.libs')
1015  
1016              if sys.platform == 'win32' and os.path.isdir(extra_dll_dir):
1017                  os.add_dll_directory(extra_dll_dir)
1018  
1019              z%s=%r
1020  a}
1021              def get_info(name):
1022                  g = globals()
1023                  return g.get(name, g.get(name + "_info", {}))
1024  
1025              def show():
1026                  """
1027                  Show libraries in the system on which NumPy was built.
1028  
1029                  Print information about various resources (libraries, library
1030                  directories, include directories, etc.) in the system on which
1031                  NumPy was built.
1032  
1033                  See Also
1034                  --------
1035                  get_include : Returns the directory containing NumPy C
1036                                header files.
1037  
1038                  Notes
1039                  -----
1040                  1. Classes specifying the information to be printed are defined
1041                     in the `numpy.distutils.system_info` module.
1042  
1043                     Information may include:
1044  
1045                     * ``language``: language used to write the libraries (mostly
1046                       C or f77)
1047                     * ``libraries``: names of libraries found in the system
1048                     * ``library_dirs``: directories containing the libraries
1049                     * ``include_dirs``: directories containing library header files
1050                     * ``src_dirs``: directories containing library source files
1051                     * ``define_macros``: preprocessor macros used by
1052                       ``distutils.setup``
1053                     * ``baseline``: minimum CPU features required
1054                     * ``found``: dispatched features supported in the system
1055                     * ``not found``: dispatched features that are not supported
1056                       in the system
1057  
1058                  2. NumPy BLAS/LAPACK Installation Notes
1059  
1060                     Installing a numpy wheel (``pip install numpy`` or force it
1061                     via ``pip install numpy --only-binary :numpy: numpy``) includes
1062                     an OpenBLAS implementation of the BLAS and LAPACK linear algebra
1063                     APIs. In this case, ``library_dirs`` reports the original build
1064                     time configuration as compiled with gcc/gfortran; at run time
1065                     the OpenBLAS library is in
1066                     ``site-packages/numpy.libs/`` (linux), or
1067                     ``site-packages/numpy/.dylibs/`` (macOS), or
1068                     ``site-packages/numpy/.libs/`` (windows).
1069  
1070                     Installing numpy from source
1071                     (``pip install numpy --no-binary numpy``) searches for BLAS and
1072                     LAPACK dynamic link libraries at build time as influenced by
1073                     environment variables NPY_BLAS_LIBS, NPY_CBLAS_LIBS, and
1074                     NPY_LAPACK_LIBS; or NPY_BLAS_ORDER and NPY_LAPACK_ORDER;
1075                     or the optional file ``~/.numpy-site.cfg``.
1076                     NumPy remembers those locations and expects to load the same
1077                     libraries at run-time.
1078                     In NumPy 1.21+ on macOS, 'accelerate' (Apple's Accelerate BLAS
1079                     library) is in the default build-time search order after
1080                     'openblas'.
1081  
1082                  Examples
1083                  --------
1084                  >>> import numpy as np
1085                  >>> np.show_config()
1086                  blas_opt_info:
1087                      language = c
1088                      define_macros = [('HAVE_CBLAS', None)]
1089                      libraries = ['openblas', 'openblas']
1090                      library_dirs = ['/usr/local/lib']
1091                  """
1092                  from numpy.core._multiarray_umath import (
1093                      __cpu_features__, __cpu_baseline__, __cpu_dispatch__
1094                  )
1095                  for name,info_dict in globals().items():
1096                      if name[0] == "_" or type(info_dict) is not type({}): continue
1097                      print(name + ":")
1098                      if not info_dict:
1099                          print("  NOT AVAILABLE")
1100                      for k,v in info_dict.items():
1101                          v = str(v)
1102                          if k == "sources" and len(v) > 200:
1103                              v = v[:60] + " ...\n... " + v[-60:]
1104                          print("    %s = %s" % (k,v))
1105  
1106                  features_found, features_not_found = [], []
1107                  for feature in __cpu_dispatch__:
1108                      if __cpu_features__[feature]:
1109                          features_found.append(feature)
1110                      else:
1111                          features_not_found.append(feature)
1112  
1113                  print("Supported SIMD extensions in this NumPy install:")
1114                  print("    baseline = %s" % (','.join(__cpu_baseline__)))
1115                  print("    found = %s" % (','.join(features_found)))
1116                  print("    not found = %s" % (','.join(features_not_found)))
1117  
1118                      N)�numpy.distutils.system_infor*�distutils.dir_utilrOrOrkr|r�r�r�r�argv�textwrap�dedent�
saved_resultsr�)r"r*rOrr�rfrrrr	s
1119  
1120  
1121  �w�wrcCs|jdkstd|j��|jS)zdReturn version major and minor of compiler instance if it is
1122      MSVC, raise an exception otherwise.�msvcz"Compiler instance is not msvc (%s))�
compiler_typer��_MSVCCompiler__version)�compilerrrr�msvc_version�	s
1123  
1124  �rZcCsddlm}|�S)Nr�r2)�distutils.msvccompilerr2r[rrrr2�	sr2z%-Werror=implicit-function-declarationz-std=c99cCsdd�|D�S)z=
1125      Some flags are valid for C but not C++. Prune them.
1126      cSsg|]}|tvr|�qSr)�_cxx_ignore_flags)rJr�rrrr��	r4z&sanitize_cxx_flags.<locals>.<listcomp>r)Zcxxflagsrrrr6�	sr6cCs*tj�||�}tj�|�}|j�|�|S)z�
1127      Use importlib machinery to import a module `modname` from the file
1128      `modfile`. Depending on the `spec.loader`, the module may not be
1129      registered in sys.modules.
1130      )r9r:�spec_from_file_location�module_from_spec�loader�exec_module)�modnameZmodfiler=�foorrrr7�	sr7r)rmT)rmrmT)NNFr-)Fr�)NNN)frOr5rr{r�rr�r�rrQrS�importlib.utilr9�	threadingr�tlocal�	functoolsrrVr3rr�rr
r�__all__r8r5rhrrvr�r,rr+r�r�r0r�rr�r�r�r�rrrrrr�rrr�r�r�r6�Ir�rrr�r�rr.rr-rr/r1r r!r"rrr#r#r$r?rHr%r&r'r[r(r)r*rrrr>r4r3rIrrrrrZr2r]r6r7rrrr�<module>s�
1131  $
1132  
1133  
1134  %
1135  

1136  
1137  �
1138  %
1139  		
	
1140  

1141  +
1142  f	
1143  
1144  &<
1145