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

  2  [��ca4�@s�ddlZddlZddlZddlmZgd�Ze�d�ZGdd�de�Z	Gdd�de�Z
  3  d	d
  4  �Zdd�ZGd
d�d�Z
Gdd�d�Zdd�Zdd�Zdd�Zdd�ZdCdd�ZdCdd�ZiZdCdd�Zedk�rSdd lmZddlZe�Zejd!d"d#d$d%�ejd&d'd#d(d%�ejd)d*d+d,�ejd-d.d#d/d%�ejd0d1d2d,�ejd3d4d#d2d%�ejd5d6d7d,�e�ej�\ZZ e!e �d8kr�e"d9��ej#r�e�d:�Z$e$D]Z%ee%�Z&e'd;e&j(e&j(e&j)f�q�e d<Z*ej+�,d=�Z-e-r�ee*d>d?e-g�Z&nee*d>d?g�Z&ej.�rej.Z.nd@Z.ej/�r&e�0dAej/�Z1e1�se"dB��e1�2d<�Z(e1�2d8�Z3e3e&j4e(<ej5�r1e'e&�5e.��ej6�r<e'e&�6e.��ej7�rEe'e&j7�ej8�rUe'e&j7ej8k�dSdSdS)D�N)�RawConfigParser)�FormatError�PkgNotFound�LibraryInfo�VariableSet�read_config�parse_flagsz\$\{([a-zA-Z0-9_-]+)\}c@� eZdZdZdd�Zdd�ZdS)rzQ
  5      Exception thrown when there is a problem parsing a configuration file.
  6  
  7      cC�
  8  ||_dS�N��msg��selfr
�r��C:\Users\Jacks.GUTTSPC\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\numpy\distutils\npy_pkg_config.py�__init__�
  9  zFormatError.__init__cC�|jSrr�rrrr�__str__�zFormatError.__str__N��__name__�
 10  __module__�__qualname__�__doc__rrrrrrrsrc@r	)rz3Exception raised when a package can not be located.cCr
 11  rrrrrrrrzPkgNotFound.__init__cCrrrrrrrrrzPkgNotFound.__str__NrrrrrrsrcCs�gggggd�}d|�d�}|D]_}d|}t|�dkrp|�d�r0|d�|dd	����q|�d
 12  �rC|d�|dd	����q|�d�rV|d
�|dd	����q|�d�ri|d�|dd	����q|d�|�q|S)a�
 13      Parse a line from a config file containing compile flags.
 14  
 15      Parameters
 16      ----------
 17      line : str
 18          A single line containing one or more compile flags.
 19  
 20      Returns
 21      -------
 22      d : dict
 23          Dictionary of parsed flags, split into relevant categories.
 24          These categories are the keys of `d`:
 25  
 26          * 'include_dirs'
 27          * 'library_dirs'
 28          * 'libraries'
 29          * 'macros'
 30          * 'ignored'
 31  
 32      )�include_dirs�library_dirs�	libraries�macros�ignored� z -�-rz-Ir�Nz-Lrz-lrz-Dr r!)�split�len�
 33  startswith�append�strip)�line�d�flags�flagrrrrs$�
 34  
 35  
 36  
 37  �rcCs|�dd�S)N�\z\\)�replace)�valrrr�_escape_backslashIsr1c@s>eZdZdZddd�Zdd�Zddd	�Zdd
 38  d�Zdd
