--- id: pkgconfig version: "1.6.0" license: MIT license_treatment: permissive maintenance: active --- # pkgconfig — Interface Python with pkg-config License: permissive · Maintenance: active · Downloads: 6.6M/mo ## What it is and what it does pkgconfig is a Python wrapper around the pkg-config command-line tool that lets you query system package metadata programmatically. It exposes functions to check package existence, retrieve versions, extract compiler flags (CFLAGS) and linker flags (LDFLAGS), list all available packages, and parse multiple packages at once. The module is particularly useful in build scripts and setup.py files where you need to dynamically configure C extensions based on installed system libraries. The package requires Python 3.9 or later and has no Python dependencies—it simply shells out to pkg-config or pkgconf on the system. It is licensed under MIT and marked as production/stable, with active maintenance and support for current Python versions through 3.14. Use it for: - Configure C extension builds in setup.py by querying CFLAGS and LDFLAGS for system libraries like GTK or GLib. - Check whether required system packages are installed and meet version constraints before proceeding with installation or build. - Discover all available pkg-config packages on a system and extract their metadata for dependency resolution. - Parse multiple packages in one call to build a unified set of compiler and linker flags for complex multi-library projects. - Extract custom variables defined in .pc files for packages that expose non-standard build metadata. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. pkgconfig wraps the pkg-config command-line tool to query system package metadata—versions, compiler flags, library paths—from Python code, typically for use in build scripts and extension configuration. Yes. pkgconfig is a lightweight, stable, actively maintained wrapper with no Python dependencies and permissive licensing. Install it if you need to query system package metadata from Python—especially in build scripts or when configuring C extensions. The only prerequisite is that pkg-config or pkgconf be installed on the system; if that's not available, the module will raise an error at runtime. ## Install pip install pkgconfig uv add pkgconfig poetry add pkgconfig ## Installing pkgconfig Before you install: Low friction: pure Python wheel with no runtime dependencies. Actively maintained as of March 2026, supporting Python 3.9 through 3.14. Repository shows recent activity and the project is marked production/stable. License in practice: MIT license (permissive) means you can use, modify, and distribute this package freely in commercial or open-source projects with minimal restrictions—just retain the license notice. Quickstart: import pkgconfig # Check if a package exists if pkgconfig.exists('glib-2.0'): version = pkgconfig.modversion('glib-2.0') cflags = pkgconfig.cflags('glib-2.0') libs = pkgconfig.libs('glib-2.0') print(f"Version: {version}, CFLAGS: {cflags}, LIBS: {libs}") Requires pkg-config or pkgconf command-line tool to be installed and on PATH; raises EnvironmentError if not found. Verify before relying: - Whether the package handles all edge cases in pkg-config output parsing across different versions of pkg-config and pkgconf. - Performance characteristics when querying large numbers of packages or complex dependency trees. ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 6.6M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags pkg-config wrapper python, query system libraries metadata, cflags ldflags from python, build extension configuration, check installed package versions, parse pkg-config output, system package discovery, build-tools, system-integration [View on SkillFed](https://skillfed.io/packages/pkgconfig) · [View on PyPI](https://pypi.org/project/pkgconfig/)