o
    "g\                    @   s^  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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Zd dlmZ e Zg Zdd Zee g dZG dd	 d	Zd
d Zdd Zdd Zdd ZdddZdd Z dddZ!dd Z"dd Z#dd Z$dd d!Z%dd"d#Z&d$d% Z'e' re(d d&d'd(d)d*d+d,d-d.	Z)dd0d1Z*ndd2d1Z*d3d4 Z+d5d6 Z,d7d8 Z-d9d: Z.d;d< Z/d=d> Z0d?e1d@e1fdAdBZ2dCdD Z3dEdF Z4dGdH Z5dIdJ Z6e7dKej8j9Z:e7dLej8j9Z;e7dMej8j9Z<e7dNej8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 ZQddwdxZRdydz ZSd{d| ZTdd}d~ZUG dd dZVi fddZWdd ZXdd ZYdddZZdddZ[dd Z\dddZ]dd Z^dd Z_dd Z`dd Zadd ZbddhZcdd Zddd ZedS )    N)local)reduce)DistutilsErrorc               	   C   s:   t d urt D ]} zt|  W q ty   Y qw d S d S N)_tmpdirsshutilrmtreeOSError)d r   [/var/www/html/ecg_monitoring/venv/lib/python3.10/site-packages/numpy/distutils/misc_util.pyclean_up_temporary_directory   s   r   )*Configurationget_numpy_include_dirsdefault_config_dictdict_append
appendpathgenerate_config_pyget_cmdallpathget_mathlibsterminal_has_colorsred_text
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
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                   @   s   e Zd ZdZdd ZdS )InstallableLiba  
    Container to hold information on an installable library.

    Parameters
    ----------
    name : str
        Name of the installed library.
    build_info : dict
        Dictionary holding build information.
    target_dir : str
        Absolute path specifying where to install the library.

    See Also
    --------
    Configuration.add_installed_library

    Notes
    -----
    The three parameters are stored as attributes with the same names.

    c                 C   s   || _ || _|| _d S r   )name
build_info
target_dir)selfr9   r:   r;   r   r   r   __init__F   s   
zInstallableLib.__init__N)__name__
__module____qualname____doc__r=   r   r   r   r   r8   0   s    r8   c                  C   s   ddl m}  z	ttd}W n ty   t }Y nw t|d}t	tj
d|}|  }|du r4|S t|dddt|dddt|d	ddf}td
d |D rY|S tdd |D S )a  
    Get number of parallel build jobs set by the --parallel command line
    argument of setup.py
    If the command did not receive a setting the environment variable
    NPY_NUM_BUILD_JOBS is checked. If that is unset, return the number of
    processors on the system, with a maximum of 8 (to prevent
    overloading the system if there a lot of CPUs).

    Returns
    -------
    out : int
        number of parallel jobs that can be run

    r   get_distribution   NPY_NUM_BUILD_JOBSNbuildparallel	build_ext
build_clibc                 s   s    | ]}|d u V  qd S r   r   .0xr   r   r   	<genexpr>k       z%get_num_build_jobs.<locals>.<genexpr>c                 s   s    | ]	}|d ur|V  qd S r   r   rJ   r   r   r   rM   n   s    )numpy.distutils.corerC   lenossched_getaffinityAttributeErrormultiprocessing	cpu_countminintenvirongetgetattrget_command_objallmax)rC   rU   envjobsdistcmdattrr   r   r   r5   L   s$   
r5   c                 C   s^   ddl }|jdtdd t| } tt| D ]}| | }d|v r,|d dvr,d| | |< q| S )	z8Quote list of arguments.

    .. deprecated:: 1.22.
    r   Nz"quote_args" is deprecated.   
stacklevel z"'z"%s")warningswarnDeprecationWarninglistrangerP   )argsre   iar   r   r   
quote_argsp   s   rm   c                 C   s   |  d}tjj| S )zDConvert a /-separated pathname to one using the OS's path separator./)splitrQ   pathjoin)r9   ro   r   r   r   r      s   
r   c                 C   s   t jt j|}t jt j| }t|t|k r| S ||kr$dS ||dt| krN|t| t jfv sDJ t| |t| f|t|d d } | S )z$Return path relative to parent_path. N   )rQ   rp   realpathabspathrP   seprepr)rp   parent_pathpdapathr   r   r   rel_path   s   ,r{   c                 C   s   zt d| j| j}tjtj|}W n1 tyE   t d| j| j}t| t	j
| }t|dr=tjtj|j}ntjd}Y nw |durOt||}|pRdS )zReturn path of the module given a frame object from the call stack.

    Returned path is relative to parent_path when given,
    otherwise it is absolute path.
    __file__r>   .N)eval	f_globalsf_localsrQ   rp   dirnameru   	NameError
__import__sysmoduleshasattrr|   r{   )framerx   caller_filer
   caller_namemodr   r   r   get_path_from_frame   s   


r   c                  G   sz   g }| D ]}t |r|t|  qt|sJ || q|} | s%d}ntjj|  }tjjdkr9|dtjj}t	|S )a2  Join two or more pathname components +
    - convert a /-separated pathname to one using the OS's path separator.
    - resolve `..` and `.` from path.

    Either passing n arguments as in njoin('a','b'), or a sequence
    of n names as in njoin(['a','b']) is handled, or a mixture of such arguments.
    rr   rn   )
r-   appendr,   r.   rQ   rp   rq   rv   replacer+   )rp   pathspjoinedr   r   r   r,      s   r,   c           	      C   s   | durt j| d}n t }|D ]} t j| d}t j|r$|} nqtd|f t|+}g }d}|D ]}||rR|t|d 	 }|rR|
|d q7W d   |S 1 s^w   Y  |S )z/Return the MATHLIB line from numpyconfig.h
    Nz_numpyconfig.hz1_numpyconfig.h not found in numpy include dirs %rz#define MATHLIB,)rQ   rp   rq   r   existsr   open
startswithrP   stripextendro   )	rp   config_filedirsfnfidmathlibsslinevaluer   r   r   r      s4   


r   c                 C   s   t | s| S d| vr| S | tj}|r+z|dd}W n	 ty%   Y nw ||= |sd}|rZz|d|}W n	 ty@   Y nw ||d  dkrN|d7 }n
||= ||d = d}|s/|s^dS tj|S )z$Resolve `..` and '.' from path.
    r}   rs   z..rr   )r.   ro   rQ   rv   index
ValueErrorrq   )rp   lrk   jr   r   r   r+      s8   

r+   c                 C   s   t t| S )z}sorts output of python glob for https://bugs.python.org/issue30461
    to allow extensions to have reproducible build results)sortedglob)fileglobr   r   r   sorted_glob  s   r   c                 C   sB  t | sJ tt| g }t| rJ t| | D ]}t|rd|v s(d|v rSt|}tt||}|r;|| q|rC|| q|rJ|| td||f  qt||}t	j
|rd|| qt	j
|rp|| n|rw|| t	j
|std||f  qt |r|t||| q|| qdd |D S )N*?z#could not resolve pattern in %r: %rznon-existing path in %r: %rc                 S   s   g | ]}t |qS r   )r+   rK   r   r   r   r   
<listcomp>-      z_fix_paths.<locals>.<listcomp>)r-   rw   typer.   r   r,   r   r   printrQ   rp   r   
_fix_paths)r   
local_pathinclude_non_existing	new_pathsnr   p2n2r   r   r   r   
  sB   


r   rr   Tc                 C   s   t | r| f} t| ||S )z:Apply glob to paths and prepend local_path if needed.
    )r.   r   )r   r   r   r   r   r   r0   /  s   r0   c                 C   sL   t tdst t_ttj tj| |tj|d\}}t	|d}||fS )Ntempdir)suffixprefixdirtextw)
r   _tdatatempfilemkdtempr   r   r   mkstemprQ   fdopen)r   r   r   r   r9   for   r   r   make_temp_file6  s   


