|
@@ -128,6 +128,28 @@ int write_python_table_native(ostream &out) {
|
|
|
out << "extern void Dtool_" << *ii << "_BuildInstants(PyObject *module);\n";
|
|
out << "extern void Dtool_" << *ii << "_BuildInstants(PyObject *module);\n";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ out.put('\n');
|
|
|
|
|
+
|
|
|
|
|
+ out << "#if PY_MAJOR_VERSION >= 3 || !defined(NDEBUG)\n"
|
|
|
|
|
+ << "#ifdef _WIN32\n"
|
|
|
|
|
+ << "extern \"C\" __declspec(dllexport) PyObject *PyInit_" << library_name << "();\n"
|
|
|
|
|
+ << "#elif __GNUC__ >= 4\n"
|
|
|
|
|
+ << "extern \"C\" __attribute__((visibility(\"default\"))) PyObject *PyInit_" << library_name << "();\n"
|
|
|
|
|
+ << "#else\n"
|
|
|
|
|
+ << "extern \"C\" PyObject *PyInit_" << library_name << "();\n"
|
|
|
|
|
+ << "#endif\n"
|
|
|
|
|
+ << "#endif\n";
|
|
|
|
|
+
|
|
|
|
|
+ out << "#if PY_MAJOR_VERSION < 3 || !defined(NDEBUG)\n"
|
|
|
|
|
+ << "#ifdef _WIN32\n"
|
|
|
|
|
+ << "extern \"C\" __declspec(dllexport) void init" << library_name << "();\n"
|
|
|
|
|
+ << "#elif __GNUC__ >= 4\n"
|
|
|
|
|
+ << "extern \"C\" __attribute__((visibility(\"default\"))) void init" << library_name << "();\n"
|
|
|
|
|
+ << "#else\n"
|
|
|
|
|
+ << "extern \"C\" void init" << library_name << "();\n"
|
|
|
|
|
+ << "#endif\n"
|
|
|
|
|
+ << "#endif\n";
|
|
|
|
|
+
|
|
|
out << "\n"
|
|
out << "\n"
|
|
|
<< "#if PY_MAJOR_VERSION >= 3\n"
|
|
<< "#if PY_MAJOR_VERSION >= 3\n"
|
|
|
<< "static struct PyModuleDef py_" << library_name << "_module = {\n"
|
|
<< "static struct PyModuleDef py_" << library_name << "_module = {\n"
|
|
@@ -139,14 +161,6 @@ int write_python_table_native(ostream &out) {
|
|
|
<< " NULL, NULL, NULL, NULL\n"
|
|
<< " NULL, NULL, NULL, NULL\n"
|
|
|
<< "};\n"
|
|
<< "};\n"
|
|
|
<< "\n"
|
|
<< "\n"
|
|
|
- << "#ifdef _WIN32\n"
|
|
|
|
|
- << "extern \"C\" __declspec(dllexport) PyObject *PyInit_" << library_name << "();\n"
|
|
|
|
|
- << "#elif __GNUC__ >= 4\n"
|
|
|
|
|
- << "extern \"C\" __attribute__((visibility(\"default\"))) PyObject *PyInit_" << library_name << "();\n"
|
|
|
|
|
- << "#else\n"
|
|
|
|
|
- << "extern \"C\" PyObject *PyInit_" << library_name << "();\n"
|
|
|
|
|
- << "#endif\n"
|
|
|
|
|
- << "\n"
|
|
|
|
|
<< "PyObject *PyInit_" << library_name << "() {\n";
|
|
<< "PyObject *PyInit_" << library_name << "() {\n";
|
|
|
|
|
|
|
|
if (track_interpreter) {
|
|
if (track_interpreter) {
|
|
@@ -184,15 +198,16 @@ int write_python_table_native(ostream &out) {
|
|
|
<< " return module;\n"
|
|
<< " return module;\n"
|
|
|
<< "}\n"
|
|
<< "}\n"
|
|
|
<< "\n"
|
|
<< "\n"
|
|
|
- << "#else // Python 2 case\n"
|
|
|
|
|
- << "\n"
|
|
|
|
|
- << "#ifdef _WIN32\n"
|
|
|
|
|
- << "extern \"C\" __declspec(dllexport) void init" << library_name << "();\n"
|
|
|
|
|
- << "#elif __GNUC__ >= 4\n"
|
|
|
|
|
- << "extern \"C\" __attribute__((visibility(\"default\"))) void init" << library_name << "();\n"
|
|
|
|
|
- << "#else\n"
|
|
|
|
|
- << "extern \"C\" void init" << library_name << "();\n"
|
|
|
|
|
|
|
+
|
|
|
|
|
+ << "#ifndef NDEBUG\n"
|
|
|
|
|
+ << "void init" << library_name << "() {\n"
|
|
|
|
|
+ << " PyErr_SetString(PyExc_ImportError, \"" << module_name << " was "
|
|
|
|
|
+ << "compiled for Python \" PY_VERSION \", which is incompatible "
|
|
|
|
|
+ << "with Python 2\");\n"
|
|
|
|
|
+ << "}\n"
|
|
|
<< "#endif\n"
|
|
<< "#endif\n"
|
|
|
|
|
+
|
|
|
|
|
+ << "#else // Python 2 case\n"
|
|
|
<< "\n"
|
|
<< "\n"
|
|
|
<< "void init" << library_name << "() {\n";
|
|
<< "void init" << library_name << "() {\n";
|
|
|
|
|
|
|
@@ -228,6 +243,15 @@ int write_python_table_native(ostream &out) {
|
|
|
|
|
|
|
|
out << " }\n"
|
|
out << " }\n"
|
|
|
<< "}\n"
|
|
<< "}\n"
|
|
|
|
|
+ << "\n"
|
|
|
|
|
+ << "#ifndef NDEBUG\n"
|
|
|
|
|
+ << "PyObject *PyInit_" << library_name << "() {\n"
|
|
|
|
|
+ << " PyErr_SetString(PyExc_ImportError, \"" << module_name << " was "
|
|
|
|
|
+ << "compiled for Python \" PY_VERSION \", which is incompatible "
|
|
|
|
|
+ << "with Python 3\");\n"
|
|
|
|
|
+ << " return (PyObject *)NULL;\n"
|
|
|
|
|
+ << "}\n"
|
|
|
|
|
+ << "#endif\n"
|
|
|
<< "#endif\n"
|
|
<< "#endif\n"
|
|
|
<< "\n";
|
|
<< "\n";
|
|
|
|
|
|