How to use the pkgconfig.libs 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 matze / pkgconfig / test_pkgconfig.py View on Github external
def test_libs():
    flags = pkgconfig.libs(PACKAGE_NAME)

    for flag in flags.split(' '):
        assert flag in ('-L/usr/lib_gtk_foo', '-lgtk-3')

    with pytest.raises(pkgconfig.PackageNotFoundError):
        pkgconfig.libs('doesnotexist')
github omni-us / pagexml / py-textfeat / setup.py View on Github external
def textfeat_Extension(magick=False):
    import pkgconfig
    libs = ['opencv','libxml-2.0','Magick++']
    compile_args = ['-std=c++11']
    link_args = []
    for lib in libs:
        if not pkgconfig.exists(lib):
            raise FileNotFoundError('pkgconfig did not find '+lib)
        compile_args += pkgconfig.cflags(lib).split()
        link_args += pkgconfig.libs(lib).split()
    #compile_args += pkgconfig.cflags('opencv').split()
    #cvre = re.compile('^-L|^-lopencv_core|^-lopencv_imgproc|^-lopencv_imgcodecs|^-lopencv_flann')
    #link_args += [x for x in pkgconfig.libs('opencv').split() if cvre.match(x)]
    cvinc = pkgconfig.cflags('opencv').split()[0].rsplit('/opencv',1)[0]
    defimage = '__PAGEXML_IMG_MAGICK__' if magick else '__PAGEXML_IMG_CV__'
    pageimage = 'Magick::Image' if magick else 'cv::Mat'
    define_macros = [(defimage,''),('__PAGEXML_MAGICK__','')]
    swig_opts = ['-D'+defimage,'-DPageImage='+pageimage,'-D__PAGEXML_MAGICK__']
    print('textfeat_Extension configured with '+defimage)
    return Extension('_textfeat',
                     define_macros = define_macros + [('SWIG_PYTHON_SILENT_MEMLEAK','')],
                     extra_compile_args = compile_args,
                     extra_link_args = link_args,
                     swig_opts = swig_opts + [cvinc,'-modern','-keyword','-c++'],
                     sources = ['textfeat/TextFeatExtractor.i','textfeat/TextFeatExtractor.cc','textfeat/intimg.cc','textfeat/mem.cc'])
github limbo018 / DREAMPlace / dreamplace / ops / draw_place / src / setup.py View on Github external
import sys
import pkgconfig

boost_dir = os.environ['BOOST_DIR']
limbo_dir = os.environ['LIMBO_DIR']
utility_dir = os.environ['UTILITY_DIR']
ops_dir = os.environ['OPS_DIR']

include_dirs = [os.path.join(os.path.abspath(boost_dir), 'include'), os.path.join(os.path.abspath(limbo_dir), 'include'), os.path.abspath(ops_dir)]
lib_dirs = [os.path.join(os.path.abspath(boost_dir), 'lib'), os.path.join(os.path.abspath(limbo_dir), 'lib'), utility_dir]
libs = ['gdsparser', 'boost_iostreams', 'z', 'utility'] 

if pkgconfig.exists('cairo'):
    print("found cairo and enable")
    include_dirs.append(pkgconfig.cflags('cairo')[2:])
    libs.append(pkgconfig.libs('cairo')[2:])
    cairo_compile_args = '-DDRAWPLACE=1'
else:
    print("not found cairo and disable")
    cairo_compile_args = '-DDRAWPLACE=0'

tokens = str(torch.__version__).split('.')
torch_major_version = "-DTORCH_MAJOR_VERSION=%d" % (int(tokens[0]))
torch_minor_version = "-DTORCH_MINOR_VERSION=%d" % (int(tokens[1]))

