Skip to content

Commit 211f209

Browse files
committed
Make numpy initialization Python 3 compatible.
Adjust for slightly changed definition of numpy `import_array` in the extension module.
1 parent e36388f commit 211f209

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

src/extensions/srreal_ext.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,23 @@ void wrap_OverlapCalculator();
4949

5050
} // namespace srrealmodule
5151

52+
namespace {
53+
54+
#if PY_MAJOR_VERSION >= 3
55+
void* initialize_numpy() { import_array(); return NULL; }
56+
#else
57+
void initialize_numpy() { import_array(); }
58+
#endif
59+
60+
} // namespace
61+
5262
// Module Definitions --------------------------------------------------------
5363

5464
BOOST_PYTHON_MODULE(srreal_ext)
5565
{
5666
using namespace srrealmodule;
5767
// initialize numpy module
58-
import_array();
68+
initialize_numpy();
5969
// execute external wrappers
6070
wrap_libdiffpy_version();
6171
wrap_exceptions();

0 commit comments

Comments
 (0)