HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/local/lib/python3.10/dist-packages/numpy/distutils/__pycache__/npy_pkg_config.cpython-310.pyc
o

���g�2�@s�ddlZddlZddlZddlmZgd�Ze�d�ZGdd�de�Z	Gdd�de�Z
d	d
�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
    Exception thrown when there is a problem parsing a configuration file.

    cC�
||_dS�N��msg��selfr
�r�I/usr/local/lib/python3.10/dist-packages/numpy/distutils/npy_pkg_config.py�__init__�
zFormatError.__init__cC�|jSrr�rrrr�__str__�zFormatError.__str__N��__name__�
__module__�__qualname__�__doc__rrrrrrrsrc@r	)rz3Exception raised when a package can not be located.cCr
rrrrrrrrzPkgNotFound.__init__cCrrrrrrrrrzPkgNotFound.__str__NrrrrrrsrcCs�gggggd�}d|�d�}|D]_}d|}t|�dkrp|�d�r0|d�|dd	����q|�d
�rC|d�|dd	����q|�d�rV|d
�|dd	����q|�d�ri|d�|dd	����q|d�|�q|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 -�-rz-Ir�Nz-Lrz-lrz-Dr r!)�split�len�
startswith�append�strip)�line�d�flags�flagrrrrs$�



�rcCs|�dd�S)N�\z\\)�replace)�valrrr�_escape_backslashIsr1c@s>eZdZdZddd�Zdd�Zddd	�Zdd
d�Zdd
�ZdS)ra$
    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.

    NcCs4||_||_|r||_ng|_||_||_||_dSr)�name�description�requires�version�	_sections�vars)rr2r3r5�sectionsr7r4rrrrgs
zLibraryInfo.__init__cC�t|j���S)z�
        Return the section headers of the config file.

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

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

        )�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�
)r2r3r4r(�joinr5)r�mrrrr�s
zLibraryInfo.__str__r)r=)	rrrrrr8r?rErrrrrrLs


rc@sHeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)ra
    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.

    cCs0tdd�|��D��|_i|_i|_|��dS)NcSsg|]\}}||f�qSrr)�.0�k�vrrr�
<listcomp>��z(VariableSet.__init__.<locals>.<listcomp>)�dict�items�	_raw_data�_re�_re_sub�_init_parse)rr+rrrr�szVariableSet.__init__cCs$|j��D]
\}}|�||�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[�nvaluerrrrA�s
�
�zVariableSet.interpolatecCr9)z�
        Return the list of variable names.

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

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

        )r:rQr;rrrr�	variables�r<zVariableSet.variablescCs
|j|Sr)rQ)rr2rrr�__getitem__�rzVariableSet.__getitem__cCs||j|<|�||�dSr)rQrUrXrrr�__setitem__�s
zVariableSet.__setitem__N)rrrrrrTrUrAr_r`rarrrrr�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�
parse_meta�s
��recCs:|�d�s	td��i}|�d�D]\}}|||<qt|�S)Nr_zNo variables section found !)rcrrPr)rdr+r2rYrrr�parse_variables�s

rfcCsttfSr)�meta_d�r)rdrrr�parse_sections��ricCsd|S)Nz%s.inir)�pkg_namerrr�pkg_to_filename�rjrlcs�|r�fdd�|D�}n�g}t�}|�|�}t|�dks%tdt|���t|�}i}|�d�r@|�d�D]
\}}t|�||<q5dd�|�	�D�}	i}
i}|	D]$}i}
|�
|d�ra|�|d�||<|�|�D]\}}||
|<qf|
|
|<qO|||
|fS)Ncsg|]	}tj�|���qSr)�os�pathrH)rJr+��filenamerrrM�sz parse_config.<locals>.<listcomp>�zCould not find file(s) %sr_cSsg|]}|dvr|�qS))rbr_r)rJ�srrrrMrNr4)r�readr&r�strrercrPr1r8�
has_option�get)rp�dirs�	filenamesrd�nrbr7r2rY�secsr8r4rrr+rror�parse_config�s.



r{cs���fdd���|�\}}}}d|vr:d|vr:|d}|tjvr*td||df��tj|}ttj�|j��|d<t|d|d|d|t	|�d	�S)
Ncs�t|��\}}}}|��D]8\}}�t|��\}}}	}
|��D]\}}||vr+|||<q|	|��D]\}
}|rD|||
d|7<q2q
||||fS)Nz %s)r{rPrl)�frbr7r8�reqs�rname�rvalue�nmeta�nvars�	nsections�nreqsrKrL�oname�ovalue��_read_configrwrrr�s���z&_read_config_imp.<locals>._read_config�pkgdir�pkgnamez-You should import %s to get information on %sr2r3r5)r2r3r5r8r7)
�sys�modules�
ValueErrorr1rmrn�dirname�__file__rr)rxrwrbr7r8r}r��modrr�r�_read_config_imps

�
�r�cCs8zt|WStytt|�|�}|t|<|YSw)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�rl)r�rwrLrrrrFs'
�r�__main__)�OptionParserz--cflagsr?�
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
--list-all�list_allz--define-variable�define_variablez%Replace variable with the given valuer$z(Expect package name on the command line:z*.iniz
%s	%s - %srq�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�rVrm�configparserr�__all__rWr\�OSErrorrrrr1rrrerfrirlr{r�r�rr�optparser��glob�parser�
add_option�
parse_args�argv�options�argsr&r�r��filesr|�info�printr2r3rk�environrvr+rCr�r]rI�grouprYr7r?rEr5r�rrrr�<module>s�
*HD

$(

3
�
��
��
��




�;