How to use the pkgconfig.installed function in pkgconfig

To help you get started, we’ve selected a few pkgconfig examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ufo-kit / ufo-core / python / setup.py View on Github external
import os
import sys
import subprocess
import pkgconfig
import numpy
from setuptools import setup, Extension


VERSION = '1.1.0'


if not pkgconfig.installed('pygobject-3.0', '>=3.2.2') and \
   not pkgconfig.installed('pygobject-2.0', '>=2.28'):
    sys.exit("You must install pygobject-2.0 or pygobject-3.0")

if not pkgconfig.installed('ufo', '>=0.4.0'):
    sys.exit("You must install ufo>=0.4.0")

def listify(d):
    return {k: list(v) for k, v in d.items()}

build_flags = listify(pkgconfig.parse('pygobject-3.0 ufo'))

build_flags['include_dirs'].append(numpy.get_include())
build_flags['extra_compile_args'] = ['-std=c99']

setup(
    name='ufo',
    version=VERSION,
github ufo-kit / ufo-core / python / setup.py View on Github external
import os
import sys
import subprocess
import pkgconfig
import numpy
from setuptools import setup, Extension


VERSION = '1.1.0'


if not pkgconfig.installed('pygobject-3.0', '>=3.2.2') and \
   not pkgconfig.installed('pygobject-2.0', '>=2.28'):
    sys.exit("You must install pygobject-2.0 or pygobject-3.0")

if not pkgconfig.installed('ufo', '>=0.4.0'):
    sys.exit("You must install ufo>=0.4.0")

def listify(d):
    return {k: list(v) for k, v in d.items()}

build_flags = listify(pkgconfig.parse('pygobject-3.0 ufo'))

build_flags['include_dirs'].append(numpy.get_include())
build_flags['extra_compile_args'] = ['-std=c99']

setup(
    name='ufo',
github ufo-kit / ufo-core / python / setup.py View on Github external
import os
import sys
import subprocess
import pkgconfig
import numpy
from setuptools import setup, Extension


VERSION = '1.1.0'


if not pkgconfig.installed('pygobject-3.0', '>=3.2.2') and \
   not pkgconfig.installed('pygobject-2.0', '>=2.28'):
    sys.exit("You must install pygobject-2.0 or pygobject-3.0")

if not pkgconfig.installed('ufo', '>=0.4.0'):
    sys.exit("You must install ufo>=0.4.0")

def listify(d):
    return {k: list(v) for k, v in d.items()}

build_flags = listify(pkgconfig.parse('pygobject-3.0 ufo'))

build_flags['include_dirs'].append(numpy.get_include())
build_flags['extra_compile_args'] = ['-std=c99']

setup(
    name='ufo',
    version=VERSION,
    author='Matthias Vogelgesang',
    author_email='matthias.vogelgesang@kit.edu',
    url='http://ufo.kit.edu',
github python-lz4 / python-lz4 / setup.py View on Github external
def pkgconfig_installed_check(lib, required_version, default):
        installed = default
        try:
            installed = pkgconfig_installed(lib, required_version)
        except EnvironmentError:
            # Windows, no pkg-config present
            pass
        except ValueError:
            # pkgconfig was unable to determine if
            # required version of liblz4 is available
            # Bundled version of liblz4 will be used
            pass
        return installed
    liblz4_found = pkgconfig_installed_check('liblz4', LZ4_REQUIRED_VERSION, default=False)
github borgbackup / borg / setup_b2.py View on Github external
def b2_ext_kwargs(prefer_system):
    if prefer_system:
        system_prefix = os.environ.get('BORG_LIBB2_PREFIX')
        if system_prefix:
            print('Detected and preferring libb2 [via BORG_LIBB2_PREFIX]')
            return dict(include_dirs=[os.path.join(system_prefix, 'include')],
                        library_dirs=[os.path.join(system_prefix, 'lib')],
                        libraries=['b2'])

        import pkgconfig

        if pkgconfig.installed('libb2', '>= 0.98.1'):
            print('Detected and preferring libb2 [via pkg-config]')
            return pkgconfig.parse('libb2')

    print('Using bundled BLAKE2')
    sources = multi_join(b2_sources, bundled_path)
    include_dirs = multi_join(b2_includes, bundled_path)
    define_macros = [('BORG_USE_BUNDLED_B2', 'YES')]
    return dict(sources=sources, include_dirs=include_dirs, define_macros=define_macros)
github capnproto / pycapnp / setup.py View on Github external
def run(self):
        if force_bundled_libcapnp:
            need_build = True
        elif force_system_libcapnp:
            need_build = False
        else:
            # Try to use capnp executable to find include and lib path
            capnp_executable = shutil.which("capnp")
            if capnp_executable:
                self.include_dirs += [os.path.join(os.path.dirname(capnp_executable), '..', 'include')]
                self.library_dirs += [os.path.join(os.path.dirname(capnp_executable), '..', 'lib{}'.format(8 * struct.calcsize("P")))]
                self.library_dirs += [os.path.join(os.path.dirname(capnp_executable), '..', 'lib')]

            # Look for capnproto using pkg-config (and minimum version)
            try:
                if pkgconfig.installed('capnp', '>= 0.8.0'):
                    need_build = False
                else:
                    need_build = True
            except EnvironmentError:
                # pkg-config not available in path
                need_build = True

        if need_build:
            print(
                "*WARNING* no libcapnp detected or rebuild forced. "
                "Attempting to build it from source now. "
                "If you have C++ Cap'n Proto installed, it may be out of date or is not being detected. "
                "This may take a while..."
            )
            bundle_dir = os.path.join(_this_dir, "bundled")
            if not os.path.exists(bundle_dir):
github borgbackup / borg / setup_lz4.py View on Github external
def lz4_ext_kwargs(prefer_system):
    if prefer_system:
        system_prefix = os.environ.get('BORG_LIBLZ4_PREFIX')
        if system_prefix:
            print('Detected and preferring liblz4 [via BORG_LIBLZ4_PREFIX]')
            return dict(include_dirs=[os.path.join(system_prefix, 'include')],
                        library_dirs=[os.path.join(system_prefix, 'lib')],
                        libraries=['lz4'])

        import pkgconfig

        if pkgconfig.installed('liblz4', '>= 1.7.0'):
            print('Detected and preferring liblz4 [via pkg-config]')
            return pkgconfig.parse('liblz4')

    print('Using bundled LZ4')
    sources = multi_join(lz4_sources, bundled_path)
    include_dirs = multi_join(lz4_includes, bundled_path)
    define_macros = [('BORG_USE_BUNDLED_LZ4', 'YES')]
    return dict(sources=sources, include_dirs=include_dirs, define_macros=define_macros)
github libvips / pyvips / pyvips / pyvips_build.py View on Github external
# flake8: noqa

import pkgconfig
from cffi import FFI

# we must have the vips package to be able to do anything
if not pkgconfig.exists('vips'): 
    raise Exception('unable to find pkg-config package "vips"')
if pkgconfig.installed('vips', '< 8.2'):
    raise Exception('pkg-config "vips" is too old -- need libvips 8.2 or later')

ffibuilder = FFI()

ffibuilder.set_source("_libvips",
    r""" 
        #include 
    """, 
    **pkgconfig.parse('vips'))

# pkgconfig 1.5+ has modversion ... otherwise, use a small shim
try:
    from pkgconfig import modversion
except ImportError:
    def modversion(package):
        # will need updating once we hit 8.20 :(
github libvips / pyvips / pyvips / pyvips_build.py View on Github external
def modversion(package):
        # will need updating once we hit 8.20 :(
        for i in range(20, 3, -1):
            if pkgconfig.installed(package, '>= 8.' + str(i)):
                # be careful micro version is always set to 0
                return '8.' + str(i) + '.0'
        return '8.2.0'
github libvips / pyvips / pyvips / pyvips_build.py View on Github external
import pkgconfig

# we must have the vips package to be able to do anything
if not pkgconfig.exists('vips'): 
    raise Exception('unable to find pkg-config package "vips"')
if pkgconfig.installed('vips', '< 8.2'):
    raise Exception('pkg-config "vips" is too old -- need libvips 8.2 or later')

from cffi import FFI

ffibuilder = FFI()

# this is very hacky ... cffi in API mode won't let us cast function pointers,
# so we can't pass vips_free() as a vipsCallbackFn, which we need to be able to
# do when we set a blob
# 
# to fix this, we rename vips_free during the vips header load as
# real_vips_free, then declare a fake type ourselves that decl.py then hooks up
# to

ffibuilder.set_source("_libvips",
    r"""