r   c                  C   s   t jdkrdtjvrdS tt jdrgt j rgzEdd l} |   | 	ddkrT| 	ddkrW| 
dd ur<| 
dd usQ| 
d	d urJ| 
d
d usQ| 
dd urZW dS W dS W dS W dS  tyf   Y dS w dS )Ncygwin	USE_COLORr   isattycolorspairssetfsetbsetafsetabscprs   )r   platformrQ   rX   r   stdoutr   curses	setuptermtigetnumtigetstr	Exception)r   r   r   r   r   C  s2   	
	r   rs   ra                  	   )	blackredgreenyellowbluemagentacyanwhitedefaultFc                 C   sx   g }|r	| d |rdt| d }| t| |r/dt| d }| t| |r:dd|| f S | S )N1   r   (   r   z[%sm%s[0m;)r   _colour_codesrY   lowerstrrq   )r   fgbgboldseqfgcodebgcoder   r   r   colour_texta  s   
r   c                 C   s   | S r   r   )r   r   r   r   r   r   r   p  s   c                 C   
   t | dS )Nr   r   r   r   r   r   default_texts     
r   c                 C   r   )Nr   r   r   r   r   r   r   u  r   r   c                 C   r   )Nr   r   r   r   r   r   r   w  r   r   c                 C   r   )Nr   r   r   r   r   r   r   y  r   r   c                 C   r   )Nr   r   r   r   r   r   r   {  r   r   c                 C   r   )Nr   r   r   r   r   r   r   }  r   r   rp   returnc                 C   s"   t jdkr| S tjdd| gddS )a(  Convert a path from Cygwin-native to Windows-native.

    Uses the cygpath utility (part of the Base install) to do the
    actual conversion.  Falls back to returning the original path if
    this fails.

    Handles the default ``/cygdrive`` mount prefix as well as the
    ``/proc/cygdrive`` portable prefix, custom cygdrive prefixes such
    as ``/`` or ``/mnt``, and absolute paths such as ``/usr/src/`` or
    ``/home/username``

    Parameters
    ----------
    path : str
       The path to convert

    Returns
    -------
    converted_path : str
        The converted path

    Notes
    -----
    Documentation for cygpath utility:
    https://cygwin.com/cygwin-ug-net/cygpath.html
    Documentation for the C function it wraps:
    https://cygwin.com/cygwin-api/func-cygwin-conv-path.html

    r   z/usr/bin/cygpathz	--windowsT)r   )r   r   
subprocesscheck_output)rp   r   r   r   r     s
   

r   c                   C   s:   t jdkrtjdddkrdS tjdddkrdS dS )	z0Return true when using mingw32 environment.
    win32OSTYPErr   msysTMSYSTEMMINGW32F)r   r   rQ   rX   rY   r   r   r   r   r     s   
r   c                  C   s:   t jd} | dkrtt j| d | d  }|S d}|S )zGReturn version of MSVC runtime library, as defined by __MSC_VER__ macrozMSC v.r   
   N)r   versionfindrW   )msc_posmsc_verr   r   r   msvc_runtime_version  s   r  c                  C   s&   t  } | r| dk rd|  S d|  S dS )zFReturn name of MSVC runtime library if Python was built with MSVC >= 7   zmsvcr%izvcruntime%iN)msvc_runtime_major)verr   r   r   msvc_runtime_library  s   r  c                  C   s    ddddddd t d} | S )	zFReturn major version of MSVC runtime coded like get_build_msvc_versionF   G   P   Z   d   r  )i  i  ix  i  i@  il  N)rY   r  )majorr   r   r   r    s   
r  z.*\.(cpp|cxx|cc)\Zz.*\.(f90|f95|f77|for|ftn|f)\Zz.*\.(f90|f95)\Zz\s*module\s*(?P<name>[\w_]+)c                 C   sh   t | sg S g }t| }|D ]}t|}|r!|d}|| qW d   |S 1 s-w   Y  |S )zRReturn a list of Fortran f90 module names that
    given source file defines.
    r9   N)f90_ext_matchr   f90_module_name_matchgroupr   )sourcer   fr   mr9   r   r   r   _get_f90_modules  s   



r  c                 C   s
   t | tS r   )
isinstancer   r   r   r   r   r.     r   r.   c                 C      t dd | D S )z4Return True if all items in lst are string objects. c                 s       | ]}t |V  qd S r   r.   )rK   itemr   r   r   rM     rN   zall_strings.<locals>.<genexpr>)r\   )lstr   r   r   r        r   c                 C   s0   t | rdS zt|  W dS  ty   Y dS w )NFT)r.   rP   r   r   r   r   r   r-     s   
r-   c                 C   s   t | od| v pd| v S )Nr   r   r  r   r   r   r   is_glob_pattern  s   r  c                 C   s   t | rt| S | gS r   )r-   rh   r  r   r   r   r/     s   r/   c                 C   s:   d}| D ]}t |trt|rd} |S t|rd}q|S )z2Determine language value (c,f77,f90) from sources Nf90f77)r  r   r  fortran_ext_match)sourceslanguager  r   r   r   r1      s   
r1   c                 C   r  )z.Return True if sources contains Fortran files c                 s   r  r   )r   rK   r  r   r   r   rM     rN   z has_f_sources.<locals>.<genexpr>anyr!  r   r   r   r      r  r    c                 C   r  )z*Return True if sources contains C++ files c                 s   r  r   )cxx_ext_matchr#  r   r   r   rM     rN   z"has_cxx_sources.<locals>.<genexpr>r$  r&  r   r   r   r!     r  r!   c                 C   sp   g }g }g }g }| D ]'}t |r"t|}|r|| q
|| q
t|r,|| q
|| q
||||fS )ztReturn four lists of filenames containing
    C, C++, Fortran, and Fortran 90 module sources,
    respectively.
    )r   r  r   r'  )r!  	c_sourcescxx_sources	f_sourcesfmodule_sourcesr  r   r   r   r   r"     s   r"   c                 C   s.   g }| D ]}t tj|d}|| q|S )Nz*.h)r   rQ   rp   rq   r   )directory_listheadersr
   headr   r   r   _get_headers,  s
   r/  c                 C   sD   g }| D ]}t j|}|d dkr|d |vr||d  q|S )Nr   rr   )rQ   rp   ro   r   )list_of_sourcesdirecsr  r
   r   r   r   _get_directories4  s   r2  c                 C   s6   d}|d | 7 }|d |7 }|d |d 7 }|S )zb
    Return commandline representation used to determine if a file needs
    to be recompiled
    zcommandline: rd   
rq   )cc_argsextra_postargspp_optscmdliner   r   r   _commandline_dep_string=  s
   r9  c                 C   s   t t| S r   )r/  r2  r&  r   r   r   r#   I  s   r#   c                 C   s   t | sdS tj| }tjt |g}|t|d tj}|r.|d s.|dd }|r8|d dkr8dS tj	|}tj