�ZdS)ra$
 39      Object containing build information about a library.
 40  
 41      Parameters
 42      ----------
 43      name : str
 44          The library name.
 45      description : str
 46          Description of the library.
 47      version : str
 48          Version string.
 49      sections : dict
 50          The sections of the configuration file for the library. The keys are
 51          the section headers, the values the text under each header.
 52      vars : class instance
 53          A `VariableSet` instance, which contains ``(name, value)`` pairs for
 54          variables defined in the configuration file for the library.
 55      requires : sequence, optional
 56          The required libraries for the library to be installed.
 57  
 58      Notes
 59      -----
 60      All input parameters (except "sections" which is a method) are available as
 61      attributes of the same name.
 62  
 63      NcCs4||_||_|r||_ng|_||_||_||_dSr)�name�description�requires�version�	_sections�vars)rr2r3r5�sectionsr7r4rrrrgs
 64  zLibraryInfo.__init__cC�t|j���S)z�
 65          Return the section headers of the config file.
 66  
 67          Parameters
 68          ----------
 69          None
 70  
 71          Returns
 72          -------
 73          keys : list of str
 74              The list of section headers.
 75  
 76          )�listr6�keysrrrrr8r�zLibraryInfo.sections�defaultcC�|j�|j|d�}t|�S)N�cflags�r7�interpolater6r1�r�sectionr0rrrr?��zLibraryInfo.cflagscCr>)N�libsr@rBrrrrE�rDzLibraryInfo.libscCsVd|jd|jg}|jr|�d�n|�dd�|j��|�d|j�d�|�S)NzName: %szDescription: %sz	Requires:zRequires: %s�,zVersion: %s�
 77  )r2r3r4r(�joinr5)r�mrrrr�s
 78  zLibraryInfo.__str__r)r=)	rrrrrr8r?rErrrrrrLs
 79  
 80  
 81  rc@sHeZdZdZdd�Zdd�Zdd�Zdd	�Zd
 82  d�Zdd
�Z	dd�Z
 83  dS)ra
 84      Container object for the variables defined in a config file.
 85  
 86      `VariableSet` can be used as a plain dictionary, with the variable names
 87      as keys.
 88  
 89      Parameters
 90      ----------
 91      d : dict
 92          Dict of items in the "variables" section of the configuration file.
 93  
 94      cCs0tdd�|��D��|_i|_i|_|��dS)NcSsg|]\}}||f�qSrr)�.0�k�vrrr�
 95  <listcomp>��z(VariableSet.__init__.<locals>.<listcomp>)�dict�items�	_raw_data�_re�_re_sub�_init_parse)rr+rrrr�szVariableSet.__init__cCs$|j��D]
 96  \}}|�||�qdSr)rQrP�_init_parse_var)rrKrLrrrrT�s�zVariableSet._init_parsecCs"t�d|�|j|<||j|<dS)Nz\$\{%s\})�re�compilerRrS�rr2�valuerrrrU�szVariableSet._init_parse_varcs>�fdd�}t�|�r||�}||kr	|S|}t�|�s|S)Ncs,�j��D]}�j|��j||�}q|Sr)rRr;�subrS)rYrKrrr�_interpolate�sz-VariableSet.interpolate.<locals>._interpolate)�_VAR�search)rrYr[ZnvaluerrrrA�s
 97  �
 98  �zVariableSet.interpolatecCr9)z�
 99          Return the list of variable names.
