[boost/f20] libboost_python{,3} should depend on libpython

Petr Machata pmachata at fedoraproject.org
Wed Jan 14 00:10:55 UTC 2015


commit d443a5858b169595633af69f54fb9d3dff9cb65f
Author: Petr Machata <pmachata at redhat.com>
Date:   Tue Jan 13 22:17:20 2015 +0100

    libboost_python{,3} should depend on libpython

 boost-1.55.0-python-abi_letters.patch              |   62 ++++++++++++
 boost-1.55.0-python-libpython_dep.patch            |   13 +++
 ...1.55.0-python-test-PyImport_AppendInittab.patch |   98 ++++++++++++++++++++
 boost.spec                                         |   23 ++++-
 4 files changed, 194 insertions(+), 2 deletions(-)
---
diff --git a/boost-1.55.0-python-abi_letters.patch b/boost-1.55.0-python-abi_letters.patch
new file mode 100644
index 0000000..71fa9bd
--- /dev/null
+++ b/boost-1.55.0-python-abi_letters.patch
@@ -0,0 +1,62 @@
+--- boost_1_55_0/tools/build/v2/tools/python.jam	2013-05-21 06:14:18.000000000 +0200
++++ boost_1_55_0/tools/build/v2/tools/python.jam	2014-05-29 19:09:12.115413877 +0200
+@@ -94,7 +94,7 @@ feature.feature pythonpath : : free opti
+ #   using python : 2.3 : /usr/local/bin/python ;
+ #
+ rule init ( version ? : cmd-or-prefix ? : includes * : libraries ?
+-    : condition * : extension-suffix ? )
++    : condition * : extension-suffix ? : abi-letters ? )
+ {
+     project.push-current $(.project) ;
+ 
+@@ -107,7 +107,7 @@ rule init ( version ? : cmd-or-prefix ? 
+         }
+     }
+ 
+-    configure $(version) : $(cmd-or-prefix) : $(includes) : $(libraries) : $(condition) : $(extension-suffix) ;
++    configure $(version) : $(cmd-or-prefix) : $(includes) : $(libraries) : $(condition) : $(extension-suffix) : $(abi-letters) ;
+ 
+     project.pop-current ;
+ }
+@@ -653,7 +653,7 @@ local rule system-library-dependencies (
+ 
+ # Declare a target to represent Python's library.
+ #
+-local rule declare-libpython-target ( version ? : requirements * )
++local rule declare-libpython-target ( version ? : requirements * : abi-letters ? )
+ {
+     # Compute the representation of Python version in the name of Python's
+     # library file.
+@@ -677,13 +677,13 @@ local rule declare-libpython-target ( ve
+     }
+ 
+     # Declare it.
+-    lib python.lib : : <name>python$(lib-version) $(requirements) ;
++    lib python.lib : : <name>python$(lib-version)$(abi-letters) $(requirements) ;
+ }
+ 
+ 
+ # Implementation of init.
+ local rule configure ( version ? : cmd-or-prefix ? : includes * : libraries ? :
+-    condition * : extension-suffix ? )
++    condition * : extension-suffix ? : abi-letters ? )
+ {
+     local prefix ;
+     local exec-prefix ;
+@@ -699,6 +699,7 @@ local rule configure ( version ? : cmd-o
+         extension-suffix ?= _d ;
+     }
+     extension-suffix ?= "" ;
++    abi-letters ?= "" ;
+ 
+     # Normalize and dissect any version number.
+     local major-minor ;
+@@ -922,7 +923,7 @@ local rule configure ( version ? : cmd-o
+     }
+     else
+     {
+-        declare-libpython-target $(version) : $(target-requirements) ;
++        declare-libpython-target $(version) : $(target-requirements) : $(abi-letters) ;
+ 
+         # This is an evil hack.  On, Windows, when Python is embedded, nothing
+         # seems to set up sys.path to include Python's standard library
diff --git a/boost-1.55.0-python-libpython_dep.patch b/boost-1.55.0-python-libpython_dep.patch
new file mode 100644
index 0000000..202f4ec
--- /dev/null
+++ b/boost-1.55.0-python-libpython_dep.patch
@@ -0,0 +1,13 @@
+Index: boost/tools/build/v2/tools/python.jam
+===================================================================
+--- boost/tools/build/v2/tools/python.jam	(revision 50406)
++++ boost/tools/build/v2/tools/python.jam	(working copy)
+@@ -994,7 +994,7 @@
+     else
+     {
+         alias python_for_extensions
+-            :
++            : python
+             : $(target-requirements)
+             :
+             : $(usage-requirements)
diff --git a/boost-1.55.0-python-test-PyImport_AppendInittab.patch b/boost-1.55.0-python-test-PyImport_AppendInittab.patch
new file mode 100644
index 0000000..1d2ee5c
--- /dev/null
+++ b/boost-1.55.0-python-test-PyImport_AppendInittab.patch
@@ -0,0 +1,98 @@
+diff -up boost_1_55_0/libs/python/test/exec.cpp\~ boost_1_55_0/libs/python/test/exec.cpp
+--- boost_1_55_0/libs/python/test/exec.cpp~	2010-07-05 00:38:38.000000000 +0200
++++ boost_1_55_0/libs/python/test/exec.cpp	2015-01-09 21:31:12.903218280 +0100
+@@ -56,6 +56,20 @@ void eval_test()
+   BOOST_TEST(value == "ABCDEFG");
+ }
+ 
++struct PyCtx
++{
++  PyCtx() {
++    Py_Initialize();
++  }
++
++  ~PyCtx() {
++    // N.B. certain problems may arise when Py_Finalize is called when
++    // using Boost.Python.  However in this test suite it all seems to
++    // work fine.
++    Py_Finalize();
++  }
++};
++
+ void exec_test()
+ {
+   // Register the module with the interpreter
+@@ -68,6 +82,8 @@ void exec_test()
+                              ) == -1) 
+     throw std::runtime_error("Failed to add embedded_hello to the interpreter's "
+                  "builtin modules");
++
++  PyCtx ctx;
+   // Retrieve the main module
+   python::object main = python::import("__main__");
+   
+@@ -148,41 +164,43 @@ void check_pyerr(bool pyerr_expected=fal
+   }
+ }
+ 
++template <class Cb>
++bool
++run_and_handle_exception(Cb cb, bool pyerr_expected = false)
++{
++  PyCtx ctx;
++  if (python::handle_exception(cb)) {
++    check_pyerr(pyerr_expected);
++    return true;
++  } else {
++    return false;
++  }
++}
++
+ int main(int argc, char **argv)
+ {
+   BOOST_TEST(argc == 2 || argc == 3);
+   std::string script = argv[1];
+-  // Initialize the interpreter
+-  Py_Initialize();
+ 
+-  if (python::handle_exception(eval_test)) {
+-    check_pyerr();
+-  }
+-  else if(python::handle_exception(exec_test)) {
+-    check_pyerr();
+-  }
+-  else if (python::handle_exception(boost::bind(exec_file_test, script))) {
++  // N.B. exec_test mustn't be called through run_and_handle_exception
++  // as it needs to handles the python context by itself.
++  if (run_and_handle_exception(eval_test)
++      || python::handle_exception(exec_test))
+     check_pyerr();
+-  }
+-  
+-  if (python::handle_exception(exec_test_error))
+-  {
+-    check_pyerr(/*pyerr_expected*/ true);
+-  }
+   else
+-  {
++    run_and_handle_exception(boost::bind(exec_file_test, script));
++
++  if (!run_and_handle_exception(exec_test_error, true))
+     BOOST_ERROR("Python exception expected, but not seen.");
+-  }
+ 
+   if (argc > 2) {
++    PyCtx ctx;
+     // The main purpose is to test compilation. Since this test generates
+     // a file and I (rwgk) am uncertain about the side-effects, run it only
+     // if explicitly requested.
+     exercise_embedding_html();
+   }
+ 
+-  // Boost.Python doesn't support Py_Finalize yet.
+-  // Py_Finalize();
+   return boost::report_errors();
+ }
+ 
+
+Diff finished.  Fri Jan  9 21:31:13 2015
diff --git a/boost.spec b/boost.spec
index 640354e..a419836 100644
--- a/boost.spec
+++ b/boost.spec
@@ -36,7 +36,7 @@ Name: boost
 Summary: The free peer-reviewed portable C++ source libraries
 Version: 1.54.0
 %define version_enc 1_54_0