|S )z1Return true if directory is local directory.
    FNr   rs   rF   )r.   rQ   rp   ru   commonprefixgetcwdrP   ro   rv   rq   isdir)	directoryabs_dircnew_dirr   r   r   r$   M  s   r$   c                 #   sx    dddd t d}tj| ddD ]&\}}} fdd|D }||d d < |D ]}||s8tj||V  q)qd S )Nrs   CVS.svnrF   (?:[~#]|\.py[co]|\.o)$Ttopdownc                       g | ]}| vr|qS r   r   rK   r
   pruned_directoriesr   r   r   `      z(general_source_files.<locals>.<listcomp>)recompilerQ   walksearchrp   rq   )top_pathprune_file_patdirpathdirnames	filenamesprunedr  r   rI  r   general_source_files\  s   

rV  c           
      #   s    g dt dtj| ddD ]K\}}}fdd|D }||dd< |D ]4}tj|| t | }g }t D ]}tj |}	tj|	rU	|	sU|
|	 q<||fV  q'q|  t | } fddt D }d	d |D }||fV  dS )
zJReturn a directory name relative to top_path and
    files contained.
    rA  rD  TrE  c                    rG  r   r   rH  rI  r   r   r   m  rK  z4general_source_directories_files.<locals>.<listcomp>Nc                    s$   g | ]} |stj |qS r   )rO  rQ   rp   rq   rK   r  )dpathrQ  r   r   r   z  s    c                 S      g | ]
}t j|r|qS r   )rQ   rp   isfilerW  r   r   r   r   |      )rL  rM  rQ   rN  rp   rq   r{   listdirrZ  rO  r   )
rP  rR  rS  rT  rU  r
   rpathfilesr  r   r   )rX  rQ  rJ  r    general_source_directories_filesf  s,   


	
r_  c                 C   sn   g }dd | j D }|| |t| | jD ]}t|r)|tt| qtj	|r4|
| q|S )Nc                 S      g | ]}t |r|qS r   r  rK   _mr   r   r   r     rK  z(get_ext_source_files.<locals>.<listcomp>)r!  r   r#   dependsr$   rh   rV  rQ   rp   rZ  r   )extrT  r!  r
   r   r   r   r%     s   


r%   c                 C   s   dd | D } | S )Nc                 S   r`  r   r  ra  r   r   r   r     rK  z$get_script_files.<locals>.<listcomp>r   )scriptsr   r   r   r&     s   r&   c                 C   s   g }| d  dg }dd |D }|| |t| | d  dg }|D ]}t|r7|tt| q'tj|rB|	| q'|S )Nrs   r!  c                 S   r`  r   r  ra  r   r   r   r     rK  z(get_lib_source_files.<locals>.<listcomp>rc  )
rY   r   r#   r$   rh   rV  rQ   rp   rZ  r   )librT  r!  rc  r
   r   r   r   r'     s   

r'   c                 C   s   t j }|dd}| sAtjdstjdrd}|S tjdr'd}|S tjdr1d	}|S d
|v rA|d|d
 dd}|S )a  Return the correct file extension for shared libraries.

    Parameters
    ----------
    is_python_ext : bool, optional
        Whether the shared library is a Python extension.  Default is False.

    Returns
    -------
    so_ext : str
        The shared library extension.

    Notes
    -----
    For Python shared libs, `so_ext` will typically be '.so' on Linux and OS X,
    and '.pyd' on Windows.  For Python >= 3.2 `so_ext` has a tag prepended on
    POSIX systems according to PEP 3149.

    
EXT_SUFFIXrr   linuxgnukfreebsdz.sodarwinz.dylibwinz.dllSOABIr}   rs   )	distutils	sysconfigget_config_varsrY   r   r   r   r   )is_python_extconfvarsso_extr   r   r   get_shared_lib_extension  s"   


rs  c                 C   s   t | r| gS | d }g }|D ]1}t|drqt|r%|tt| qt |r;tj|r5|	| qt
d| qtt||S )Nrs   __call__zNot existing data file:)r.   r   r$   r   rh   rV  rQ   rp   rZ  r   r   	TypeErrorrw   )datar!  rT  r   r   r   r   r(     s   
r(   c                  G   s   d dd | D S )Nr}   c                 S   s   g | ]}|r|qS r   r   )rK   rl   r   r   r   r     r   zdot_join.<locals>.<listcomp>r4  )rj   r   r   r   r)     s   r)   c                 C   sN   zt | d W S  ty&   t  d j}t| d D ]}|j}q| Y S w )z:Return frame object from call stack with given level.
    rs   ra   )r   	_getframerS   exc_infotb_frameri   f_back)levelr   _r   r   r   r*     s   r*   c                   @   s  e Zd Zg dZddgZddgZg Z						dXd	d
Zdd Zdd Z	dd Z
dd Zdd Z	dYddZ	dYddZ			dZddZ		d[ddZdd Zd d! Zd"d# Zd$d% Zd&d' Zd(d) Zd*d+ Zd,d- Zd.d/ Zd0d1 Zd2d3 Zd\d4d5Zd\d6d7Zd8d9 Zd:d; Zd<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,dS )`r   )
packagesext_modules
data_filesinclude_dirs	librariesr-  re  
py_modulesinstalled_librariesdefine_macrospackage_dirinstalled_pkg_configr9   r   Nrs   setup.pyc              	   K   s|  t ||| _d| _t|}t||| _|du r| j}d| _|du r%| j}ntjt	| j|r5t	| j|}tj|p;dsDt
d|f || _|| _tjj| jd | _| jdd | _| jdd | _| jD ]}	t||	g }
t| |	t|
 qh| jD ]}	t||	i }
t| |	|
 q| j| j }| jdd | _| D ]/}	|	|v rq||	 }t| |	| t|tr| j|	 qt|tr| j|	 q| j|	 qtjt	|dr| j | j || j!| j< tddddd| _"d}t#dd	D ])}zt|}W n t
y   Y  nw zt$d
|j%|j&}W  n
 t'y"   Y qw t|| j(r9|j"d r9| j)di |j" || _*dS )a  Construct configuration instance of a package.

        package_name -- name of the package
                        Ex.: 'distutils'
        parent_name  -- name of the parent package
                        Ex.: 'numpy'
        top_path     -- directory of the toplevel package
                        Ex.: the directory where the numpy package source sits
        package_path -- directory of package. Will be computed by magic from the
                        directory of the caller module if not specified
                        Ex.: the directory where numpy.distutils is
        caller_level -- frame level to caller namespace, internal parameter.
        Nrr   r}   z%r is not a directory__init__.pyF)ignore_setup_xxx_pyassume_default_configurationdelegate_options_to_subpackagesquietrs   r   r<   r  r   )+r)   r9   r   r*   r   r   rQ   rp   r<  r,   r   rP  package_pathrq   ro   path_in_package
_list_keys	list_keys
_dict_keys	dict_keyscopyrY   setattrr/   _extra_keys
extra_keyskeysr  rh   r   dictr   r}  r  optionsri   r~   r   r   r   	__class__set_options
setup_name)r<   package_nameparent_namerP  r  caller_levelr  attrscaller_framer   v
known_keysrl   caller_instancerk   r  r   r   r   r=     s|   




zConfiguration.__init__c                 C   sB   |    i }| j| j | j }|D ]}t| |}|r|||< q|S )z
        Return a dictionary compatible with the keyword arguments of distutils
        setup function.

        Examples
        --------
        >>> setup(**config.todict())                           #doctest: +SKIP
        )_optimize_data_filesr  r  r  rZ   )r<   r
   r  r   rl   r   r   r   todictY  s   

zConfiguration.todictc                 C   s   | j d st| d S d S )Nr  )r  r   r<   messager   r   r   infol  s   
zConfiguration.infoc                 C   s   t jd|f  d S )NzWarning: %s
)r   stderrwriter  r   r   r   rf   p  s   zConfiguration.warnc                 K   s6   |  D ]\}}|| jv r|| j|< qtd| dS )z
        Configure Configuration instance.

        The following options are available:
         - ignore_setup_xxx_py
         - assume_default_configuration
         - delegate_options_to_subpackages
         - quiet

        zUnknown option: N)itemsr  r   )r<   r  keyr   r   r   r   r  s  s
   
zConfiguration.set_optionsc                 C   s   ddl m} | S )z2Return the distutils distribution object for self.r   rB   )rO   rC   )r<   rC   r   r   r   rC     s   zConfiguration.get_distributionc                 C   s   | d}t| jg| }dd t|D }g }|D ]4}tjt|ds&qd| tjv r/qd| tjt	| d  }	| j
|	||d d}
||
 q|S )Nr}   c                 S   rY  r   )rQ   rp   r<  ra  r   r   r   r     r[  z:Configuration._wildcard_get_subpackage.<locals>.<listcomp>r  rF   rs   r  r  )ro   r,   r   r   rQ   rp   rZ  rv   rq   rP   get_subpackager   )r<   subpackage_namer  r  r   subpackage_pathr   config_listr
   r   r?  r   r   r   _wildcard_get_subpackage  s    
 z&Configuration._wildcard_get_subpackagec                 C   s&  t jdtj| ztjtj|d }t| j||}t	d
|d|}t|dsH| jd s;| d|  t||| j||d d}	n#t|g|dd d	   }
|
f}|jjjdkrf|| jf }|j| }	|	jt||kr| d
t|||	jf  W t jd= |	S W t jd= |	S t jd= w )Nr   r|  r}   configurationr  zCAssuming default configuration (%s does not define configuration())rs   r  r   z*Subpackage %r configuration returned as %r)r   rp   insertrQ   r   splitextbasenamer)   r9   r7   rq   ro   r   r  rf   r   rP  r  __code__co_argcount)r<   setup_pyr  r  r  r  r  r   setup_moduleconfigpnrj   r   r   r    _get_configuration_from_setup_py  s>   