100  
101          Parameters
102          ----------
103          None
104  
105          Returns
106          -------
107          names : list of str
108              The names of all variables in the `VariableSet` instance.
109  
110          )r:rQr;rrrr�	variables�r<zVariableSet.variablescCs
111  |j|Sr)rQ)rr2rrr�__getitem__�rzVariableSet.__getitem__cCs||j|<|�||�dSr)rQrUrXrrr�__setitem__�s
112  zVariableSet.__setitem__N)rrrrrrTrUrAr^r_r`rrrrr�srcCsR|�d�s	td��t|�d��}dD]}||vrtd|��qd|vr'g|d<|S)N�metazNo meta section found !)r2r3r5z6Option %s (section [meta]) is mandatory, but not foundr4)�has_sectionrrOrP)�configr+rKrrr�
113  parse_meta�s
114  ��rdcCs:|�d�s	td��i}|�d�D]\}}|||<qt|�S)Nr^zNo variables section found !)rbrrPr)rcr+r2rYrrr�parse_variables�s
115  
116  recCsttfSr)Zmeta_d�r)rcrrr�parse_sections��rgcCsd|S)Nz%s.inir)�pkg_namerrr�pkg_to_filename�rhrjcs�|r�fdd�|D�}n�g}t�}|�|�}t|�dks%tdt|���t|�}i}|�d�r@|�d�D]
117  \}}t|�||<q5dd�|�	�D�}	i}
118  i}|	D]$}i}
|�
119  |d�ra|�|d�||<|�|�D]\}}||
|<qf|
|
120  |<qO|||
121  |fS)Ncsg|]	}tj�|���qSr)�os�pathrH)rJr+��filenamerrrM�sz parse_config.<locals>.<listcomp>�zCould not find file(s) %sr^cSsg|]}|dvr|�qS))rar^r)rJ�srrrrMrNr4)r�readr&r�strrdrbrPr1r8�
122  has_option�get)rn�dirs�	filenamesrc�nrar7r2rY�secsr8r4rpr+rrmr�parse_config�s.
123  
124  
125  
126  rycs���fdd���|�\}}}}d|vr:d|vr:|d}|tjvr*td||df��tj|}ttj�|j��|d<t|d|d|d|t	|�d	�S)
127  Ncs�t|��\}}}}|��D]8\}}�t|��\}}}	}
128  |��D]\}}||vr+|||<q|	|��D]\}
}|rD|||
d|7<q2q
||||fS)Nz %s)ryrPrj)�frar7r8�reqs�rname�rvalueZnmetaZnvarsZ	nsectionsZnreqsrKrL�onameZovalue��_read_configrurrr�s���z&_read_config_imp.<locals>._read_configZpkgdir�pkgnamez-You should import %s to get information on %sr2r3r5)r2r3r5r8r7)
129  �sys�modules�
130  ValueErrorr1rkrl�dirname�__file__rr)rvrurar7r8r{r��modrrr�_read_config_imps
131  
132  �
133  �r�cCs8zt|WStytt|�|�}|t|<|YSw)a
134      Return library info for a package from its configuration file.
135  
136      Parameters
137      ----------
138      pkgname : str
139          Name of the package (should match the name of the .ini file, without
140          the extension, e.g. foo for the file foo.ini).
141      dirs : sequence, optional
142          If given, should be a sequence of directories - usually including
143          the NumPy base directory - where to look for npy-pkg-config files.
144  
145      Returns
146      -------
147      pkginfo : class instance
148          The `LibraryInfo` instance containing the build information.
149  
150      Raises
151      ------
152      PkgNotFound
153          If the package is not found.
154  
155      See Also
156      --------
157      misc_util.get_info, misc_util.get_pkg_info
158  
159      Examples
160      --------
161      >>> npymath_info = np.distutils.npy_pkg_config.read_config('npymath')
162      >>> type(npymath_info)
163      <class 'numpy.distutils.npy_pkg_config.LibraryInfo'>
164      >>> print(npymath_info)
165      Name: npymath
166      Description: Portable, core math library implementing C99 standard
167      Requires:
168      Version: 0.1  #random
169  
170      )�_CACHE�KeyErrorr�rj)r�rurLrrrrFs'
171  �r�__main__)�OptionParserz--cflagsr?�
172  store_truez*output all preprocessor and compiler flags)�dest�action�helpz--libsrEzoutput all linker flagsz
--use-sectionrCz/use this section instead of default for options)r�r�z	--versionr5zoutput versionz--atleast-version�min_versionzMinimal versionz
173  --list-all�list_allz--define-variable�define_variablez%Replace variable with the given valuer$z(Expect package name on the command line:z*.iniz
174  %s	%s - %sro�NPY_PKG_CONFIG_PATHznumpy/core/lib/npy-pkg-config�.r=z([\S]+)=([\S]+)zH--define-variable option should be of the form --define-variable=foo=barr)9r�rVrk�configparserr�__all__rWr\�OSErrorrrrr1rrrdrergrjryr�r�rr�optparser��glob�parser�
175  add_option�
176  parse_args�argv�options�argsr&r�r��filesrz�info�printr2r3ri�environrtr+rCr�r]rI�grouprYr7r?rEr5r�rrrr�<module>s�
177  *HD
178  
179  $(
180  
181  3
182  �
183  ��
184  ��
185  ��
186  
187  
188  
189  
190  �;