You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2015/07/10 00:11:48 UTC
[08/50] qpid-proton git commit: PROTON-922: use pkg-config to find
proton's headers and library
PROTON-922: use pkg-config to find proton's headers and library
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/70a463f0
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/70a463f0
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/70a463f0
Branch: refs/heads/cjansen-cpp-client
Commit: 70a463f0068b1ff365df53c5128e65e5eec4a271
Parents: 69cc9ec
Author: Ken Giusti <kg...@apache.org>
Authored: Thu Jun 25 16:11:00 2015 -0400
Committer: Ken Giusti <kg...@apache.org>
Committed: Fri Jun 26 13:02:45 2015 -0400
----------------------------------------------------------------------
proton-c/bindings/python/setup.py | 26 +++++++++-
proton-c/bindings/python/setuputils/misc.py | 64 +++++++++++++++++-------
2 files changed, 69 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/70a463f0/proton-c/bindings/python/setup.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/setup.py b/proton-c/bindings/python/setup.py
index 1eb3e64..d4eb3ca 100755
--- a/proton-c/bindings/python/setup.py
+++ b/proton-c/bindings/python/setup.py
@@ -133,6 +133,10 @@ class Configure(build_ext):
ext.swig_opts = []
def bundle_libqpid_proton_extension(self):
+ """The proper version of libqpid-proton is not present on the system,
+ so attempt to retrieve the proper libqpid-proton sources and
+ build/install them locally.
+ """
setup_path = os.path.dirname(os.path.realpath(__file__))
base = self.get_finalized_command('build').build_base
build_include = os.path.join(base, 'include')
@@ -142,6 +146,9 @@ class Configure(build_ext):
log.info("Using bundled libqpid-proton")
+ # QPID_PROTON_SRC - (optional) pathname to the Proton C sources. Can
+ # be used to override where this setup gets the Proton C sources from
+ # (see bundle.fetch_libqpid_proton())
if 'QPID_PROTON_SRC' not in os.environ:
if not os.path.exists(os.path.join(setup_path, 'tox.ini')):
bundledir = os.path.join(base, "bundled")
@@ -331,8 +338,21 @@ class Configure(build_ext):
@property
def bundle_proton(self):
- """Bundled proton if the conditions below are met."""
- return not self.check_qpid_proton_version()
+ """Need to bundle proton if the conditions below are met."""
+ return ('QPID_PROTON_SRC' in os.environ) or \
+ (not self.check_qpid_proton_version())
+
+ def use_installed_proton(self):
+ """The Proton development headers and library are installed, tell swig
+ and the extension where to find them.
+ """
+ _cproton = self.distribution.ext_modules[-1]
+ incs = misc.pkg_config_get_var('includedir')
+ for i in incs.split():
+ _cproton.swig_opts.append('-I%s' % i)
+ _cproton.include_dirs.append(i)
+ ldirs = misc.pkg_config_get_var('libdir')
+ _cproton.library_dirs.extend(ldirs.split())
def run(self):
# linux2 for python<2.7
@@ -340,6 +360,8 @@ class Configure(build_ext):
if sys.platform in ['linux', 'linux2', 'linux4']:
if self.bundle_proton:
self.bundle_libqpid_proton_extension()
+ else:
+ self.use_installed_proton()
# Do this just on linux since it's the only
# platform we support building the bundle for
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/70a463f0/proton-c/bindings/python/setuputils/misc.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/setuputils/misc.py b/proton-c/bindings/python/setuputils/misc.py
index 3a32165..b1864a0 100644
--- a/proton-c/bindings/python/setuputils/misc.py
+++ b/proton-c/bindings/python/setuputils/misc.py
@@ -19,6 +19,26 @@ import sys
from . import log
+def _call_pkg_config(args):
+ """Spawn a subprocess running pkg-config with the given args.
+
+ :param args: list of strings to pass to pkg-config's command line.
+ Refer to pkg-config's documentation for more detail.
+
+ Return the Popen object, or None if the command failed
+ """
+ try:
+ return subprocess.Popen(['pkg-config'] + args,
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE,
+ universal_newlines=True)
+ except OSError as e:
+ if e.errno == errno.ENOENT:
+ log.warn("command not found: pkg-config")
+ else:
+ log.warn("Running pkg-config failed - %s." % e)
+ return None
+
+
def pkg_config_version(atleast=None, max_version=None, module='libqpid-proton'):
"""Check the qpid_proton version using pkg-config
@@ -32,25 +52,31 @@ def pkg_config_version(atleast=None, max_version=None, module='libqpid-proton'):
"""
if atleast and max_version:
- log.error('Specify either atleast or max_version')
+ log.fatal('Specify either atleast or max_version')
- try:
- cmd = ['pkg-config',
- '--%s-version=%s' % (atleast and 'atleast' or 'max',
- atleast or max_version),
- module]
- p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- except OSError as e:
- if e.errno == errno.ENOENT:
- log.info("pkg-config not found")
- else:
- log.warn("Running pkg-config failed - %s." % e)
- return False
+ p = _call_pkg_config(['--%s-version=%s' % (atleast and 'atleast' or 'max',
+ atleast or max_version),
+ module])
+ if p:
+ out,err = p.communicate()
+ if p.returncode:
+ log.info("Did not find %s via pkg-config: %s" % (module, err))
+ return False
+ log.info("Using %s (found via pkg-config)." % module)
+ return True
+ return False
- if p.wait():
- log.info("Did not find libqpid-proton via pkg-config:")
- log.info(p.stderr.read().decode())
- return False
- log.info("Using %s (found via pkg-config)." % module)
- return True
+def pkg_config_get_var(name, module='libqpid-proton'):
+ """Retrieve the value of the named module variable as a string
+ """
+ p = _call_pkg_config(['--variable=%s' % name, module])
+ if not p:
+ log.warn("pkg-config: var %s get failed, package %s", name, module)
+ return ""
+ out,err = p.communicate()
+ if p.returncode:
+ out = ""
+ log.warn(err)
+ return out
+
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org