
    G/Ph2                        d dl Z d dlZd dlZd dlmZ g dZ ej        d          Z G d de          Z	 G d de          Z
d	 Zd
 Z G d d          Z G d d          Zd Zd Zd Zd Zd;dZd;dZi Zd;dZedk    rtd dlmZ d dlZ e            Ze                    dddd           e                    dddd           e                    d d!d"#           e                    d$d%dd&           e                    d'd(d)#           e                    d*d+dd)           e                    d,d-d.#           e                    e j                  \  ZZ  e!e           d/k     r e"d0          ej#        rB ej        d1          Z$e$D ]/Z% ee%          Z& e'e&j(        d2e&j(        d3e&j)                   0e d4         Z*ej+        ,                    d5          Z-e-r ee*d6d7e-g          Z&n ee*d6d7g          Z&ej.        rej.        Z.nd8Z.ej/        rW ej0        d9ej/                  Z1e1s e"d:          e12                    d4          Z(e12                    d/          Z3e3e&j4        e(<   ej5        r e'e&5                    e.                     ej6        r e'e&6                    e.                     ej7        r e'e&j7                   ej8        r e'e&j7        ej8        k               dS dS dS )<    N)RawConfigParser)FormatErrorPkgNotFoundLibraryInfoVariableSetread_configparse_flagsz\$\{([a-zA-Z0-9_-]+)\}c                       e Zd ZdZd Zd ZdS )r   zQ
    Exception thrown when there is a problem parsing a configuration file.

    c                     || _         d S Nmsgselfr   s     ^/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/numpy/distutils/npy_pkg_config.py__init__zFormatError.__init__           c                     | j         S r   r   r   s    r   __str__zFormatError.__str__   	    xr   N__name__
__module____qualname____doc__r   r    r   r   r   r      s<               r   r   c                       e Zd ZdZd Zd ZdS )r   z3Exception raised when a package can not be located.c                     || _         d S r   r   r   s     r   r   zPkgNotFound.__init__   r   r   c                     | j         S r   r   r   s    r   r   zPkgNotFound.__str__   r   r   Nr   r   r   r   r   r      s8        ==      r   r   c                    g g g g g d}d| z                        d          }|D ]d}d|z   }t          |          dk    rH|                    d          r6|d                             |dd	                                                    g|                    d
          r6|d                             |dd	                                                    |                    d          r6|d                             |dd	                                                    |                    d          r7|d                             |dd	                                                    I|d                             |           f|S )a  
    Parse a line from a config file containing compile flags.

    Parameters
    ----------
    line : str
        A single line containing one or more compile flags.

    Returns
    -------
    d : dict
        Dictionary of parsed flags, split into relevant categories.
        These categories are the keys of `d`:

        * 'include_dirs'
        * 'library_dirs'
        * 'libraries'
        * 'macros'
        * 'ignored'

    )include_dirslibrary_dirs	librariesmacrosignored z --r   z-Ir#      Nz-Lr$   z-lr%   z-Dr&   r'   )splitlen
startswithappendstrip)linedflagsflags       r   r	   r	      s   , Rb"	& 	&A 4Zt$$E * *Tzt99q==t$$ 	*.!((abb)9)9::::&& *.!((abb)9)9::::&& *+%%d122hnn&6&67777&& *(""48>>#3#34444)##D)))Hr   c                 .    |                      dd          S )N\z\\)replace)vals    r   _escape_backslashr8   I   s    ;;tV$$$r   c                   6    e Zd ZdZd	dZd Zd
dZd
dZd ZdS )r   a$  
    Object containing build information about a library.

    Parameters
    ----------
    name : str
        The library name.
    description : str
        Description of the library.
    version : str
        Version string.
    sections : dict
        The sections of the configuration file for the library. The keys are
        the section headers, the values the text under each header.
    vars : class instance
        A `VariableSet` instance, which contains ``(name, value)`` pairs for
        variables defined in the configuration file for the library.
    requires : sequence, optional
        The required libraries for the library to be installed.

    Notes
    -----
    All input parameters (except "sections" which is a method) are available as
    attributes of the same name.

    Nc                 n    || _         || _        |r|| _        ng | _        || _        || _        || _        d S r   )namedescriptionrequiresversion	_sectionsvars)r   r;   r<   r>   sectionsr@   r=   s          r   r   zLibraryInfo.__init__g   sB    	& 	$DMMDM!			r   c                 N    t          | j                                                  S )z
        Return the section headers of the config file.

        Parameters
        ----------
        None

        Returns
        -------
        keys : list of str
            The list of section headers.

        )listr?   keysr   s    r   rA   zLibraryInfo.sectionsr         DN''))***r   defaultc                 v    | j                             | j        |         d                   }t          |          S )Ncflagsr@   interpolater?   r8   r   sectionr7   s      r   rH   zLibraryInfo.cflags   s1    i##DN7$;H$EFF %%%r   c                 v    | j                             | j        |         d                   }t          |          S )NlibsrI   rK   s      r   rN   zLibraryInfo.libs   s1    i##DN7$;F$CDD %%%r   c                 (   d| j         z  d| j        z  g}| j        r|                    d           n0|                    dd                    | j                  z             |                    d| j        z             d                    |          S )NzName: %szDescription: %sz	Requires:zRequires: %s,zVersion: %s
)r;   r<   r=   r.   joinr>   )r   ms     r   r   zLibraryInfo.__str__   s    $)#%69I%IJ= 	?HH[!!!!HH^chht}&=&==>>>	-...yy||r   r   )rF   )	r   r   r   r   r   rA   rH   rN   r   r   r   r   r   r   L   sx         4	 	 	 	+ + + & & & && & & &    r   r   c                   <    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	S )
r   a  
    Container object for the variables defined in a config file.

    `VariableSet` can be used as a plain dictionary, with the variable names
    as keys.

    Parameters
    ----------
    d : dict
        Dict of items in the "variables" section of the configuration file.

    c                     t          d |                                D                       | _        i | _        i | _        |                                  d S )Nc                     g | ]	\  }}||f