z.Configuration._get_configuration_from_setup_pyc                 C   sL  |du r|du rt dtj|}|d}|du r)d|v r)| j|||d dS d|vs6J t|||f|du rCt| jg| }nt|g|dd  }| 	|gd }t|| j
}| jd	 sntj|snt|d
| }tj|s| jd s| dtj||f  t||| j||d d}n| j|||||d d}|r|gS g S )a  Return list of subpackage configurations.

        Parameters
        ----------
        subpackage_name : str or None
            Name of the subpackage to get the configuration. '*' in
            subpackage_name is handled as a wildcard.
        subpackage_path : str
            If None, then the path is assumed to be the local path plus the
            subpackage_name. If a setup.py file is not found in the
            subpackage_path, then a default configuration is used.
        parent_name : str
            Parent name.
        Nz;either subpackage_name or subpackage_path must be specifiedr}   r   rs   r  r   r   r  zsetup_%s.pyr  zEAssuming default configuration (%s/{setup_%s,setup}.py was not found))r   rQ   rp   r  ro   r  rw   r,   r   r   r  r  rZ  rf   r   r   rP  r  )r<   r  r  r  r  r   r  r  r   r   r   r    sT   


zConfiguration.get_subpackageFc           	      C   s   |rd}n| j }| j|||dd}|s| d |D ]/}|}t|tr'| }t|ts4J tt|| 	d|
d| j f  | jdi | q|  }|dur[| d|  dS dS )	a  Add a sub-package to the current Configuration instance.

        This is useful in a setup.py script for adding sub-packages to a
        package.

        Parameters
        ----------
        subpackage_name : str
            name of the subpackage
        subpackage_path : str
            if given, the subpackage path such as the subpackage is in
            subpackage_path / subpackage_name. If None,the subpackage is
            assumed to be located in the local path / subpackage_name.
        standalone : bool
        Nra   r  z0No configuration returned, assuming unavailable.z Appending %s configuration to %sr9   zTdistutils distribution has been initialized, it may be too late to add a subpackage r   )r9   r  rf   r  r   r  r  rw   r   r  rY   r   rC   )	r<   r  r  
standaloner  r  r  r
   r_   r   r   r   add_subpackage  s0   


zConfiguration.add_subpackagec              
      s  t |r	|\ }nd t |r fdd|D  dS t|s&td|f  du rBtj|r;tj||fS ||fS j|dd}t	|rt	 rt
 tj}|  ttt|d }|  |D ]	}|| sw||= qn|D ]|}tj|std| qzt|j}|tj}|  g }	d	}|D ]9}
t	|
r|t|krtd
 |f |	||  n|
|| ksJ t|
|| | ||f|	|
 |d7 }q||d rd||f  |	  tj|	|f qzdS |D ]	} |f qdS t	 rJ t  }|dur%|jdur%|j}nj}|D ]}tt|D ]\}}tjj |}|||f q2q*dS )a  Recursively add files under data_path to data_files list.

        Recursively add files under data_path to the list of data_files to be
        installed (and distributed). The data_path can be either a relative
        path-name, or an absolute path-name, or a 2-tuple where the first
        argument shows where in the install directory the data directory
        should be installed to.

        Parameters
        ----------
        data_path : seq or str
            Argument can be either

                * 2-sequence (<datadir suffix>, <path to data directory>)
                * path to data directory where python datadir suffix defaults
                  to package dir.

        Notes
        -----
        Rules for installation paths::

            foo/bar -> (foo/bar, foo/bar) -> parent/foo/bar
            (gun, foo/bar) -> parent/gun
            foo/* -> (foo/a, foo/a), (foo/b, foo/b) -> parent/foo/a, parent/foo/b
            (gun, foo/*) -> (gun, foo/a), (gun, foo/b) -> gun
            (gun/*, foo/*) -> parent/gun/a, parent/gun/b
            /foo/bar -> (bar, /foo/bar) -> parent/bar
            (gun, /foo/bar) -> parent/gun
            (fun/*/gun/*, sun/foo/bar) -> parent/fun/foo/gun/bar

        Examples
        --------
        For example suppose the source directory contains fun/foo.dat and
        fun/bar/car.dat:

        >>> self.add_data_dir('fun')                       #doctest: +SKIP
        >>> self.add_data_dir(('sun', 'fun'))              #doctest: +SKIP
        >>> self.add_data_dir(('gun', '/full/path/to/fun'))#doctest: +SKIP

        Will install data-files to the locations::

            <package install directory>/
              fun/
                foo.dat
                bar/
                  car.dat
              sun/
                foo.dat
                bar/
                  car.dat
              gun/
                foo.dat
                car.dat

        Nc                    s   g | ]	}  |fqS r   )add_data_dirr   r
   r<   r   r   r   b  s    z.Configuration.add_data_dir.<locals>.<listcomp>znot a string: %rFr   rs   zNot a directory, skippingr   zcannot fill pattern %r with %rz,mismatch of pattern_list=%s and path_list=%s)r-   r.   ru  rQ   rp   isabsr  r  r   r  r   ro   rv   reverserh   ri   rP   r<  r   r{   r   r   r   rw   rf   rq   rC   r  r_  r  )r<   	data_pathr   pattern_listrlrk   rp   r]  	path_listtarget_listr   r_   r  d1r  target_pathr   r  r   r  %  s|   8


(

zConfiguration.add_data_dirc                 C   s^   i }| j D ]\}}||vrt ||< |D ]	}|| | qqdd | D | j d d < d S )Nc                 S   s   g | ]
\}}|t |fqS r   )rh   )rK   r   r^  r   r   r   r     r[  z6Configuration._optimize_data_files.<locals>.<listcomp>)r  setaddr  )r<   	data_dictr   r^  r  r   r   r   r    s   
 z"Configuration._optimize_data_filesc                 G   s  t |dkr|D ]}| | qdS t |dksJ t|d r'|d \}}nd}t|r0|}n%t|rMt |dkr?|d }n|D ]	}| ||f qAdS ttt||du ryt|drad}ntj	
|rjd}ntj	|}| ||f dS | j|dd}t|rt|r|tj}|  |D ]=}|tj}|  |  g }	d}
|D ]}t|r|	||
  |
d7 }
q|	| q|	  | tj|	|f qdS | ||f dS t|rJ t||f|  }|dur|jdur|j}n| j}|tj	| j||f dS )a  Add data files to configuration data_files.

        Parameters
        ----------
        files : sequence
            Argument(s) can be either

                * 2-sequence (<datadir prefix>,<path to data file(s)>)
                * paths to data files where python datadir prefix defaults
                  to package dir.

        Notes
        -----
        The form of each element of the files sequence is very flexible
        allowing many combinations of where to get the files from the package
        and where they should ultimately be installed on the system. The most
        basic usage is for an element of the files argument sequence to be a
        simple filename. This will cause that file from the local path to be
        installed to the installation path of the self.name package (package
        path). The file argument can also be a relative path in which case the
        entire relative path will be installed into the package directory.
        Finally, the file can be an absolute path name in which case the file
        will be found at the absolute path name but installed to the package
        path.

        This basic behavior can be augmented by passing a 2-tuple in as the
        file argument. The first element of the tuple should specify the
        relative path (under the package install directory) where the
        remaining sequence of files should be installed to (it has nothing to
        do with the file-names in the source distribution). The second element
        of the tuple is the sequence of files that should be installed. The
        files in this sequence can be filenames, relative paths, or absolute
        paths. For absolute paths the file will be installed in the top-level
        package installation directory (regardless of the first argument).
        Filenames and relative path names will be installed in the package
        install directory under the path name given as the first element of
        the tuple.

        Rules for installation paths:

          #. file.txt -> (., file.txt)-> parent/file.txt
          #. foo/file.txt -> (foo, foo/file.txt) -> parent/foo/file.txt
          #. /foo/bar/file.txt -> (., /foo/bar/file.txt) -> parent/file.txt
          #. ``*``.txt -> parent/a.txt, parent/b.txt
          #. foo/``*``.txt`` -> parent/foo/a.txt, parent/foo/b.txt
          #. ``*/*.txt`` -> (``*``, ``*``/``*``.txt) -> parent/c/a.txt, parent/d/b.txt
          #. (sun, file.txt) -> parent/sun/file.txt
          #. (sun, bar/file.txt) -> parent/sun/file.txt
          #. (sun, /foo/bar/file.txt) -> parent/sun/file.txt
          #. (sun, ``*``.txt) -> parent/sun/a.txt, parent/sun/b.txt
          #. (sun, bar/``*``.txt) -> parent/sun/a.txt, parent/sun/b.txt
          #. (sun/``*``, ``*``/``*``.txt) -> parent/sun/c/a.txt, parent/d/b.txt

        An additional feature is that the path to a data-file can actually be
        a function that takes no arguments and returns the actual path(s) to
        the data-files. This is useful when the data files are generated while
        building the package.

        Examples
        --------
        Add files to the list of data_files to be included with the package.

            >>> self.add_data_files('foo.dat',
            ...     ('fun', ['gun.dat', 'nun/pun.dat', '/tmp/sun.dat']),
            ...     'bar/cat.dat',
            ...     '/full/path/to/can.dat')                   #doctest: +SKIP

        will install these data files to::

            <package install directory>/
             foo.dat
             fun/
               gun.dat
               nun/
                 pun.dat
             sun.dat
             bar/
               car.dat
             can.dat

        where <package install directory> is the package (or sub-package)
        directory such as '/usr/lib/python2.4/site-packages/mypackage' ('C:
        \Python2.4 \Lib \site-packages \mypackage') or
        '/usr/lib/python2.4/site- packages/mypackage/mysubpackage' ('C:
        \Python2.4 \Lib \site-packages \mypackage \mysubpackage').
        rs   Nr   rt  rr   Fr  )rP   add_data_filesr-   r.   ru  rw   r   r   rQ   rp   r  r   r   r  ro   rv   r  popr   rq   rC   r  r  )r<   r^  r  r
   filepatr   r  rp   r  r  rk   r   r_   r  r   r   r   r    sh   X


