You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by mc...@apache.org on 2015/06/18 16:03:16 UTC
[09/50] qpid-proton git commit: PROTON-908: Remove install-runtime
dependency on swig
PROTON-908: Remove install-runtime dependency on swig
The patch allows python-qpid-proton for generating the `cproton_wrap.c`
file when creating the distribution package. Since this file is already
cross-platform, it should be safe to ship it as part of the
python-qpid-proton package.
This allows us for building the bindings even when swig is not
available. The setup.py process will try to generate a new
cproton_wrap.c everytime but it'll fallback to the one distributed with
the package if swig is not available.
Note that this will be done just in the platforms where bundling
proton-c is supported. The reason being that, in the other platforms, w
can't verify whether the installed qpid-proton version is the same that
was used to generated these files
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/56af1189
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/56af1189
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/56af1189
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: 56af1189cf2e6a769b0452a102a795a6f906b470
Parents: 821b4e1
Author: Flavio Percoco <fl...@gmail.com>
Authored: Thu Jun 11 10:24:36 2015 +0200
Committer: Ken Giusti <kg...@apache.org>
Committed: Tue Jun 16 13:06:46 2015 -0400
----------------------------------------------------------------------
proton-c/CMakeLists.txt | 2 +-
proton-c/bindings/python/setup.py | 58 +++++++++++++++++++++++++++++++---
2 files changed, 54 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/56af1189/proton-c/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/proton-c/CMakeLists.txt b/proton-c/CMakeLists.txt
index 5b05e38..5985e2d 100644
--- a/proton-c/CMakeLists.txt
+++ b/proton-c/CMakeLists.txt
@@ -520,7 +520,7 @@ if (BUILD_PYTHON)
to_native_path ("${py_pythonpath}" py_pythonpath)
add_test (NAME python-tox-test
COMMAND ${env_py}
- "PATH=${py_path}" ${VALGRIND_ENV}
+ "PATH=${py_path}" "QPID_PROTON_SRC=${CMAKE_CURRENT_SOURCE_DIR}/../" ${VALGRIND_ENV}
tox
WORKING_DIRECTORY ${py_src})
set_tests_properties(python-tox-test PROPERTIES PASS_REGULAR_EXPRESSION "Totals: .* 0 failed")
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/56af1189/proton-c/bindings/python/setup.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/setup.py b/proton-c/bindings/python/setup.py
index 84b5a66..0a77872 100755
--- a/proton-c/bindings/python/setup.py
+++ b/proton-c/bindings/python/setup.py
@@ -78,12 +78,32 @@ from distutils.ccompiler import new_compiler, get_default_compiler
from distutils.core import setup, Extension
from distutils.command.build import build
from distutils.command.build_ext import build_ext
+from distutils.command.sdist import sdist
+from distutils import errors
from setuputils import bundle
from setuputils import log
from setuputils import misc
+class CheckSDist(sdist):
+
+ def run(self):
+ self.distribution.run_command('configure')
+
+ # Append the source that was removed during
+ # the configuration step.
+ _cproton = self.distribution.ext_modules[-1]
+ _cproton.sources.append('cproton.i')
+
+ try:
+ sdist.run(self)
+ finally:
+ for src in ['cproton.py', 'cproton_wrap.c']:
+ if os.path.exists(src):
+ os.remove(src)
+
+
class Configure(build_ext):
description = "Discover Qpid Proton version"
@@ -97,6 +117,21 @@ class Configure(build_ext):
else:
return compiler.compiler_type
+ def prepare_swig_wrap(self):
+ ext = self.distribution.ext_modules[-1]
+
+ try:
+ # This will actually call swig to generate the files
+ # and list the sources.
+ self.swig_sources(ext.sources, ext)
+ except (errors.DistutilsExecError, errors.DistutilsPlatformError) as e:
+ if not (os.path.exists('cproton_wrap.c') or
+ os.path.exists('cproton.py')):
+ raise e
+
+ ext.sources = ext.sources[1:]
+ ext.swig_opts = []
+
def bundle_libqpid_proton_extension(self):
base = self.get_finalized_command('build').build_base
build_include = os.path.join(base, 'include')
@@ -262,6 +297,7 @@ class Configure(build_ext):
_cproton = self.distribution.ext_modules[-1]
_cproton.library_dirs.append(self.build_lib)
_cproton.include_dirs.append(proton_include)
+ _cproton.include_dirs.append(build_include)
_cproton.include_dirs.append(os.path.join(proton_src, 'bindings', 'python'))
_cproton.swig_opts.append('-I%s' % build_include)
@@ -283,11 +319,20 @@ 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()
+ return not self.check_qpid_proton_version()
def run(self):
- if self.bundle_proton:
- self.bundle_libqpid_proton_extension()
+ if sys.platform == 'linux2':
+ if self.bundle_proton:
+ self.bundle_libqpid_proton_extension()
+
+ # Do this just on linux since it's the only
+ # platform we support building the bundle for
+ # and especially, it's the only platform we check
+ # the, hopefully installed, qpid-proton version.
+ # This avoids re-using the distributed wrappers with
+ # uncompatible versions.
+ self.prepare_swig_wrap()
class CustomBuildOrder(build):
@@ -316,7 +361,8 @@ class CheckingBuildExt(build_ext):
# Override `build_ext` and add `configure`
cmdclass = {'configure': Configure,
'build': CustomBuildOrder,
- 'build_ext': CheckingBuildExt}
+ 'build_ext': CheckingBuildExt,
+ 'sdist': CheckSDist}
setup(name='python-qpid-proton',
@@ -332,6 +378,8 @@ setup(name='python-qpid-proton',
"Intended Audience :: Developers",
"Programming Language :: Python"],
cmdclass = cmdclass,
- ext_modules=[Extension('_cproton', ['cproton.i'],
+ ext_modules=[Extension('_cproton',
+ sources=['cproton.i', 'cproton_wrap.c'],
swig_opts=['-threads'],
+ extra_compile_args=['-pthread'],
libraries=['qpid-proton'])])
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org