skillfed

PyPgConfig

Access pg_config from Python

pypgconfig v0.1.0a2 99.0K downloads/30d#13,046 on PyPI0
Permissive license Apache License, Version 2.0 DORMANT released

What it is and what it does

PyPgConfig is a thin Python wrapper around the PostgreSQL pg_config utility. It runs pg_config on the system and parses its output to expose PostgreSQL metadata—version number (with major/minor breakdown), linked libraries, and build-time options like Python support—as Python objects and attributes.

The package is useful when you need to programmatically discover PostgreSQL installation details at runtime, such as which libraries PostgreSQL was compiled with or whether Python support is enabled. It requires that PostgreSQL and pg_config be installed on the system where the code runs.

Use it for:

  • Detect PostgreSQL version at runtime to conditionally enable or disable features in a Python application.
  • Query which libraries PostgreSQL was compiled with to verify compatibility before attempting a connection.
  • Locate the Python installation path that PostgreSQL was built with to ensure consistent Python environments.
  • Automate build or deployment scripts that need to confirm PostgreSQL is installed and inspect its configuration.
  • Validate PostgreSQL build options (e.g., Python support) before initializing a database client.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

PyPgConfig detects and exposes PostgreSQL configuration details from the system's pg_config tool, allowing Python code to query PostgreSQL version, library dependencies, and build settings.

Yes, if you need to programmatically query PostgreSQL configuration at runtime and can accept an alpha-stage, dormant package. The low install friction and permissive license are in its favor, and there are no known vulnerabilities. However, the lack of updates since 2023-11-28 and alpha status mean you should verify it works with your PostgreSQL version and be prepared to maintain a fork if needed.

Install

pypgconfig on PyPI

pip

pip install pypgconfig

uv

uv add pypgconfig

poetry

poetry add pypgconfig

Installing PyPgConfig

Before you install

Installation is straightforward with low friction—the package is a pure Python wheel with only setuptools and pip as runtime dependencies. However, the project is dormant; the last commit was 2023-11-28 and no updates have been released since the initial 0.1.0a2 alpha version.

License in practice

Licensed under Apache License, Version 2.0 (permissive), so you may use, modify, and distribute the package freely in commercial and private projects, provided you include a copy of the license.

Quickstart

pip install PyPgConfig

from pypgconfig import detect

pgconf = detect()
pgconf.version  # "15.4"
pgconf.libs  # ["pgcommon", "pgport", "lz4", "xml2"]

PostgreSQL and pg_config must be installed on the system where this code runs.

Verify before relying

  • Whether detect() raises an exception or returns a specific value if pg_config is not found.
  • Whether the package works with PostgreSQL versions other than the 15.4 example shown.
  • Stability guarantees for the 0.1.0a2 alpha release and whether a stable 1.0 is planned.

Package facts

License Apache License, Version 2.0 (permissive)
Python support supports the current Python release (>=3.7)
Install friction low — pure-Python wheel
Runtime dependencies 2 — setuptools, pip
Maintenance dormant — 991 days since the last release
Last repo commit
First released
Downloads 98,966/month — #13,046 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: PyPgConfig-0.1.0a2-py3-none-any.whl

Tags

postgres configuration detectionpg_config python wrapperpostgresql version detectionquery postgres build infopostgresql library discoverypostgres installation detailspg_config from python
postgres-integrationsystem-discovery

More Database packages