S r   r   ).0kvs      r   
<listcomp>z(VariableSet.__init__.<locals>.<listcomp>   s     <<<$!Q1v<<<r   )dictitems	_raw_data_re_re_sub_init_parse)r   r1   s     r   r   zVariableSet.__init__   sN    <<!''))<<<==r   c                 p    | j                                         D ]\  }}|                     ||           d S r   )r]   r\   _init_parse_var)r   rX   rY   s      r   r`   zVariableSet._init_parse   sF    N((** 	' 	'DAq  A&&&&	' 	'r   c                 X    t          j        d|z            | j        |<   || j        |<   d S )Nz\$\{%s\})recompiler^   r_   r   r;   values      r   rb   zVariableSet._init_parse_var   s.    K$$677"Tr   c                       fd}t                               |          r. ||          }||k    rn|}t                               |          .|S )Nc                     j                                         D ].}j         |                             j        |         |           } /| S r   )r^   rD   subr_   )rg   rX   r   s     r   _interpolatez-VariableSet.interpolate.<locals>._interpolate   sD    X]]__ @ @Q??Lr   )_VARsearch)r   rg   rk   nvalues   `   r   rJ   zVariableSet.interpolate   so    	 	 	 	 	 kk%   	!\%((FE	 kk%   	 r   c                 N    t          | j                                                  S )z
        Return the list of variable names.

        Parameters
        ----------
        None

        Returns
        -------
        names : list of str
            The names of all variables in the `VariableSet` instance.

        )rC   r]   rD   r   s    r   	variableszVariableSet.variables   rE   r   c                     | j         |         S r   )r]   )r   r;   s     r   __getitem__zVariableSet.__getitem__   s    ~d##r   c                 F    || j         |<   |                     ||           d S r   )r]   rb   rf   s      r   __setitem__zVariableSet.__setitem__   s*    $tT5)))))r   N)r   r   r   r   r   r`   rb   rJ   rp   rr   rt   r   r   r   r   r      s           ' ' '# # #  + + +"$ $ $* * * * *r   r   c                     |                      d          st          d          t          |                     d                    }dD ]}||vrt          d|z            d|vrg |d<   |S )NmetazNo meta section found !)r;   r<   r>   z6Option %s (section [meta]) is mandatory, but not foundr=   )has_sectionr   r[   r\   )configr1   rX   s      r   
parse_metary      s    f%% 53444V\\&!!""A/ % %Avv  "#$ % % %  ??*Hr   c                     |                      d          st          d          i }|                     d          D ]
\  }}|||<   t          |          S )Nrp   zNo variables section found !)rw   r   r\   r   )rx   r1   r;   rg   s       r   parse_variablesr{      sb    k** :8999
A||K00  e$q>>r   c                     t           t          fS r   )meta_dr)rx   s    r   parse_sectionsr      s    19r   c                     d| z  S )Nz%s.inir   )pkg_names    r   pkg_to_filenamer      s    hr   c                     |r fd|D             }n g}t                      }|                    |          }t          |          dk    st          dt	          |          z            t          |          }i }|                    d          r-|                    d          D ]\  }}t          |          ||<   d |	                                D             }	i }
i }|	D ]X}i }|
                    |d          r|                    |d          ||<   |                    |          D ]