-Release: 11%{?dist}
+Release: 12%{?dist}
 License: Boost and MIT and Python
 
 %define toplev_dirname %{name}_%{version_enc}
@@ -205,6 +205,11 @@ Patch56: boost-1.54.0-smart_ptr-shared_ptr_at.patch
 Patch57: boost-1.55.0-graph-dijkstra_shortest_paths.patch
 Patch58: boost-1.55.0-graph-dijkstra_shortest_paths-2.patch
 
+# https://bugzilla.redhat.com/show_bug.cgi?id=1102667
+Patch61: boost-1.55.0-python-libpython_dep.patch
+Patch62: boost-1.55.0-python-abi_letters.patch
+Patch63: boost-1.55.0-python-test-PyImport_AppendInittab.patch
+
 %bcond_with tests
 %bcond_with docs_generated
 
@@ -698,6 +703,9 @@ a number of significant features and is now developed independently
 %patch56 -p1
 %patch57 -p2
 %patch58 -p2
+%patch61 -p1
+%patch62 -p1
+%patch63 -p1
 
 # At least python2_version needs to be a macro so that it's visible in
 # %%install as well.
@@ -718,11 +726,13 @@ cat >> ./tools/build/v2/user-config.jam << EOF
 # There are many strict aliasing warnings, and it's not feasible to go
 # through them all at this time.
 using gcc : : : <compileflags>-fno-strict-aliasing ;
+%if %{with openmpi} || %{with mpich}
 using mpi ;
+%endif
 %if %{with python3}
 # This _adds_ extra python version.  It doesn't replace whatever
 # python 2.X is default on the system.
-using python : %{python3_version} : /usr/bin/python3 : /usr/include/python%{python3_version}%{python3_abiflags} ;
+using python : %{python3_version} : /usr/bin/python3 : /usr/include/python%{python3_version}%{python3_abiflags} : : : : %{python3_abiflags} ;
 %endif
 EOF
 
@@ -1289,6 +1299,15 @@ rm -rf $RPM_BUILD_ROOT
 %{_mandir}/man1/bjam.1*
 
 %changelog
+* Wed Jan 14 2015 Petr Machata <pmachata at redhat.com> - 1.54.0-12
+- Build libboost_python and libboost_python3 such that they depend on
+  their respective libpython's.
+  (boost-1.55.0-python-libpython_dep.patch,
+  boost-1.55.0-python-abi_letters.patch)
+- Fix Boost.Python test suite so that PyImport_AppendInittab is called
+  before PyInitialize, which broke the test suite with Python 3.
+  (boost-1.55.0-python-test-PyImport_AppendInittab.patch)
+
 * Tue Jan 13 2015 Petr Machata <pmachata at redhat.com> - 1.54.0-11
 - Apply upstream fix for dijkstra_bfs_visitor from Boost.Graph to not
   misinterpret edge weights.


More information about the scm-commits mailing list