def check_pkgconfig():
 pcfg = None
 zmq_config = None
 try:
  check_call(['pkg-config', '--exists', 'libzmq'])
  pcfg = Popen(['pkg-config', '--libs', '--cflags', 'libzmq'], stdout=subprocess.PIPE)
 except OSError as osexception:
  if (osexception.errno == errno.ENOENT):
   info('pkg-config not found')
  else:
   warn(('Running pkg-config failed - %s.' % osexception))
 except CalledProcessError:
  info('Did not find libzmq via pkg-config.')
 if (pcfg is not None):
  (output, _) = pcfg.communicate()
  output = output.decode('utf8', 'replace')
  bits = output.strip().split()
  zmq_config = {'library_dirs': [], 'include_dirs': [], 'libraries': []}
  for tok in bits:
   if tok.startswith('-L'):
    zmq_config['library_dirs'].append(tok[2:])
   if tok.startswith('-I'):
    zmq_config['include_dirs'].append(tok[2:])
   if tok.startswith('-l'):
    zmq_config['libraries'].append(tok[2:])
  info(('Settings obtained from pkg-config: %r' % zmq_config))
 return zmq_config

def check_pkgconfig ( ) : pcfg = None zmq_config = None try : check_call ( [ 'pkg-config' , '--exists' , 'libzmq' ] ) pcfg = Popen ( [ 'pkg-config' , '--libs' , '--cflags' , 'libzmq' ] , stdout = subprocess . PIPE ) except OSError as osexception : if ( osexception . errno == errno . ENOENT ) : info ( 'pkg-config not found' ) else : warn ( ( 'Running pkg-config failed - %s.' % osexception ) ) except CalledProcessError : info ( 'Did not find libzmq via pkg-config.' ) if ( pcfg is not None ) : ( output , _ ) = pcfg . communicate ( ) output = output . decode ( 'utf8' , 'replace' ) bits = output . strip ( ) . split ( ) zmq_config = { 'library_dirs' : [ ] , 'include_dirs' : [ ] , 'libraries' : [ ] } for tok in bits : if tok . startswith ( '-L' ) : zmq_config [ 'library_dirs' ] . append ( tok [ 2 : ] ) if tok . startswith ( '-I' ) : zmq_config [ 'include_dirs' ] . append ( tok [ 2 : ] ) if tok . startswith ( '-l' ) : zmq_config [ 'libraries' ] . append ( tok [ 2 : ] ) info ( ( 'Settings obtained from pkg-config: %r' % zmq_config ) ) return zmq_config
pull compile / link flags from pkg-config if present .