How to use the pkgconfig.cflags 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_cflags():
    flags = pkgconfig.cflags(PACKAGE_NAME)

    for flag in flags.split(' '):
        assert flag in ('-DGSEAL_ENABLE', '-I/usr/include/gtk-3.0')

    with pytest.raises(pkgconfig.PackageNotFoundError):
        pkgconfig.cflags('doesnotexist')
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 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 hotdoc / hotdoc / hotdoc / extensions / c / c_extension.py View on Github external
def flags_from_config(config):
    flags = []

    for package in config.get('pkg_config_packages') or []:
        flags.extend(pkgconfig.cflags(package).split(' '))

    extra_flags = config.get('extra_c_flags') or []
    for flag in extra_flags:
        flags.extend([f for f in flag.split()])

    return flags
github limbo018 / DREAMPlace / dreamplace / ops / draw_place / setup.py View on Github external
import os 
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 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 hotdoc / hotdoc / hotdoc / extensions / c_extension.py View on Github external
def flags_from_config(config, path_resolver):
    flags = []

    for package in config.get('pkg_config_packages', []):
        flags.extend(pkgconfig.cflags(package).split(' '))

    extra_flags = config.get('extra_c_flags', [])
    for extra_flag in extra_flags:
        extra_flag = extra_flag.strip()
        if extra_flag.startswith('-I'):
            path = extra_flag.split('-I')[1]
            flags.append('-I%s' % path_resolver.resolve_config_path(path))
        else:
            flags.append(extra_flag)

    print "ze flags are", flags
    return flags