zConfiguration.add_data_filesc                 C   s@   |   }|durt|dsg |_|j| dS | j| dS )zAdd define macros to configuration

        Add the given sequence of macro name and value duples to the beginning
        of the define_macros list This list will be visible to all extension
        modules of the current package.
        Nr  )rC   r   r  r   )r<   macrosr_   r   r   r   add_define_macros@  s   
zConfiguration.add_define_macrosc                 G   J   |  |}|  }|dur|jdu rg |_|j| dS | j| dS )zAdd paths to configuration include directories.

        Add the given sequence of paths to the beginning of the include_dirs
        list. This list will be visible to all extension modules of the
        current package.
        N)r   rC   r  r   )r<   r   r  r_   r   r   r   add_include_dirsP     

zConfiguration.add_include_dirsc                    s   g  |D ]6t r fddD  qtttfr%tdkr+tt fddd D  q }|durS|j	du rKg |_	|j	
  dS j	
  dS )a  Add installable headers to configuration.

        Add the given sequence of files to the beginning of the headers list.
        By default, headers will be installed under <python-
        include>/<self.name.replace('.','/')>/ directory. If an item of files
        is a tuple, then its first argument specifies the actual installation
        location relative to the <python-include> path.

        Parameters
        ----------
        files : str or seq
            Argument(s) can be either:

                * 2-sequence (<includedir suffix>,<path to header file(s)>)
                * path(s) to header file(s) where python includedir suffix will
                  default to package name.
        c                    s   g | ]
}  j|fqS r   )r   r9   r   )r-  r<   r   r   r   u  r[  z-Configuration.add_headers.<locals>.<listcomp>ra   c                    s   g | ]}  d  |fqS r   )r   r   )r-  rp   r   r   r   y  s    rs   N)r.   r   r  tuplerh   rP   ru  rw   rC   r-  r   )r<   r^  r_   r   )r-  rp   r<   r   add_headers`  s    
zConfiguration.add_headersc                 O   s   | dd}t|| j|dS )a  Apply glob to paths and prepend local_path if needed.

        Applies glob.glob(...) to each path in the sequence (if needed) and
        prepends the local_path if needed. Because this is called on all
        source lists, this allows wildcard characters to be specified in lists
        of sources for extension modules and libraries and scripts and allows
        path-names be relative to the source directory.

        r   T)r   r   )rY   r0   r   )r<   r   kwsr   r   r   r   r     s
   
zConfiguration.pathsc                 C   s4   |  D ]}|| }|dv r| |}|||< qd S )N)r!  rc  r  library_dirsmodule_dirsextra_objects)r  r   )r<   kwkr  new_vr   r   r   _fix_paths_dict  s   
zConfiguration._fix_paths_dictc                 K   s  t  |}t| j||d< ||d< d|v r<|d }|d= t|tr$|g}|D ]}t|ts3J t|t|fi | q&| | |dg }g }g |d< |D ]k}	t|	t	r]| |	d  d|	v r|	
dd\}
}tjt| j|}tj|r| jd|dd	}t|tr| }d
d |dg D D ]}|
ddd }||
kr|dd t|fi |  nqqO||	 qO||d  |d< | j|dg  |d< ddlm} |di |}| j| |  }|dur| d|  |S )a  Add extension to configuration.

        Create and add an Extension instance to the ext_modules list. This
        method also takes the following optional keyword arguments that are
        passed on to the Extension constructor.

        Parameters
        ----------
        name : str
            name of the extension
        sources : seq
            list of the sources. The list of sources may contain functions
            (called source generators) which must take an extension instance
            and a build directory as inputs and return a source file or list of
            source files or None. If None is returned then no sources are
            generated. If the Extension instance has no sources after
            processing all source generators, then no extension module is
            built.
        include_dirs :
        define_macros :
        undef_macros :
        library_dirs :
        libraries :
        runtime_library_dirs :
        extra_objects :
        extra_compile_args :
        extra_link_args :
        extra_f77_compile_args :
        extra_f90_compile_args :
        export_symbols :
        swig_opts :
        depends :
            The depends list contains paths to files or directories that the
            sources of the extension module depend on. If any path in the
            depends list is newer than the extension module, then the module
            will be rebuilt.
        language :
        f2py_options :
        module_dirs :
        extra_info : dict or list
            dict or list of dict of keywords to be appended to keywords.

        Notes
        -----
        The self.paths(...) method is applied to all lists that may contain
        paths.
        r9   r!  
extra_infor  rs   @Nra   r  c                 S   s   g | ]}|d  qS r  r   )rK   r   r   r   r   r     r   z/Configuration.add_extension.<locals>.<listcomp>__OF__r   r  	ExtensionzTdistutils distribution has been initialized, it may be too late to add an extension r   )r  r)   r9   r  r  rw   r   r  rY   r  ro   rQ   rp   ru   r,   r   r<  r  r   r  r  r   r  rO   r  r~  rC   rf   )r<   r9   r!  r  ext_argsr  r  r  libnameslibnamelnamelpathr?  r   llnamer  rd  r_   r   r   r   add_extension  s`   
0



zConfiguration.add_extensionc                 K   s6   |  ||d| |  }|dur| d|  dS dS )a  
        Add library to configuration.

        Parameters
        ----------
        name : str
            Name of the extension.
        sources : sequence
            List of the sources. The list of sources may contain functions
            (called source generators) which must take an extension instance
            and a build directory as inputs and return a source file or list of
            source files or None. If None is returned then no sources are
            generated. If the Extension instance has no sources after
            processing all source generators, then no extension module is
            built.
        build_info : dict, optional
            The following keys are allowed:

                * depends
                * macros
                * include_dirs
                * extra_compiler_args
                * extra_f77_compile_args
                * extra_f90_compile_args
                * f2py_options
                * language

        NzQdistutils distribution has been initialized, it may be too late to add a library )_add_libraryrC   rf   )r<   r9   r!  r:   r_   r   r   r   add_library   s   
zConfiguration.add_libraryc                 C   s@   t  |}||d< d|vrg |d< | | | j||f dS )z\Common implementation for add_library and add_installed_library. Do
        not use directlyr!  rc  N)r  r  r  r   r<   r9   r!  install_dirr:   r   r   r   r  $  s   

