Repository: qpid-proton
Updated Branches:
refs/heads/0.9.x 801052159 -> 20ab710e4
PROTON-922: use pkg-config to find proton's headers and library
(cherry picked from commit 70a463f0068b1ff365df53c5128e65e5eec4a271)
Conflicts:
proton-c/bindings/python/setup.py
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/20ab710e
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/20ab710e
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/20ab710e
Branch: refs/heads/0.9.x
Commit: 20ab710e416772f2c5a12f3672d3bfd8e89552c1
Parents: 8010521
Author: Ken Giusti <[email protected]>
Authored: Thu Jun 25 16:11:00 2015 -0400
Committer: Ken Giusti <[email protected]>
Committed: Mon Jun 29 15:39:26 2015 -0400
----------------------------------------------------------------------
proton-c/bindings/python/setup.py | 33 ++++++++++--
proton-c/bindings/python/setuputils/misc.py | 64 +++++++++++++++++-------
2 files changed, 74 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/20ab710e/proton-c/bindings/python/setup.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/setup.py
b/proton-c/bindings/python/setup.py
index 1c51f00..6a2284a 100755
--- a/proton-c/bindings/python/setup.py
+++ b/proton-c/bindings/python/setup.py
@@ -98,6 +98,10 @@ class Configure(build_ext):
return compiler.compiler_type
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.
+ """
base = self.get_finalized_command('build').build_base
build_include = os.path.join(base, 'include')
install = self.get_finalized_command('install').install_base
@@ -106,6 +110,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:
bundledir = os.path.join(base, "bundled")
if not os.path.exists(bundledir):
@@ -269,12 +276,30 @@ class Configure(build_ext):
@property
def bundle_proton(self):
- """Bundled proton if the conditions below are met."""
- return sys.platform == 'linux2' and 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):
- if self.bundle_proton:
- self.bundle_libqpid_proton_extension()
+ # linux2 for python<2.7
+ # linux4 for python<2.6
+ if sys.platform in ['linux', 'linux2', 'linux4']:
+ if self.bundle_proton:
+ self.bundle_libqpid_proton_extension()
+ else:
+ self.use_installed_proton()
class CustomBuildOrder(build):
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/20ab710e/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 cf6b97f..f5b31cd 100644
--- a/proton-c/bindings/python/setuputils/misc.py
+++ b/proton-c/bindings/python/setuputils/misc.py
@@ -18,6 +18,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
@@ -31,25 +51,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: [email protected]
For additional commands, e-mail: [email protected]