Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r67483 - in branches/release: boost/python libs/python libs/python/src tools/build/v2
From: rwgk_at_[hidden]
Date: 2010-12-28 15:38:31


Author: rwgk
Date: 2010-12-28 15:38:29 EST (Tue, 28 Dec 2010)
New Revision: 67483
URL: http://svn.boost.org/trac/boost/changeset/67483

Log:
merging current boost/python and libs/python from trunk into release branch
Properties modified:
   branches/release/boost/python/ (props changed)
   branches/release/libs/python/ (props changed)
   branches/release/tools/build/v2/user-config.jam (contents, props changed)
Text files modified:
   branches/release/boost/python/module_init.hpp | 53 +++++++++++++++++++++++++--------
   branches/release/libs/python/src/module.cpp | 62 +++++++++++++++++++++------------------
   branches/release/tools/build/v2/user-config.jam | 10 +++++-
   3 files changed, 82 insertions(+), 43 deletions(-)

Modified: branches/release/boost/python/module_init.hpp
==============================================================================
--- branches/release/boost/python/module_init.hpp (original)
+++ branches/release/boost/python/module_init.hpp 2010-12-28 15:38:29 EST (Tue, 28 Dec 2010)
@@ -13,27 +13,54 @@
 
 namespace boost { namespace python { namespace detail {
 
+# if PY_VERSION_HEX >= 0x03000000
+
+BOOST_PYTHON_DECL PyObject* init_module(PyModuleDef&, void(*)());
+
+#else
+
 BOOST_PYTHON_DECL PyObject* init_module(char const* name, void(*)());
 
+#endif
+
 }}}
 
 # if PY_VERSION_HEX >= 0x03000000
 
-# define _BOOST_PYTHON_MODULE_INIT(name) \
- PyObject* BOOST_PP_CAT (PyInit_,name)() \
-{ \
- return boost::python::detail::init_module( \
- BOOST_PP_STRINGIZE(name),&BOOST_PP_CAT(init_module_,name)); \
-} \
- void BOOST_PP_CAT(init_module_,name)()
+# define _BOOST_PYTHON_MODULE_INIT(name) \
+ PyObject* BOOST_PP_CAT(PyInit_, name)() \
+ { \
+ static PyModuleDef_Base initial_m_base = { \
+ PyObject_HEAD_INIT(NULL) \
+ 0, /* m_init */ \
+ 0, /* m_index */ \
+ 0 /* m_copy */ }; \
+ static PyMethodDef initial_methods[] = { { 0, 0, 0, 0 } }; \
+ \
+ static struct PyModuleDef moduledef = { \
+ initial_m_base, \
+ BOOST_PP_STRINGIZE(name), \
+ 0, /* m_doc */ \
+ -1, /* m_size */ \
+ initial_methods, \
+ 0, /* m_reload */ \
+ 0, /* m_traverse */ \
+ 0, /* m_clear */ \
+ 0, /* m_free */ \
+ }; \
+ \
+ return boost::python::detail::init_module( \
+ moduledef, BOOST_PP_CAT(init_module_, name) ); \
+ } \
+ void BOOST_PP_CAT(init_module_, name)()
 
 # else
 
 # define _BOOST_PYTHON_MODULE_INIT(name) \
- void BOOST_PP_CAT(init,name)() \
+ void BOOST_PP_CAT(init,name)() \
 { \
     boost::python::detail::init_module( \
- BOOST_PP_STRINGIZE(name),&BOOST_PP_CAT(init_module_,name)); \
+ BOOST_PP_STRINGIZE(name),&BOOST_PP_CAT(init_module_,name)); \
 } \
   void BOOST_PP_CAT(init_module_,name)()
 
@@ -42,23 +69,23 @@
 # if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(BOOST_PYTHON_STATIC_MODULE)
 
 # define BOOST_PYTHON_MODULE_INIT(name) \
- void BOOST_PP_CAT(init_module_,name)(); \
+ void BOOST_PP_CAT(init_module_,name)(); \
 extern "C" __declspec(dllexport) _BOOST_PYTHON_MODULE_INIT(name)
 
 # elif BOOST_PYTHON_USE_GCC_SYMBOL_VISIBILITY
 
 # define BOOST_PYTHON_MODULE_INIT(name) \