setup(
        name='draw_place',
        ext_modules=[
            CppExtension('draw_place_cpp', 
                [
                    'draw_place.cpp', 
                    ],
github python-lz4 / python-lz4 / setup.py View on Github external
]
    )

if py3c_found is False:
    include_dirs.append('py3c')

compiler = ccompiler.get_default_compiler()

extra_link_args = []
extra_compile_args = []

if compiler == 'msvc':
    extra_compile_args = ['/Ot', '/Wall', '/wd4711', '/wd4820']
elif compiler in ('unix', 'mingw32'):
    if liblz4_found:
        extra_link_args.append(pkgconfig_libs('liblz4'))
        if pkgconfig_cflags('liblz4'):
            extra_compile_args.append(pkgconfig_cflags('liblz4'))
    else:
        extra_compile_args = [
            '-O3',
            '-Wall',
            '-Wundef'
        ]
else:
    print('Unrecognized compiler: {0}'.format(compiler))
    sys.exit(1)

lz4version = Extension('lz4._version',
                       lz4version_sources,
                       extra_compile_args=extra_compile_args,
                       extra_link_args=extra_link_args,
github GuLinux / AstroPhoto-Plus / backend / image_processing / setup.py View on Github external
import pkgconfig
import os


opencv_names = ['opencv', 'opencv3', 'opencv4', 'opencv2']
opencv = None

for name in opencv_names:
    if not opencv and pkgconfig.exists(name):
        opencv = name

if not opencv:
    raise RuntimeError('Opencv not found')

opencv_cflags = pkgconfig.cflags(opencv)
opencv_ldflags = pkgconfig.libs(opencv)

include_dirs = [x[2:] for x in opencv_cflags.split(' ') if x.startswith('-I')]
include_dirs.append('/usr/include/CCfits')
include_dirs.append('/usr/local/include/CCfits')
 

library_dirs = set(['/usr/lib'])
libraries=['CCfits']


cflags = [x for x in opencv_cflags.split(' ') if not x.startswith('-I')]

def parse_lib(lib):
    global library_dirs
    if lib.startswith('-l'):
        return lib[2:]
github omni-us / pagexml / py-pagexml / setup.py View on Github external
def pagexml_Extension(magick):
    import pkgconfig
    libs = ['opencv','libxml-2.0','libxslt','gdal']
    if magick:
        libs += ['Magick++']
    compile_args = ['-std=c++11']
    link_args = []
    for lib in libs:
        if not pkgconfig.exists(lib):
            raise FileNotFoundError('pkgconfig did not find '+lib)
        compile_args += pkgconfig.cflags(lib).split()
        link_args += pkgconfig.libs(lib).split()
    #compile_args += pkgconfig.cflags('opencv').split()
    #cvre = re.compile('^-L|^-lopencv_core|^-lopencv_imgproc|^-lopencv_imgcodecs|^-lopencv_highgui')
    #link_args += [x for x in pkgconfig.libs('opencv').split() if cvre.match(x)]
    cvinc = pkgconfig.cflags('opencv').split()[0].rsplit('/opencv',1)[0]
    defimage = '__PAGEXML_IMG_MAGICK__' if magick else '__PAGEXML_IMG_CV__'
    pageimage = 'Magick::Image' if magick else 'cv::Mat'
    define_macros = [('__PAGEXML_OGR__',''),(defimage,'')] + ( [('__PAGEXML_MAGICK__','')] if magick else [] )
    swig_opts = ['-D__PAGEXML_OGR__','-D'+defimage,'-DPageImage='+pageimage] + ( ['-D__PAGEXML_MAGICK__'] if magick else [] )
    print('pagexml_Extension configured with '+defimage)
    return Extension('_pagexml',
                     define_macros = define_macros + [('SWIG_PYTHON_SILENT_MEMLEAK','')],
                     extra_compile_args = compile_args,
                     extra_link_args = link_args,
                     swig_opts = swig_opts + [cvinc,'-I./opencv-swig/lib','-modern','-keyword','-w511','-c++'],
                     sources = ['pagexml/PageXML.i','pagexml/PageXML.cc'])
github limbo018 / DREAMPlace / dreamplace / ops / draw_place / setup.py View on Github external
import sys
import pkgconfig

boost_dir = os.environ['BOOST_DIR']
limbo_dir = os.environ['LIMBO_DIR']
utility_dir = os.environ['UTILITY_DIR']
ops_dir = os.environ['OPS_DIR']

include_dirs = [os.path.join(os.path.abspath(boost_dir), 'include'), os.path.join(os.path.abspath(limbo_dir), 'include'), os.path.abspath(ops_dir)]
lib_dirs = [os.path.join(os.path.abspath(boost_dir), 'lib'), os.path.join(os.path.abspath(limbo_dir), 'lib'), utility_dir]
libs = ['gdsparser', 'boost_iostreams', 'z', 'utility'] 

if pkgconfig.exists('cairo'):
    print("found cairo and enable")
    include_dirs.append(pkgconfig.cflags('cairo')[2:])
    libs.append(pkgconfig.libs('cairo')[2:])
    cairo_compile_args = '-DDRAWPLACE=1'
else:
    print("not found cairo and disable")
    cairo_compile_args = '-DDRAWPLACE=0'

tokens = str(torch.__version__).split('.')
torch_major_version = "-DTORCH_MAJOR_VERSION=%d" % (int(tokens[0]))
torch_minor_version = "-DTORCH_MINOR_VERSION=%d" % (int(tokens[1]))

setup(
        name='draw_place',
        ext_modules=[
            CppExtension('draw_place_cpp', 
                [
                    'src/draw_place.cpp', 
                    ],
github JuniorPolegato / pole / setup.py View on Github external
from setuptools import setup, Extension
from setuptools.command.install import install
import os
import ConfigParser

try:
    import pkgconfig
    cflags = pkgconfig.cflags('xmlsec1').replace('\\', '')
    if not cflags:
        raise
    libs = pkgconfig.libs('xmlsec1')
except Exception:
    import traceback
    print '-' * 100
    traceback.print_exc()
    print '-' * 100
    import platform
    cflags = ("-DXMLSEC_CRYPTO=\"openssl\" -D__XMLSEC_FUNCTION__=__FUNCTION__"
              " -DXMLSEC_NO_GOST=1 -DXMLSEC_NO_XKMS=1"
              " -DXMLSEC_NO_CRYPTO_DYNAMIC_LOADING=1 -DXMLSEC_OPENSSL_100=1"
              " -DXMLSEC_CRYPTO_OPENSSL=1"
              " -I/usr/include/libxml2 -I/usr/include/xmlsec1")

    if platform.uname()[4] == 'x86_64':
        cflags = "-DXMLSEC_NO_SIZE_T " + cflags
    libs = "-lxmlsec1-openssl -lxmlsec1 -lssl -lcrypto -lxslt -lxml2"