From 89eac133eab2e4bcd5f67544fe0ca888f5e7df9e Mon Sep 17 00:00:00 2001
From: Marcus Müllr <marcus.mueller@ettus.com>
Date: Fri, 27 Jul 2018 14:47:31 +0000
Subject: python: Fixing Boost.Python initializer visibility

With Boost 1.64 to 1.65 (which, of course, Ubuntu LTS ships), the
`PyInit_Libraryname` are invisible when one sets the default visibility
to "hidden" (which is reasonable, and which we do).
---
 host/python/CMakeLists.txt |  4 ++--
 host/python/pyuhd.cpp      | 11 +++++++++++
 2 files changed, 13 insertions(+), 2 deletions(-)

(limited to 'host')

diff --git a/host/python/CMakeLists.txt b/host/python/CMakeLists.txt
index c3099348a..32a32592e 100644
--- a/host/python/CMakeLists.txt
+++ b/host/python/CMakeLists.txt
@@ -54,14 +54,14 @@ CONFIGURE_FILE(${SETUP_PY_IN} ${SETUP_PY})
 
 ADD_CUSTOM_COMMAND(OUTPUT ${TIMESTAMP_FILE}
   COMMAND ${CMAKE_COMMAND} -E copy ${PYUHD_FILES} ${CMAKE_CURRENT_BINARY_DIR}/uhd
-  COMMAND ${PYTHON} ${SETUP_PY} -q build
+  COMMAND ${PYTHON_EXECUTABLE} ${SETUP_PY} -q build
   COMMAND ${CMAKE_COMMAND} -E touch ${TIMESTAMP_FILE}
   DEPENDS ${PYUHD_FILES})
 
 ADD_CUSTOM_TARGET(pyuhd_library ALL DEPENDS ${TIMESTAMP_FILE} pyuhd)
 IF(HAVE_PYTHON_VIRTUALENV)
     # In virtualenvs, let setuptools do its thing
-    INSTALL(CODE "execute_process(COMMAND ${PYTHON} ${SETUP_PY} -q install --force)")
+    INSTALL(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} ${SETUP_PY} -q install --force)")
 ELSE()
     # Otherwise, use distutils to determine the correct relative path for Python
     # packages, and install to our prefix
diff --git a/host/python/pyuhd.cpp b/host/python/pyuhd.cpp
index fe8d6a790..27b154c90 100644
--- a/host/python/pyuhd.cpp
+++ b/host/python/pyuhd.cpp
@@ -9,6 +9,17 @@
 #include <boost/python/stl_iterator.hpp>
 #include <boost/python/suite/indexing/vector_indexing_suite.hpp>
 
+/*
+This solution was adapted from an Issue posted to the Boost.Python Github.
+https://github.com/boostorg/python/pull/159/files
+*/
+#if (BOOST_VERSION >= 106400) && (BOOST_VERSION < 106600)
+#warning overriding broken boost python implementation of BOOST_PYTHON_MODULE_INIT
+#  define BOOST_PYTHON_MODULE_INIT(name)                       \
+  void BOOST_PP_CAT(init_module_,name)();                      \
+extern "C" BOOST_SYMBOL_EXPORT _BOOST_PYTHON_MODULE_INIT(name)
+#endif
+
 #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
 #include <numpy/arrayobject.h>
 
-- 
cgit v1.2.3