- void BOOST_PP_CAT(init_module_,name)(); \
+ void BOOST_PP_CAT(init_module_,name)(); \
 extern "C" __attribute__ ((visibility("default"))) _BOOST_PYTHON_MODULE_INIT(name)
 
 # else
 
 # define BOOST_PYTHON_MODULE_INIT(name) \
- void BOOST_PP_CAT(init_module_,name)(); \
+ void BOOST_PP_CAT(init_module_,name)(); \
 extern "C" _BOOST_PYTHON_MODULE_INIT(name)
 
 # endif
 
-# endif
+# endif
 
 #endif // MODULE_INIT_DWA20020722_HPP

Modified: branches/release/libs/python/src/module.cpp
==============================================================================
--- branches/release/libs/python/src/module.cpp (original)
+++ branches/release/libs/python/src/module.cpp 2010-12-28 15:38:29 EST (Tue, 28 Dec 2010)
@@ -11,6 +11,23 @@
 
 namespace boost { namespace python { namespace detail {
 
+namespace
+{
+ PyObject* init_module_in_scope(PyObject* m, void(*init_function)())
+ {
+ if (m != 0)
+ {
+ // Create the current module scope
+ object m_obj(((borrowed_reference_t*)m));
+ scope current_module(m_obj);
+
+ handle_exception(init_function);
+ }
+
+ return m;
+ }
+}
+
 BOOST_PYTHON_DECL void scope_setattr_doc(char const* name, object const& x, char const* doc)
 {
     // Use function::add_to_namespace to achieve overloading if
@@ -19,42 +36,31 @@
     objects::add_to_namespace(current, name, x, doc);
 }
 
+#if PY_VERSION_HEX >= 0x03000000
+
+PyObject* init_module(PyModuleDef& moduledef, void(*init_function)())
+{
+ return init_module_in_scope(
+ PyModule_Create(&moduledef),
+ init_function);
+}
+
+#else
+
 namespace
 {
- PyMethodDef initial_methods[] = { { 0, 0, 0, 0 } };
+ PyMethodDef initial_methods[] = { { 0, 0, 0, 0 } };
 }
 
 BOOST_PYTHON_DECL PyObject* init_module(char const* name, void(*init_function)())
 {
-#if PY_VERSION_HEX >= 0x03000000
- static struct PyModuleDef moduledef = {
- PyModuleDef_HEAD_INIT,
- name,
- 0, /* m_doc */
- -1, /* m_size */
- initial_methods,
- 0, /* m_reload */
- 0, /* m_traverse */
- 0, /* m_clear */
- 0, /* m_free */
- };
- PyObject* m = PyModule_Create(&moduledef);
-#else
- PyObject* m
- = Py_InitModule(const_cast<char*>(name), initial_methods);
-#endif
-
- if (m != 0)
- {
- // Create the current module scope
- object m_obj(((borrowed_reference_t*)m));
- scope current_module(m_obj);
-
- handle_exception(init_function);
- }
- return m;
+ return init_module_in_scope(
+ Py_InitModule(const_cast<char*>(name), initial_methods),
+ init_function);
 }
 
+#endif
+
 }}} // namespace boost::python::detail
 
 namespace boost { namespace python {

Modified: branches/release/tools/build/v2/user-config.jam
==============================================================================
--- branches/release/tools/build/v2/user-config.jam (original)
+++ branches/release/tools/build/v2/user-config.jam 2010-12-28 15:38:29 EST (Tue, 28 Dec 2010)
@@ -8,7 +8,7 @@
 # this file in place, or you can place it in a permanent location so that it
 # does not get overwritten should you get a new version of Boost.Build. See:
 #
-# http://boost.org/boost-build2/doc/html/bbv2/reference.html#bbv2.reference.init
+# http://www.boost.org/boost-build2/doc/html/bbv2/overview/configuration.html
 #
 # for documentation about possible permanent locations.
 
@@ -34,7 +34,6 @@
 # http://boost.org/boost-build2/doc/html/bbv2/advanced.html#bbv2.advanced.jam_language
 #
 
-
 # ------------------
 # GCC configuration.
 # ------------------
@@ -84,3 +83,10 @@
 
 # Configure with an explicit installation prefix.
 # using qt : /usr/opt/qt ;
+
+# ---------------------
+# Python configuration.
+# ---------------------
+
+# Configure specific Python version.
+# using python : 3.1 : /usr/bin/python3 : /usr/include/python3.1 : /usr/lib ;


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk