Skip to main content

Interface Python with pkg-config

Project description

https://travis-ci.org/matze/pkgconfig.png?branch=master

pkgconfig is a Python module to interface with the pkg-config command line tool and supports Python 2.6+ and 3.3+.

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 equivalent pkg-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.

Changelog

Version 1.5.3

  • Add configure_extension API

Version 1.5.2

  • Update poetry dep

  • Improve CI

Version 1.5.0

  • 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

Version 1.4.0

  • Add boolean static keyword to output private libraries as well

  • Raise original OSError as well

Version 1.3.1

  • Fix compatibility problems with Python 2.6

Version 1.3.0

  • 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

Version 1.2.1 and 1.2.2

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

Version 1.2.0

Released on November 30th 2016.

  • Potential break: switch from result set to list

  • Expose –list-all query

  • Added support for PKG_CONFIG environment variable

Version 1.1.0

Released on November 6th 2013.

  • Multiple packages can now be parsed with a single call to .parse.

Version 1.0.0

First release on September 8th 2013.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pkgconfig-1.5.3.tar.gz (6.1 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pkgconfig-1.5.3-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

pkgconfig-1.5.3-py2.py3-none-any.whl (6.7 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pkgconfig-1.5.3.tar.gz.

File metadata

  • Download URL: pkgconfig-1.5.3.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.6 CPython/3.8.5 Linux/5.8.0-50-generic

File hashes

Hashes for pkgconfig-1.5.3.tar.gz
Algorithm Hash digest
SHA256 41fb65d14fa918cedd7e205d95331162692dad2edee1441b485665b1f69a61c7
MD5 912b527f60458877174a9f9c0359394b
BLAKE2b-256 9a8a600d7e96368a86c713002630be1dd069b9905a7a7854a59641acc2e753cd

See more details on using hashes here.

File details

Details for the file pkgconfig-1.5.3-py3-none-any.whl.

File metadata

  • Download URL: pkgconfig-1.5.3-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.6 CPython/3.8.5 Linux/5.8.0-50-generic

File hashes

Hashes for pkgconfig-1.5.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ad69adc5afe0b9d975c655daea815a21fb5fe31f3bb55fe67ea7a8ffd20e8781
MD5 0a362bca8b3b392f20cf44d4d8f401e5
BLAKE2b-256 14bfade532c7425d2f03c530c2727139dca1775aff0ccac4d819f61c1a15ad83

See more details on using hashes here.

File details

Details for the file pkgconfig-1.5.3-py2.py3-none-any.whl.

File metadata

  • Download URL: pkgconfig-1.5.3-py2.py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.6 CPython/3.8.5 Linux/5.8.0-50-generic

File hashes

Hashes for pkgconfig-1.5.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a83df65ef71c3ac451b5b99ebc095174efd7a2c856561475bfe80abf75c260e8
MD5 dff198003991180b10a177adbe1a8b36
BLAKE2b-256 0179f28adde15a7e10985e5f63f4d079ccc9d59fa4627fa1db6bf1c604448712

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page