Build certgen in py3

This commit is contained in:
Flaviu Tamas 2018-08-24 02:01:04 -04:00
parent 79d7658ea3
commit e9603e27bf

View File

@ -379,15 +379,36 @@ static PyMethodDef certgen_methods[] = {
}; };
CALIBRE_MODINIT_FUNC #if PY_MAJOR_VERSION >= 3
initcertgen(void) { #define INITERROR return NULL
PyObject *m; static struct PyModuleDef certgen_module = {
m = Py_InitModule3("certgen", certgen_methods, /* m_base */ PyModuleDef_HEAD_INIT,
"OpenSSL bindings to easily create certificates/certificate authorities" /* m_name */ "certgen",
); /* m_doc */ "OpenSSL bindings to easily create certificates/certificate authorities.",
if (m == NULL) return; /* m_size */ -1,
/* m_methods */ certgen_methods,
/* m_slots */ 0,
/* m_traverse */ 0,
/* m_clear */ 0,
/* m_free */ 0,
};
CALIBRE_MODINIT_FUNC PyInit_certgen(void) {
PyObject *mod = PyModule_Create(&certgen_module);
#else
#define INITERROR return
CALIBRE_MODINIT_FUNC initcertgen(void) {
PyObject *mod = Py_InitModule3("certgen", certgen_methods,
"OpenSSL bindings to easily create certificates/certificate authorities");
#endif
if (mod == NULL) INITERROR;
OpenSSL_add_all_algorithms(); OpenSSL_add_all_algorithms();
ERR_load_crypto_strings(); ERR_load_crypto_strings();
ERR_load_BIO_strings(); ERR_load_BIO_strings();
}
#if PY_MAJOR_VERSION >= 3
return mod;
#endif
}