pkgconfig
is a Python module to interface with the pkg-config
command line tool for Python 3.9+.
It can be used to
find all pkg-config packages
>>> packages = pkgconfig.list_all()
check if a package exists
>>> pkgconfig.exists('glib-2.0') True
check if a package meets certain version requirements
>>> pkgconfig.installed('glib-2.0', '< 2.26') False
return the version
>>> pkgconfig.modversion('glib-2.0') '2.56.3'
query CFLAGS and LDFLAGS
>>> pkgconfig.cflags('glib-2.0') '-I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include' >>> pkgconfig.libs('glib-2.0') '-lglib-2.0'
get all variables defined for a package:
>>> pkgconfig.variables('glib-2.0') {u'exec_prefix': u'/usr'}
parse the output to build extensions with setup.py
>>> d = pkgconfig.parse('glib-2.0 gtk+-2.0') >>> d['libraries'] [u'gtk+-2.0', u'glib-2.0']
or
>>> ext = Extension('foo', ['foo.c']) >>> # sets extension attributes as needed >>> pkgconfig.configure_extension(ext, 'glib-2.0 gtk+-2.0')
The
pkgconfig.parse
function returns a dictonary of lists. The lists returned are accurate representations of the equivalentpkg-config
call's result, both in content and order.
If pkg-config
is not on the path, raises EnvironmentError
.
The pkgconfig
module is licensed under the MIT license.
- Drop support for Python < 3.9, support 3.9, 3.10, 3.11, 3.12.
- Switch CI from travis to github actions, test on all supported Python versions.
- Use src/ layout for project, fixes #36. Also move tests and test data to tests/.
- Replace deprecated distutils by setuptools to make tests work on py312, fixes #64.
- Fix configure_extension for empty cflags or libs.
- Make tests more robust by sorting
- Adjust pyproject.toml and drop Python 2 support
- Add
configure_extension
API
- Update poetry dep
- Improve CI
- Use poetry instead of setuptools directly
- Fix #42: raise exception if package is missing
- Fix version parsing for openssl-like version numbers, fixes #32
- Fix #31: expose --modversion
- Fix #30: strip whitespace from variable names
- Add boolean
static
keyword to output private libraries as well - Raise original
OSError
as well
- Fix compatibility problems with Python 2.6
- Add variables() API to query defined variables
- Disable Python 3.2 and enable Python 3.5 and 3.6 tests
- Fix #16: handle spaces of values in .pc files correctly
Bug fix releases released on December 1st and 2nd 2016.
- Include the
data
folder in the distribution in order to run tests - Improve the tests
Released on November 30th 2016.
- Potential break: switch from result set to list
- Expose --list-all query
- Added support for PKG_CONFIG environment variable
Released on November 6th 2013.
- Multiple packages can now be parsed with a single call to
.parse
.
First release on September 8th 2013.