pkgconfig

1.6.0 · active · verified Thu Apr 09

pkgconfig is a Python library that provides a simple interface to the `pkg-config` command-line tool. It allows Python applications to query installed libraries for their build flags (Cflags, Libs) and version information, making it easier to build and link against external C/C++ libraries. The current version is 1.6.0, and it has an infrequent release cadence, typically releasing new versions only when significant updates or fixes are needed.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to check for a package's existence, retrieve its CFLAGS and LIBS, get its version, and parse all available information into a dictionary using `pkgconfig.parse().`

import pkgconfig

# Check if a package exists
if pkgconfig.exists('glib-2.0'):
    print('glib-2.0 is installed.')

    # Get CFLAGS for compilation
    cflags = pkgconfig.cflags('glib-2.0')
    print(f'CFlags: {cflags}')

    # Get LIBS for linking
    libs = pkgconfig.libs('glib-2.0')
    print(f'Libs: {libs}')

    # Get the package version
    version = pkgconfig.modversion('glib-2.0')
    print(f'Version: {version}')

    # Parse all information into a dictionary
    parsed_info = pkgconfig.parse('glib-2.0')
    print(f'Parsed Info: {parsed_info}')
else:
    print('glib-2.0 is not installed or not found by pkg-config.')

# Example with a non-existent package to show handling
if not pkgconfig.exists('nonexistent-library-xyz'):
    print('nonexistent-library-xyz is not found, as expected.')

view raw JSON →