zConfiguration._add_libraryc                 C   s@   |si }t j| j|}| |||| | jt||| dS )aS  
        Similar to add_library, but the specified library is installed.

        Most C libraries used with ``distutils`` are only used to build python
        extensions, but libraries built through this method will be installed
        so that they can be reused by third-party packages.

        Parameters
        ----------
        name : str
            Name of the installed library.
        sources : sequence
            List of the library's source files. See `add_library` for details.
        install_dir : str
            Path to install the library, relative to the current sub-package.
        build_info : dict, optional
            The following keys are allowed:

                * depends
                * macros
                * include_dirs
                * extra_compiler_args
                * extra_f77_compile_args
                * extra_f90_compile_args
                * f2py_options
                * language

        Returns
        -------
        None

        See Also
        --------
        add_library, add_npy_pkg_config, get_info

        Notes
        -----
        The best way to encode the options required to link against the specified
        C libraries is to use a "libname.ini" file, and use `get_info` to
        retrieve the required options (see `add_npy_pkg_config` for more
        information).

        N)rQ   rp   rq   r  r  r  r   r8   r  r   r   r   add_installed_library4  s
   ,z#Configuration.add_installed_libraryc                 C   s\   |du ri }t j| j|}| j| jv r"| j| j |||f dS |||fg| j| j< dS )a#  
        Generate and install a npy-pkg config file from a template.

        The config file generated from `template` is installed in the
        given install directory, using `subst_dict` for variable substitution.

        Parameters
        ----------
        template : str
            The path of the template, relatively to the current package path.
        install_dir : str
            Where to install the npy-pkg config file, relatively to the current
            package path.
        subst_dict : dict, optional
            If given, any string of the form ``@key@`` will be replaced by
            ``subst_dict[key]`` in the template file when installed. The install
            prefix is always available through the variable ``@prefix@``, since the
            install prefix is not easy to get reliably from setup.py.

        See also
        --------
        add_installed_library, get_info

        Notes
        -----
        This works for both standard installs and in-place builds, i.e. the
        ``@prefix@`` refer to the source directory for in-place builds.

        Examples
        --------
        ::

            config.add_npy_pkg_config('foo.ini.in', 'lib', {'foo': bar})

        Assuming the foo.ini.in file has the following content::

            [meta]
            Name=@foo@
            Version=1.0
            Description=dummy description

            [default]
            Cflags=-I@prefix@/include
            Libs=

        The generated file will have the following content::

            [meta]
            Name=bar
            Version=1.0
            Description=dummy description

            [default]
            Cflags=-Iprefix_dir/include
            Libs=

        and will be installed as foo.ini in the 'lib' subpath.

        When cross-compiling with numpy distutils, it might be necessary to
        use modified npy-pkg-config files.  Using the default/generated files
        will link with the host libraries (i.e. libnpymath.a).  For
        cross-compilation you of-course need to link with target libraries,
        while using the host Python installation.

        You can copy out the numpy/_core/lib/npy-pkg-config directory, add a
        pkgdir value to the .ini files and set NPY_PKG_CONFIG_PATH environment
        variable to point to the directory with the modified npy-pkg-config
        files.

        Example npymath.ini modified for cross-compilation::

            [meta]
            Name=npymath
            Description=Portable, core math library implementing C99 standard
            Version=0.1

            [variables]
            pkgname=numpy._core
            pkgdir=/build/arm-linux-gnueabi/sysroot/usr/lib/python3.7/site-packages/numpy/_core
            prefix=${pkgdir}
            libdir=${prefix}/lib
            includedir=${prefix}/include

            [default]
            Libs=-L${libdir} -lnpymath
            Cflags=-I${includedir}
            Requires=mlib

            [msvc]
            Libs=/LIBPATH:${libdir} npymath.lib
            Cflags=/INCLUDE:${includedir}
            Requires=mlib

        N)rQ   rp   rq   r  r9   r  r   )r<   templater  
subst_dictr   r   r   add_npy_pkg_configg  s   _
z Configuration.add_npy_pkg_configc                 G   r  )zAdd scripts to configuration.

        Add the sequence of files to the beginning of the scripts list.
        Scripts will be installed under the <prefix>/bin/ directory.

        N)r   rC   re  r   )r<   r^  re  r_   r   r   r   add_scripts  r  zConfiguration.add_scriptsc              
   K   s  | j D ]}t| |}|||g  q| jD ]}t| |}|||i  q| j | j | j }| D ]S}||vrit| |d }|rJ||| krJq5| d||| |ddf  t	| |||  | j
| q5|| jv r~| d|t| ||| f  q5||v rq5td| d S )Nz"Inheriting attribute %r=%r from %rr9   r   z*Ignoring attempt to set %r (from %r to %r)zDon't know about key=%r)r  rZ   r   rY   r  updater  r  rf   r  r   r  r   )r<   r  r  rl   r  r   r   r   r     s0   




zConfiguration.dict_appendc                 C   sv   ddl m} | j| j | j }d}|d| j d 7 }|  |D ]}t| |d }|r4|d|||f 7 }q |d7 }|S )Nr   )pformatz<-----
zConfiguration of z:
z%s = %s
z----->)pprintr  r  r  r  r9   sortrZ   )r<   r  r  r   r  rl   r   r   r   __str__  s   zConfiguration.__str__c                 C   sJ   t d}|  d|_d|_tjd}|r#tjd|g}|tjd< |S )zF
        Returns the numpy.distutils config command instance.
        r  r   PATHr}   )	r   ensure_finalizeddump_sourcenoisyrQ   rX   rY   pathseprq   )r<   cmdold_pathrp   r   r   r   get_config_cmd  s   
zConfiguration.get_config_cmdc                 C   s   t d}|  |jS )zh
        Return a path to a temporary directory where temporary files should be
        placed.
        rF   )r   r  
build_temp)r<   r  r   r   r   get_build_temp_dir  s   z Configuration.get_build_temp_dirc                 C      d}|   }|j|dd}|S )aS  Check for availability of Fortran 77 compiler.

        Use it inside source generating function to ensure that
        setup distribution instance has been initialized.

        Notes
        -----
        True if a Fortran 77 compiler is available (because a simple Fortran 77
        code was able to be compiled successfully).
        /
        subroutine simple
        end
        r  langr  try_compiler<   simple_fortran_subroutine
config_cmdflagr   r   r   	have_f77c     zConfiguration.have_f77cc                 C   r  )aR  Check for availability of Fortran 90 compiler.

        Use it inside source generating function to ensure that
        setup distribution instance has been initialized.

        Notes
        -----
        True if a Fortran 90 compiler is available (because a simple Fortran
        90 code was able to be compiled successfully)
        r	  r  r
  r  r  r   r   r   	have_f90c2  r  zConfiguration.have_f90cc                 C   sh   t |r|\}}t|| j| jd dS ddlm} t||s$J t||j| j |j| j dS )zEAppend libraries, include_dirs to extension or library item.
        )r  r  r   r  N)	r-   r   r  r  rO   r  r  rw   r   )r<   extliblib_namer:   r  r   r   r   	append_toE  s   
zConfiguration.append_toc              	   C   s  z
t jdg|d}W n t jtfy   Y nw td|}|r&t|dS tj	dkr9t
jddr9t|dd	}nt|d
d	}t
j|rt|}| }W d   n1 sXw   Y  |dd dkrvtd|}|rtt|dS dS td|}|rt|dS dS )z+Return path's SVN revision number.
        
svnversioncwd   (?P<revision>\d+)revisionr   SVN_ASP_DOT_NET_HACKN_svnentriesrC  r   z<?xmlzrevision="(?P<revision>\d+)"zdir[\n\r]+(?P<revision>\d+))r   r   CalledProcessErrorr	   rL  matchrW   r  r   r   rQ   rX   rY   r,   rp   rZ  r   readrO  )r<   rp   outputr  r  r  fstrr   r   r   _get_svn_revisionS  s0   

zConfiguration._get_svn_revisionc              
   C   s6  zt jg d|d}W n t jtfy   Y nw td|}|r't|dS t|dd}t|dd}t	j
|rd}t|}|  }W d   n1 sPw   Y  i }	t|1}|D ]&}
|
 dd	 \}}||krp|}zt|}W n	 ty   Y q^w ||	|< q^W d   n1 sw   Y  |	|S dS )
