1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
U
O±da4ã@s¸ddlZddlZddlZddlmZddddddgZe d    ¡ZGd
d„deƒZ    Gd d„deƒZ
d d„Z d d„Z Gdd„dƒZ Gdd„dƒZdd„Zdd„Zdd„Zdd„ZdBdd„ZdCdd„ZiZdDdd„Zedkr´ddlmZddlZeƒZejd d!d"d#d$ejd%d&d"d'd$ejd(d)d*d+ejd,d-d"d.d$ejd/d0d1d+ejd2d3d"d1d$ejd4d5d6d+e ej¡\ZZ e!e ƒd7krŽe"d8ƒ‚ej#rÌe d9¡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 0d@ej/¡Z1e1s@e"dAƒ‚ne1 2d;¡Z(e1 2d7¡Z3e3e&j4e(<ej5rte'e& 5e.¡ƒej6rŠe'e& 6e.¡ƒej7rœe'e&j7ƒej8r´e'e&j7ej8kƒdS)EéN)ÚRawConfigParserÚ FormatErrorÚ PkgNotFoundÚ LibraryInfoÚ VariableSetÚ read_configÚ parse_flagsz\$\{([a-zA-Z0-9_-]+)\}c@s eZdZdZdd„Zdd„ZdS)rzQ
    Exception thrown when there is a problem parsing a configuration file.
 
    cCs
||_dS©N©Úmsg©Úselfr ©rúUd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\numpy/distutils/npy_pkg_config.pyÚ__init__szFormatError.__init__cCs|jSr    r
©r rrrÚ__str__szFormatError.__str__N©Ú__name__Ú
__module__Ú __qualname__Ú__doc__rrrrrrr sc@s eZdZdZdd„Zdd„ZdS)rz3Exception raised when a package can not be located.cCs
||_dSr    r
r rrrrszPkgNotFound.__init__cCs|jSr    r
rrrrrszPkgNotFound.__str__NrrrrrrscCsægggggdœ}d| d¡}|D]¾}d|}t|ƒdkr"| d¡r`|d |dd    … ¡¡q"| d
¡r†|d  |dd    … ¡¡q"| d ¡r¬|d  |dd    … ¡¡q"| d¡rÒ|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-Drr)ÚsplitÚlenÚ
startswithÚappendÚstrip)ÚlineÚdÚflagsÚflagrrrrs$ÿ 
 
 
 
cCs | dd¡S)Nú\z\\)Úreplace)ÚvalrrrÚ_escape_backslashIsr,c@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)r r-r.r0Úsectionsr2r/rrrrgszLibraryInfo.__init__cCst|j ¡ƒS)zÚ
        Return the section headers of the config file.
 
        Parameters
        ----------
        None
 
        Returns
        -------
        keys : list of str
            The list of section headers.
 
        )Úlistr1Úkeysrrrrr3rszLibraryInfo.sectionsÚdefaultcCs|j |j|d¡}t|ƒS)NÚcflags©r2Ú interpolater1r,©r Úsectionr+rrrr7‚szLibraryInfo.cflagscCs|j |j|d¡}t|ƒS)NÚlibsr8r:rrrr<†szLibraryInfo.libscCsVd|jd|jg}|jr&| d¡n| dd |j¡¡| d|j¡d |¡S)NzName: %szDescription: %sz    Requires:z Requires: %sú,z Version: %sÚ
)r-r.r/r#Újoinr0)r ÚmrrrrŠs  zLibraryInfo.__str__)N)r6)r6)    rrrrrr3r7r<rrrrrrLs 
 
 
c@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>¢sz(VariableSet.__init__.<locals>.<listcomp>)ÚdictÚitemsÚ    _raw_dataÚ_reÚ_re_subÚ _init_parse)r r&rrrr¡szVariableSet.__init__cCs$|j ¡D]\}}| ||¡q
dSr    )rGrFÚ_init_parse_var)r rBrCrrrrJ©szVariableSet._init_parsecCs"t d|¡|j|<||j|<dS)Nz\$\{%s\})ÚreÚcompilerHrI©r r-ÚvaluerrrrK­szVariableSet._init_parse_varcs2‡fdd„}t |¡r.||ƒ}||kr(q.|}q |S)Ncs,ˆj ¡D]}ˆj| ˆj||¡}q
|Sr    )rHr5ÚsubrI)rOrBrrrÚ _interpolate´sz-VariableSet.interpolate.<locals>._interpolate)Ú_VARÚsearch)r rOrQZnvaluerrrr9±s 
zVariableSet.interpolatecCst|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.
 
        )r4rGr5rrrrÚ    variablesÀszVariableSet.variablescCs
