I had a look at pythonwheel.
Currently, the CMake build of Qpid Proton puts together a build/python/dist directory, which contains python sources, swig .i file and C sources. The setup.py is then able to build a Linux pip package that either 1) relies on qpid-proton .so files in /usr/lib or builds its own .so file from the C sources which CMake copied there.
Windows is not handled by setup.py, see https://issues.apache.org/jira/browse/PROTON-1467 ([python] setup.py script fails to build C sources on Windows) and https://issues.apache.org/jira/browse/PROTON-1468 ([python] attempting to pip install on windows should fail gracefully).
What I tried is to put something into setup.py so that it will use the .so (actually DLL, I tried only Windows) produced by CMake and it will install them into lib/site-packages in python virtualenv.
Index: python/setup.py.in
===================================================================
--- python/setup.py.in (revision 6397116291fd569ce03025c1b3a135172de3f2a6)
+++ python/setup.py.in (date 1547492834727)
@@ -50,7 +50,7 @@
import distutils.spawn as ds_spawn
import distutils.sysconfig as ds_sys
from distutils.ccompiler import new_compiler, get_default_compiler
-from distutils.core import setup, Extension
+from setuptools import setup, Extension
from distutils.command.build import build
from distutils.command.build_ext import build_ext
from distutils.command.sdist import sdist
@@ -262,14 +262,38 @@
ldirs = misc.pkg_config_get_var('libqpid-proton', 'libdir')
_cproton.library_dirs.extend(ldirs.split())
+ def use_compiled_proton(self):
+ """The Proton development headers and library are installed, update the
+ _cproton extension to tell it where to find the library and headers.
+ """
+ # update the Extension instance passed to setup() to use the installed
+ # headers and link library
+ _cproton = self.distribution.ext_modules[-1]
+ # incs = misc.pkg_config_get_var('libqpid-proton', 'includedir')
+ incs = r"C:\Users\Vitorio\CLionProjects\qpid-proton\build\c\include"
+ for i in incs.split():
+ _cproton.swig_opts.append('-I%s' % i)
+ _cproton.include_dirs.append(i)
+ # ldirs = misc.pkg_config_get_var('libqpid-proton', 'libdir')
+ ldirs = r"C:\Users\Vitorio\CLionProjects\qpid-proton\build\c\Debug"
+ _cproton.library_dirs.extend(ldirs.split())
+
+ # https:+ self.distribution.data_files = [('lib/site-packages', [
+ r'C:\Users\Vitorio\CLionProjects\qpid-proton\build\c\Debug\qpid-proton-cored.dll',
+ r'C:\Users\Vitorio\CLionProjects\qpid-proton\build\c\Debug\qpid-proton-proactord.dll',
+ r'C:\Users\Vitorio\CLionProjects\qpid-proton\build\c\Debug\qpid-protond.dll',
+ ])]
+
def run(self):
# check if the Proton library and headers are installed and are
# compatible with this version of the binding.
- if self.libqpid_proton_installed(_PROTON_VERSION_STR):
- self.use_installed_proton()
- else:
- # Proton not installed or compatible, use bundled proton-c sources
- self.use_bundled_proton()
+ # if self.libqpid_proton_installed(_PROTON_VERSION_STR):
+ # self.use_installed_proton()
+ # else:
+ # # Proton not installed or compatible, use bundled proton-c sources
+ # self.use_bundled_proton()
+ self.use_compiled_proton()
self.prepare_swig_wrap()
@@ -330,4 +354,4 @@
sources=['cproton.i', 'cproton_wrap.c'],
swig_opts=['-threads'],
extra_compile_args=['-pthread'],
- libraries=['qpid-proton'])])
+ libraries=['qpid-protond'])])
python setup.py bdist_wheel
pip install python_qpid_proton-0.27.0-cp37-cp37m-win_amd64.whl
There are some hardcoded paths in that, it assumes a Debug CMake build, and I did not try to figure out the logic when to 1) compile from source 2) compile against system 3) use dlls build by CMake.
There would need to be a .wheel file for every combination of python version (2.7, 3.5, ...) and architecture (32, 64bit).
Since the problem described in this issue should be resolved in a recent advisory, it has been closed.
For information on the advisory, and where to find the updated files, follow the link below.
If the solution does not work for you, open a new bug report.
https://access.redhat.com/errata/RHSA-2020:2605