\  }}|||<   ||
|<   Y|||
|fS )Nc                 P    g | ]"}t           j                            |          #S r   )ospathrR   )rW   r1   filenames     r   rZ   z parse_config.<locals>.<listcomp>   s)    ===1RW\\!X..===r      zCould not find file(s) %srp   c                     g | ]}|d v|	S ))rv   rp   r   )rW   ss     r   rZ   z parse_config.<locals>.<listcomp>  s#    KKK!5J0J0JA0J0J0Jr   r=   )r   readr,   r   strry   rw   r\   r8   rA   
has_optionget)r   dirs	filenamesrx   nrv   r@   r;   rg   secsrA   r=   r   r1   s   `             r   parse_configr      s}    =======		J	FIAq66Q;;5IFGGG fDD+&& 2!<<44 	2 	2KD%*511DJJ LKv((KKKDHH  Q
++ 	4 **Q
33HQK!<<?? 	 	KD%AdGGx))r   c           	         fd |           \  }}}}d|vr{d|v rw|d         }|t           j        vrt          d|d|d                   t           j        |         }t          t          j                            |j                            |d<   t          |d         |d         |d         |t          |          	          S )
Nc                 d   t          |           \  }}}}|                                D ]\  }} t          |                    \  }}}	}
|                                D ]\  }}||vr|||<   |	|                                         D ] \  }}|r||         |xx         d|z  z  cc<   !||||fS )Nz %s)r   r\   r   )frv   r@   rA   reqsrnamervaluenmetanvars	nsectionsnreqsrX   rY   onameovalue_read_configr   s                  r   r   z&_read_config_imp.<locals>._read_config  s    %1!T%:%:"dHd!ZZ\\ 	= 	=ME6-9\/&:Q:Q-R-R*E5)U     1DyyDG "+5!1!7!7!9!9 = =v =UOE***efn<***= T8T))r   pkgdirpkgnamezYou should import z to get information on r;   r<   r>   )r;   r<   r>   rA   r@   )
sysmodules
ValueErrorr8   r   r   dirname__file__r   r   )	r   r   rv   r@   rA   r   r   modr   s	    `      @r   _read_config_impr     s    * * * * * *$ ".i!8!8D$$
 t	T 1 1y/#+%%*%ggtF||5 6 6 6 k'"*27??3<+H+HIIXDLd=6IOh[=N=NP P P Pr   c                     	 t           |          S # t          $ r, t          t          |           |          }|t           | <   |cY S w xY w)a  
    Return library info for a package from its configuration file.

    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 directories - usually including
        the NumPy base directory - where to look for npy-pkg-config files.

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

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

    See Also
    --------
    misc_util.get_info, misc_util.get_pkg_info

    Examples
    --------
    >>> npymath_info = np.distutils.npy_pkg_config.read_config('npymath')
    >>> type(npymath_info)
    <class 'numpy.distutils.npy_pkg_config.LibraryInfo'>
    >>> print(npymath_info)
    Name: npymath
    Description: Portable, core math library implementing C99 standard
    Requires:
    Version: 0.1  #random

    )_CACHEKeyErrorr   r   )r   r   rY   s      r   r   r   F  sV    Ng   _W55t<<ws    3AA__main__)OptionParserz--cflagsrH   
store_truez*output all preprocessor and compiler flags)destactionhelpz--libsrN   zoutput all linker flagsz--use-sectionrL   z/use this section instead of default for options)r   r   z	--versionr>   zoutput versionz--atleast-versionmin_versionzMinimal versionz
--list-alllist_allz--define-variabledefine_variablez%Replace variable with the given valuer*   z(Expect package name on the command line:z*.ini	z - r   NPY_PKG_CONFIG_PATHznumpy/_core/lib/npy-pkg-config.rF   z([\S]+)=([\S]+)zH--define-variable option should be of the form --define-variable=foo=barr   )9r   rd   r   configparserr   __all__re   rl   OSErrorr   r   r	   r8   r   r   ry   r{   r   r   r   r   r   r   r   optparser   globparser
add_option
parse_argsargvoptionsargsr,   r   r   filesr   infoprintr;   r<   r   environr   r1   rL   r   rm   rS   grouprg   r@   rH   rN   r>   r   r   r   r   <module>r      s/   



 				 				 ( ( ( ( ( (& & & rz+,,	 	 	 	 	' 	 	 	    '   ( ( (T% % %F F F F F F F FPB* B* B* B* B* B* B* B*H   	 	 	    "* "* "* "*H"P "P "P "PP 
, , , ,f z%%%%%%KKK\^^F
jxG  I I I
hVL4  6 6 6
oIL  N N N
k	,+  - - -
),  . . .
lL,  . . .
)0AB  D D D ''11OWd
s4yy1}}jCDDD L	'"" 	L 	LA;q>>DE4999diii9I9IJKKKKAwH

,--A 
{7a@
 
 {7=
 
  /  BI('*ABB 	* B C C C 771::DGGAJJE	$~ $dkk'""###| "dii  !!! dl 3dlg1122222A ~3 3r   