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, sho
(pkgname, dirs=None)
| 324 | # problem in practice |
| 325 | _CACHE = {} |
| 326 | def read_config(pkgname, dirs=None): |
| 327 | """ |
| 328 | Return library info for a package from its configuration file. |
| 329 | |
| 330 | Parameters |
| 331 | ---------- |
| 332 | pkgname : str |
| 333 | Name of the package (should match the name of the .ini file, without |
| 334 | the extension, e.g. foo for the file foo.ini). |
| 335 | dirs : sequence, optional |
| 336 | If given, should be a sequence of directories - usually including |
| 337 | the NumPy base directory - where to look for npy-pkg-config files. |
| 338 | |
| 339 | Returns |
| 340 | ------- |
| 341 | pkginfo : class instance |
| 342 | The `LibraryInfo` instance containing the build information. |
| 343 | |
| 344 | Raises |
| 345 | ------ |
| 346 | PkgNotFound |
| 347 | If the package is not found. |
| 348 | |
| 349 | See Also |
| 350 | -------- |
| 351 | misc_util.get_info, misc_util.get_pkg_info |
| 352 | |
| 353 | Examples |
| 354 | -------- |
| 355 | >>> npymath_info = np.distutils.npy_pkg_config.read_config('npymath') |
| 356 | >>> type(npymath_info) |
| 357 | <class 'numpy.distutils.npy_pkg_config.LibraryInfo'> |
| 358 | >>> print(npymath_info) |
| 359 | Name: npymath |
| 360 | Description: Portable, core math library implementing C99 standard |
| 361 | Requires: |
| 362 | Version: 0.1 #random |
| 363 | |
| 364 | """ |
| 365 | try: |
| 366 | return _CACHE[pkgname] |
| 367 | except KeyError: |
| 368 | v = _read_config_imp(pkg_to_filename(pkgname), dirs) |
| 369 | _CACHE[pkgname] = v |
| 370 | return v |
| 371 | |
| 372 | # TODO: |
| 373 | # - implements version comparison (modversion + atleast) |