1 #include "rpmsystem-py.h"
7 static char rpmb__doc__[] =
11 Do any common preliminary work before python 2 vs python 3 module creation:
13 static int prepareInitModule(void)
15 if (PyType_Ready(&spec_Type) < 0) return 0;
16 if (PyType_Ready(&specPkg_Type) < 0) return 0;
21 static int initModule(PyObject *m)
23 Py_INCREF(&spec_Type);
24 PyModule_AddObject(m, "spec", (PyObject *) &spec_Type);
25 Py_INCREF(&specPkg_Type);
26 PyModule_AddObject(m, "specPkg", (PyObject *) &specPkg_Type);
31 #if PY_MAJOR_VERSION >= 3
32 static struct PyModuleDef moduledef = {
33 PyModuleDef_HEAD_INIT,
35 rpmb__doc__, /* m_doc */
39 NULL, /* m_traverse */
44 PyObject * PyInit__rpm(void); /* XXX eliminate gcc warning */
45 PyObject * PyInit__rpm(void)
49 if (!prepareInitModule())
51 m = PyModule_Create(&moduledef);
52 if (m == NULL || !initModule(m)) {
59 void init_rpmb(void); /* XXX eliminate gcc warning */
64 if (!prepareInitModule())
67 m = Py_InitModule3("_rpmb", NULL, rpmb__doc__);