{"id":1630,"library":"pkgconfig","title":"pkgconfig","description":"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.","status":"active","version":"1.6.0","language":"en","source_language":"en","source_url":"https://github.com/matze/pkgconfig","tags":["pkg-config","build system","c/c++","compiler flags","linker flags"],"install":[{"cmd":"pip install pkgconfig","lang":"bash","label":"Install pkgconfig"}],"dependencies":[],"imports":[{"symbol":"pkgconfig","correct":"import pkgconfig"}],"quickstart":{"code":"import pkgconfig\n\n# Check if a package exists\nif pkgconfig.exists('glib-2.0'):\n    print('glib-2.0 is installed.')\n\n    # Get CFLAGS for compilation\n    cflags = pkgconfig.cflags('glib-2.0')\n    print(f'CFlags: {cflags}')\n\n    # Get LIBS for linking\n    libs = pkgconfig.libs('glib-2.0')\n    print(f'Libs: {libs}')\n\n    # Get the package version\n    version = pkgconfig.modversion('glib-2.0')\n    print(f'Version: {version}')\n\n    # Parse all information into a dictionary\n    parsed_info = pkgconfig.parse('glib-2.0')\n    print(f'Parsed Info: {parsed_info}')\nelse:\n    print('glib-2.0 is not installed or not found by pkg-config.')\n\n# Example with a non-existent package to show handling\nif not pkgconfig.exists('nonexistent-library-xyz'):\n    print('nonexistent-library-xyz is not found, as expected.')","lang":"python","description":"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().`"},"warnings":[{"fix":"Ensure that the `pkg-config` command-line tool is installed on your operating system (e.g., `sudo apt install pkg-config` on Debian/Ubuntu, `brew install pkg-config` on macOS, or via MSYS2/MinGW on Windows).","message":"The Python `pkgconfig` library is a wrapper around the system's `pkg-config` command-line tool. It requires the `pkg-config` executable to be installed and available in the system's PATH. This library does not install `pkg-config` itself.","severity":"gotcha","affected_versions":"All versions"},{"fix":"If you need to define new packages for `pkg-config` to find, you must manually create and place `.pc` files in a directory included in `PKG_CONFIG_PATH`.","message":"This library only reads existing `.pc` files that `pkg-config` knows about. It does not provide functionality to install new `.pc` files or manage `pkg-config` package definitions. Its purpose is solely to query system-level `pkg-config` data.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Replace calls to `pkgconfig.VARIABLES` with `pkgconfig.parse('your_package')['Variables']`.","message":"The `pkgconfig.VARIABLES` attribute was removed in version 1.4.0. To access package variables, use the `pkgconfig.parse()` function and retrieve them from the returned dictionary via the `'Variables'` key (e.g., `pkgconfig.parse('foobar')['Variables']`).","severity":"deprecated","affected_versions":">=1.4.0"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}