z1Return path's Mercurial revision number.
        )hgidentifyz--numr  r  r  z.hgbranchzbranch.cacheNra   )r   r   r   r	   rL  r!  rW   r  r,   rQ   rp   rZ  r   r"  r   ro   r   rY   )r<   rp   r#  r  	branch_fnbranch_cache_fnbranch0r  	revision0
branch_mapr   branch1	revision1r   r   r   _get_hg_revisionp  sB   




zConfiguration._get_hg_revisionc                 C   s  t | dd}|dur|S |du r d| jdd d ddd	g}n|g}|du r5dd
| jdd d g}n|g}|D ]y}t| j|}tj|rd}tjtj	|d }	t
| j|	}
ztd|
d|}W n ty } z| t| d}W Y d}~nd}~ww |du rq:|D ]}t ||d}|dur nqz| d }W n	 ty   Y nw |dur nq:|dur|| _|S | | j}|du r| | j}|durt|}|| _|S )a  Try to get version string of a package.

        Return a version string of the current package or None if the version
        information could not be detected.

        Notes
        -----
        This method scans files named
        __version__.py, <packagename>_version.py, version.py, and
        __svn_version__.py for string variables version, __version__, and
        <packagename>_version, until a version number is found.
        r   Nz__version__.pyr}   r   z_version.pyz
version.py__svn_version__.py__hg_version__.py__version___version)z.pyUrs   r   r|  )rZ   r9   ro   r,   r   rQ   rp   rZ  r  r  r)   r7   rq   ImportErrorrf   r   get_versionsrS   r   r%  r0  )r<   version_fileversion_variabler   r^  version_varsr  r   r  r9   r   version_moduleerl   r  r   r   r   get_version  sr   zConfiguration.get_versionTc                    V   t jdjtjsdu rdS  fdd}d| f dS )a  Appends a data function to the data_files list that will generate
        __svn_version__.py file to the current package directory.

        Generate package __svn_version__.py file from SVN revision number,
        it will be removed after python exits but will be available
        when sdist, etc commands are executed.

        Notes
        -----
        If __svn_version__.py existed before, nothing is done.

        This is
        intended for working with source directories that are in an SVN
        repository.
        r1  Nc                        t js/t} d| f  td}|d|   W d    n1 s*w   Y  jf fdd	}t| S )NCreating %s (version=%r)r   version = %r
c                    p    r6zt |  |d|   W n	 ty   Y nw zt | d  |d|  d  W d S  ty5   Y d S w d S Nzremoved r?  rQ   remover	   r  r   deleter   r   rm_file     &zSConfiguration.make_svn_version_py.<locals>.generate_svn_version_py.<locals>.rm_file	rQ   rp   rZ  r   r  r   r  atexitregisterr   r  rI  rH  r  r<   targetr   r   generate_svn_version_py     
zBConfiguration.make_svn_version_py.<locals>.generate_svn_version_pyrr   )r,   r   r%  rQ   rp   rZ  r  )r<   rH  rQ  r   rO  r   make_svn_version_py  s   z!Configuration.make_svn_version_pyc                    r>  )a  Appends a data function to the data_files list that will generate
        __hg_version__.py file to the current package directory.

        Generate package __hg_version__.py file from Mercurial revision,
        it will be removed after python exits but will be available
        when sdist, etc commands are executed.

        Notes
        -----
        If __hg_version__.py existed before, nothing is done.

        This is intended for working with source directories that are
        in an Mercurial repository.
        r2  Nc                     r?  )Nr@  r   rA  c                    rB  rC  rD  rF  rG  r   r   rI  &  rJ  zQConfiguration.make_hg_version_py.<locals>.generate_hg_version_py.<locals>.rm_filerK  rN  rO  r   r   generate_hg_version_py  rR  z@Configuration.make_hg_version_py.<locals>.generate_hg_version_pyrr   )r,   r   r0  rQ   rp   rZ  r  )r<   rH  rT  r   rO  r   make_hg_version_py  s   z Configuration.make_hg_version_py
__config__c                 C   s   | j | j|tf dS )zGenerate package __config__.py file containing system_info
        information used during building the package.

        This file is installed to the
        package installation directory.

        N)r  r   r9   r   )r<   r9   r   r   r   make_config_py3  s   zConfiguration.make_config_pyc                 G   s6   ddl m}m} i }|D ]}||fi || q|S )zGet resources information.

        Return information (from system_info.get_info) for all of the names in
        the argument list in a single dictionary.
        rs   )r3   r   )system_infor3   r   )r<   namesr3   r   	info_dictrl   r   r   r   r3   =  s
   zConfiguration.get_info)NNNNrs   r  )rs   )NNrs   )NFr   NN)T)rV  )-r>   r?   r@   r  r  r  numpy_include_dirsr=   r  r  rf   r  rC   r  r  r  r  r  r  r  r  r  r  r   r  r  r  r  r  r  r  r   r  r  r  r  r  r  r%  r0  r=  rS  rU  rW  r3   r   r   r   r   r     sr    
a

"
>
+y	 "g$

3k	
&
L
)
(
r   c                 C   sN   | |vr#dd l }|jj}|d u rddlm} |d|| }||| < ||  S )Nr   )DistutilsInternalErrorz+setup distribution instance not initialized)distutils.corecore_setup_distributiondistutils.errorsr]  r[   )cmdname_cacherm  r_   r]  r  r   r   r   r   J  s   
r   c                  C   s(   t jd d  } | sdd l}| g} | S )Nr   )r   r\  numpyget_include)r  rd  r   r   r   r   V  s
   
r   c                  C   sD   t jd} | dur| S tjd}t jt j|j	ddd} | S )a  Return the path where to find the npy-pkg-config directory.

    If the NPY_PKG_CONFIG_PATH environment variable is set, the value of that
    is returned.  Otherwise, a path inside the location of the numpy module is
    returned.

    The NPY_PKG_CONFIG_PATH can be useful when cross-compiling, maintaining
    customized npy-pkg-config .ini files for the cross-compilation
    environment, and using them when cross-compiling.

    NPY_PKG_CONFIG_PATHNrd  _corerf  znpy-pkg-config)
rQ   rX   rY   	importlibutil	find_specrp   rq   r   origin)r
   specr   r   r   get_npy_pkg_dir_  s   rm  c                 C   s0   ddl m} |r|t  nt g}|| |S )a  
    Return library info for the given package.

    Parameters
    ----------
    pkgname : str
        Name of the package (should match the name of the .ini file, without
        the extension, e.g. foo for the file foo.ini).
    dirs : sequence, optional
        If given, should be a sequence of additional directories where to look
        for npy-pkg-config files. Those directories are searched prior to the
        NumPy directory.

    Returns
    -------
    pkginfo : class instance
        The `LibraryInfo` instance containing the build information.

    Raises
    ------
    PkgNotFound
        If the package is not found.

    See Also
    --------
    Configuration.add_npy_pkg_config, Configuration.add_installed_library,
    get_info

    r   )read_config)numpy.distutils.npy_pkg_configrn  r   rm  )pkgnamer   rn  r   r   r   r4   s  s
   
r4   c                 C   sf   ddl m} t| |}|| }||  D ]\}}|| | q|d |d< |d= |d= |S )a;  
    Return an info dict for a given C library.

    The info dict contains the necessary options to use the C library.

    Parameters
    ----------
    pkgname : str
        Name of the package (should match the name of the .ini file, without
        the extension, e.g. foo for the file foo.ini).
    dirs : sequence, optional
        If given, should be a sequence of additional directories where to look
        for npy-pkg-config files. Those directories are searched prior to the
        NumPy directory.

    Returns
    -------
    info : dict
        The dictionary with build information.

    Raises
    ------
    PkgNotFound
        If the package is not found.

    See Also
    --------
    Configuration.add_npy_pkg_config, Configuration.add_installed_library,
    get_pkg_info

    Examples
    --------
    To get the necessary information for the npymath library from NumPy:

    >>> npymath_info = np.distutils.misc_util.get_info('npymath')
    >>> npymath_info                                    #doctest: +SKIP
    {'define_macros': [], 'libraries': ['npymath'], 'library_dirs':
    ['.../numpy/_core/lib'], 'include_dirs': ['.../numpy/_core/include']}

    This info dict can then be used as input to a `Configuration` instance::

      config.add_extension('foo', sources=['foo.c'], extra_info=npymath_info)

    r   )parse_flagsr  r  ignored)ro  rq  r4   cflagslibsr  r   )rp  r   rq  pkg_infor  r  r  r   r   r   r3     s   -
