- Add the following patches from Fedora to fix underlinking in

boost::python code
  * boost-1.57.0-python-abi_letters.patch
  * boost-1.57.0-python-libpython_dep.patch
  * boost-1.55.0-python-test-PyImport_AppendInittab.patch

OBS-URL: https://build.opensuse.org/package/show/devel:libraries:c_c++/boost?expand=0&rev=160
This commit is contained in:
Ismail Dönmez 2016-01-04 14:31:16 +00:00 committed by Git OBS Bridge
parent 5aa3cc574f
commit 686b966420
5 changed files with 205 additions and 6 deletions

View File

@ -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

View File

@ -0,0 +1,62 @@
--- boost_1_57_0/tools/build/src/tools/python.jam 2013-05-21 06:14:18.000000000 +0200
+++ boost_1_55_0/tools/build/src/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

View File

@ -0,0 +1,13 @@
Index: boost_1_57_0/tools/build/src/tools/python.jam
===================================================================
--- boost_1_57_0/tools/build/src/tools/python.jam (revision 50406)
+++ boost_1_57_0/tools/build/src/tools/python.jam (working copy)
@@ -994,7 +994,7 @@
else
{
alias python_for_extensions
- :
+ : python
: $(target-requirements)
:
: $(usage-requirements)

View File

@ -1,3 +1,12 @@
-------------------------------------------------------------------
Mon Jan 4 13:28:22 UTC 2016 - idonmez@suse.com
- Add the following patches from Fedora to fix underlinking in
boost::python code
* boost-1.57.0-python-abi_letters.patch
* boost-1.57.0-python-libpython_dep.patch
* boost-1.55.0-python-test-PyImport_AppendInittab.patch
-------------------------------------------------------------------
Wed Dec 23 21:37:07 UTC 2015 - fstrba@suse.com

View File

@ -1,7 +1,7 @@
#
# spec file for package boost
#
# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@ -85,6 +85,10 @@ Patch9: boost-aarch64-flags.patch
Patch10: boost-disable-pch-on-aarch64.patch
Patch12: boost-1.59-test-fenv.patch
Patch13: boost-visibility.patch
Patch14: boost-1.57.0-python-libpython_dep.patch
Patch15: boost-1.57.0-python-abi_letters.patch
Patch16: boost-1.55.0-python-test-PyImport_AppendInittab.patch
BuildRequires: chrpath
BuildRequires: dos2unix
BuildRequires: fdupes
@ -435,6 +439,9 @@ find -type f ! \( -name \*.sh -o -name \*.py -o -name \*.pl \) -exec chmod -x {}
%patch10 -p1
%patch12 -p1
%patch13
%patch14 -p1
%patch15 -p1
%patch16 -p1
#stupid build machinery copies .orig files
find . -name \*.orig -exec rm {} +
@ -474,11 +481,9 @@ export LONG_DOUBLE_FLAGS="--disable-long-double"
BJAM_CONFIG="-d2 -j$JOBS -sICU_PATH=%{_prefix}"
PYTHON_VERSION=$(python -c 'import sys; print sys.version[:3]')
PYTHON3_VERSION=$(python3 -c 'import sys; print (sys.version[:3])')
PYTHON3_INCLUDE=m
PYTHON_FLAGS="--with-python-root=%{_prefix} --with-python-version=$PYTHON_VERSION"
PYTHON3_ABIFLAGS=m
export REGEX_FLAGS="--with-icu"
export EXPAT_INCLUDE=%{_includedir} EXPAT_LIBPATH=%{_libdir}
export PYTHON_FLAGS
LIBRARIES_FLAGS=--with-libraries=all
%if !%{build_context}
# coroutine/coroutine2 depend on context
@ -506,13 +511,25 @@ local RPM_OPT_FLAGS = [ os.environ RPM_OPT_FLAGS ] ;
using gcc : : : <compileflags>\$(RPM_OPT_FLAGS) ;
using python
: $PYTHON_VERSION
: /usr/bin/python2
: /usr/include/python$PYTHON_VERSION
:
:
:
:
;
using python
: $PYTHON3_VERSION
: /usr/bin/python$PYTHON3_VERSION
: /usr/include/python$PYTHON3_VERSION$PYTHON3_INCLUDE
: /usr/include/python$PYTHON3_VERSION$PYTHON3_ABIFLAGS
: /usr/lib/python$PYTHON3_VERSION
:
:
:
:
$PYTHON3_ABIFLAGS
;
EOF