pkgconfig
Interface Python with pkg-config
Decision gist · record as of 2026-08-14
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.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires pkg-config or pkgconf command-line tool to be installed and on PATH; raises EnvironmentError if not found.
- Low friction: pure Python wheel with no runtime dependencies.
- Actively maintained as of March 2026, supporting Python 3.9 through 3.14.
License · maintenance · safety
MIT (permissive) — 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.
last release 2026-03-06 (161 days) · last repo commit 2026-03-06 · 64 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 6,648,684 downloads/mo, #1,875 on PyPI
Alternatives
Verify before relying
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}")- 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.
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 on this page. Verify before relying on it.
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
pkgconfig on PyPI
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.
Requires pkg-config or pkgconf command-line tool to be installed and on PATH; raises EnvironmentError if not found.
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}")
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 the current Python release <4.0.0,>=3.9.0 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Actively maintained 161 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 6,648,684 / month, #1,875 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.9Topic :: Software Development :: Build Tools |
Evidence: pkgconfig-1.6.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “pkg-config wrapper python”
- pkgconfigpkgconfig wraps the pkg-config command-line tool to query system…
- colcon-pkg-configExtends colcon-core to configure environment variables for locating…
- pkgconfpkgconf is a cross-platform Python package that distributes the…
Give your agent the search over MCP, or paste the wish link into any chat.
More Build Tools packages
Provides reusable utilities for Python packaging interoperability, including version handling, specifiers, markers, requirements, tags, and metadata parsing according to standards like PEP 440 and PEP 425.
Wraps any iterable to display a real-time progress bar in the terminal or Jupyter notebook, showing iteration count, elapsed time, and estimated time remaining.
pip is the standard installer for Python packages, enabling you to download and install packages from the Python Package Index and other indexes into your Python environment.
Hatchling is a standards-compliant Python build backend that handles packaging, metadata, and distribution of Python projects when configured in a project's pyproject.toml file.
Generates Python gRPC service stubs and message classes from Protocol Buffer definitions, enabling developers to build gRPC clients and servers.
pre-commit is a framework for installing and running git hooks written in any language before commits are made, automating code quality and validation checks across multi-language projects.
Install it if your team needs consistent, automated validation at commit time.
See also pkgconf · colcon-pkg-config · distribute · setuptools · mysqlclient · setuptools-git-versioning · donfig · pyconfigurator · setuptools-git · single-source