r3   c                  C   s*   dd l } z| j W dS  ty   Y dS w )Nr   TF)builtins__NUMPY_SETUP__rS   )rv  r   r   r   is_bootstrapping  s   rx  c                 C   s:   ddl }|jd| ||| ||f dd t| ||}| S )zqReturn a configuration dictionary for usage in
    configuration() function defined in file setup_<name>.py.
    r   NzXUse Configuration(%r,%r,top_path=%r) instead of deprecated default_config_dict(%r,%r,%r)ra   rb   )re   rf   r   r  )r9   r  r   re   r?  r   r   r   r     s   r   c                 K   sR   |  D ]"\}}|| v r"| | }t|tr|| |< q| | | q|| |< qd S r   )r  r  r   r   )r
   r  r  r  ovr   r   r   r     s   


r   c                 C   s(  t jjdkr| dt jj} |dt jj}d}t j|rt j| d }t jt j| d }t j|\}}t j||g}t j|d t	| |t	|d  |kslt j|d t	| |t	|d  |krrt j
|}|t	|d  }t j|r|dd  }n|}t jt||  |S )Nrn   rr   r   rs   )rQ   rp   rv   r   r  
splitdriveru   r:  rq   rP   r   normpathr,   )r   rp   drive	absprefix	pathdriver
   subpathr   r   r   r     s$   **r   c                 C   s   ddl m} ddlm} |tj|  t| dD}|dtj	t
jd   |d |d |td |j D ]\}}|d	||f  q?|td
 W d   | S 1 s`w   Y  | S )zGenerate config.py file containing system_info information
    used during building the package.

    Usage:
        config['py_modules'].append((packagename, '__config__',generate_config_py))
    r   )rX  )mkpathr   z'# This file is generated by numpy's %s
zH# It contains system_info results at the time of building this package.
z__all__ = ["get_info","show"]

a  
            import os
            import sys

            extra_dll_dir = os.path.join(os.path.dirname(__file__), '.libs')

            if sys.platform == 'win32' and os.path.isdir(extra_dll_dir):
                os.add_dll_directory(extra_dll_dir)

            z%s=%r
a~  
            def get_info(name):
                g = globals()
                return g.get(name, g.get(name + "_info", {}))

            def show():
                """
                Show libraries in the system on which NumPy was built.

                Print information about various resources (libraries, library
                directories, include directories, etc.) in the system on which
                NumPy was built.

                See Also
                --------
                get_include : Returns the directory containing NumPy C
                              header files.

                Notes
                -----
                1. Classes specifying the information to be printed are defined
                   in the `numpy.distutils.system_info` module.

                   Information may include:

                   * ``language``: language used to write the libraries (mostly
                     C or f77)
                   * ``libraries``: names of libraries found in the system
                   * ``library_dirs``: directories containing the libraries
                   * ``include_dirs``: directories containing library header files
                   * ``src_dirs``: directories containing library source files
                   * ``define_macros``: preprocessor macros used by
                     ``distutils.setup``
                   * ``baseline``: minimum CPU features required
                   * ``found``: dispatched features supported in the system
                   * ``not found``: dispatched features that are not supported
                     in the system

                2. NumPy BLAS/LAPACK Installation Notes

                   Installing a numpy wheel (``pip install numpy`` or force it
                   via ``pip install numpy --only-binary :numpy: numpy``) includes
                   an OpenBLAS implementation of the BLAS and LAPACK linear algebra
                   APIs. In this case, ``library_dirs`` reports the original build
                   time configuration as compiled with gcc/gfortran; at run time
                   the OpenBLAS library is in
                   ``site-packages/numpy.libs/`` (linux), or
                   ``site-packages/numpy/.dylibs/`` (macOS), or
                   ``site-packages/numpy/.libs/`` (windows).

                   Installing numpy from source
                   (``pip install numpy --no-binary numpy``) searches for BLAS and
                   LAPACK dynamic link libraries at build time as influenced by
                   environment variables NPY_BLAS_LIBS, NPY_CBLAS_LIBS, and
                   NPY_LAPACK_LIBS; or NPY_BLAS_ORDER and NPY_LAPACK_ORDER;
                   or the optional file ``~/.numpy-site.cfg``.
                   NumPy remembers those locations and expects to load the same
                   libraries at run-time.
                   In NumPy 1.21+ on macOS, 'accelerate' (Apple's Accelerate BLAS
                   library) is in the default build-time search order after
                   'openblas'.

                Examples
                --------
                >>> import numpy as np
                >>> np.show_config()
                blas_opt_info:
                    language = c
                    define_macros = [('HAVE_CBLAS', None)]
                    libraries = ['openblas', 'openblas']
                    library_dirs = ['/usr/local/lib']
                """
                from numpy._core._multiarray_umath import (
                    __cpu_features__, __cpu_baseline__, __cpu_dispatch__
                )
                for name,info_dict in globals().items():
                    if name[0] == "_" or type(info_dict) is not type({}): continue
                    print(name + ":")
                    if not info_dict:
                        print("  NOT AVAILABLE")
                    for k,v in info_dict.items():
                        v = str(v)
                        if k == "sources" and len(v) > 200:
                            v = v[:60] + " ...\n... " + v[-60:]
                        print("    %s = %s" % (k,v))

                features_found, features_not_found = [], []
                for feature in __cpu_dispatch__:
                    if __cpu_features__[feature]:
                        features_found.append(feature)
                    else:
                        features_not_found.append(feature)

                print("Supported SIMD extensions in this NumPy install:")
                print("    baseline = %s" % (','.join(__cpu_baseline__)))
                print("    found = %s" % (','.join(features_found)))
                print("    not found = %s" % (','.join(features_not_found)))

                    N)numpy.distutils.system_inforX  distutils.dir_utilr  rQ   rp   r   r   r  r  r   argvtextwrapdedentsaved_resultsr  )rP  rX  r  r  r  rk   r   r   r   r   	  s   


wwr   c                 C   s   | j dkstd| j  | jS )zdReturn version major and minor of compiler instance if it is
    MSVC, raise an exception otherwise.msvcz"Compiler instance is not msvc (%s))compiler_typer   _MSVCCompiler__version)compilerr   r   r   msvc_version	  s
   
r  c                  C   s   ddl m}  |  S )Nr   r2   )distutils.msvccompilerr2   r  r   r   r   r2   	  s   r2   z%-Werror=implicit-function-declarationz-std=c99c                 C   s   dd | D S )z=
    Some flags are valid for C but not C++. Prune them.
    c                 S   s   g | ]}|t vr|qS r   )_cxx_ignore_flags)rK   r  r   r   r   r   	  rK  z&sanitize_cxx_flags.<locals>.<listcomp>r   )cxxflagsr   r   r   r6   	  s   r6   c                 C   s*   t j| |}t j|}|j| |S )z
    Use importlib machinery to import a module `modname` from the file
    `modfile`. Depending on the `spec.loader`, the module may not be
    registered in sys.modules.
    )rh  ri  spec_from_file_locationmodule_from_specloaderexec_module)modnamemodfilerl  foor   r   r   r7   	  s   r7   r   )rr   T)rr   rr   T)NNFr[  )Fr  )NNN)frQ   rL  r   r  r   rL  r   r   r   rT   r  importlib.utilrh  	threadingr   tlocal	functoolsr   rm  ra  r   r   r   r   rM  __all__r8   r5   rm   r   r{   r   r,   r   r+   r   r   r0   r   r   r  r   r   r   r   r   r   r   r   r   r   r   r  r  r  rM  Ir!  r'  r   r  r  r  r.   r   r-   r  r/   r1   r    r!   r"   r/  r2  r9  r#   r$   rV  r_  r%   r&   r'   rs  r(   r)   r*   r   r   r   rm  r4   r3   rx  r   r   r   r   r  r2   r  r6   r7   r   r   r   r   <module>   s    
$


%



%
			

+
          f	

&<
 