|j|Sr    )rG)r r-rrrÚ __getitem__ÑszVariableSet.__getitem__cCs||j|<| ||¡dSr    )rGrKrNrrrÚ __setitem__Ôs
zVariableSet.__setitem__N) rrrrrrJrKr9rTrUrVrrrrr”s cCsR| d¡stdƒ‚t| d¡ƒ}dD]}||kr$td|ƒ‚q$d|krNg|d<|S)NÚmetazNo meta section found !)r-r.r0z6Option %s (section [meta]) is mandatory, but not foundr/)Ú has_sectionrrErF)Úconfigr&rBrrrÚ
parse_metaØs
ÿrZcCs:| d¡stdƒ‚i}| d¡D]\}}|||<q t|ƒS)NrTzNo variables section found !)rXrrFr)rYr&r-rOrrrÚparse_variablesès 
 
r[cCsttfSr    )Zmeta_dÚr)rYrrrÚparse_sectionsósr]cCsd|S)Nz%s.inir)Úpkg_namerrrÚpkg_to_filenameösr_csô|r‡fdd„|Dƒ}nˆg}tƒ}| |¡}t|ƒdksJtdt|ƒƒ‚t|ƒ}i}| d¡r€| d¡D]\}}t|ƒ||<qjdd„|     ¡Dƒ}    i}
i} |    D]H} i} | 
| d¡rÂ|  | d¡| | <| | ¡D]\}}|| |<qÌ| |
| <qž|||
| fS)Ncsg|]}tj |ˆ¡‘qSr)ÚosÚpathr?)rAr&©ÚfilenamerrrDûsz parse_config.<locals>.<listcomp>ézCould not find file(s) %srTcSsg|]}|dkr|‘qS))rWrTr)rAÚsrrrrDsr/) rÚreadr!rÚstrrZrXrFr,r3Ú
has_optionÚget)rcÚdirsÚ    filenamesrYÚnrWr2r-rOZsecsr3r/rer&rrbrÚ parse_configùs.
 
 
 
rmcs–‡‡fdd„‰ˆ|ƒ\}}}}d|krtd|krt|d}|tjkrTtd||dfƒ‚tj|}ttj |j¡ƒ|d<t|d|d|d|t    |ƒd    S)
Ncs˜t|ˆƒ\}}}}| ¡D]p\}}ˆt|ƒƒ\}}}    }
| ¡D]\} } | |kr>| || <q>|    | ¡D]$\} }|rd||| d|7<qdq||||fS)Nz %s)rmrFr_)ÚfrWr2r3ÚreqsÚrnameZrvalueZnmetaZnvarsZ    nsectionsZnreqsrBrCZonameZovalue©Ú _read_configrjrrrrs
z&_read_config_imp.<locals>._read_configZpkgdirÚpkgnamez-You should import %s to get information on %sr-r.r0)r-r.r0r3r2)
ÚsysÚmodulesÚ
ValueErrorr,r`raÚdirnameÚ__file__rr)rkrjrWr2r3rorsÚmodrrqrÚ_read_config_imps
 
ÿ
ÿrzcCs>z
t|WStk
r8tt|ƒ|ƒ}|t|<|YSXdS)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
 
    N)Ú_CACHEÚKeyErrorrzr_)rsrjrCrrrrFs '
Ú__main__)Ú OptionParserz--cflagsr7Ú
store_truez*output all preprocessor and compiler flags)ÚdestÚactionÚhelpz--libsr<zoutput all linker flagsz --use-sectionr;z/use this section instead of default for options)r€r‚z    --versionr0zoutput versionz--atleast-versionÚ min_versionzMinimal versionz
--list-allÚlist_allz--define-variableÚdefine_variablez%Replace variable with the given valuerz(Expect package name on the command line:z*.iniz
%s    %s - %srdZNPY_PKG_CONFIG_PATHznumpy/core/lib/npy-pkg-configÚ.r6z([\S]+)=([\S]+)zH--define-variable option should be of the form --define-variable=foo=bar)N)N)N)9rtrLr`Ú configparserrÚ__all__rMrRÚOSErrorrrrr,rrrZr[r]r_rmrzr{rrÚoptparser~ÚglobÚparserÚ
add_optionÚ
parse_argsÚargvÚoptionsÚargsr!rvr„ÚfilesrnÚinfoÚprintr-r.r^Úenvironrir&r;r…rSr@ÚgrouprOr2r7r<r0rƒrrrrÚ<module>sœ ÿ
 *HD 
$
(
3
 
ÿ
ÿÿ
ÿÿ
ÿÿ