Showing the changes to python (1 of 1 file). Show all
Unified · Split
| @@ -248,10 +248,25 @@ static PyMethodDef aubio_methods[] = { · 247 unmodified lines | |||
| 248 | {NULL, NULL} /* Sentinel */ | 248 | {NULL, NULL} /* Sentinel */ |
| 249 | }; | 249 | }; |
| 250 | 250 | ||
| 251 | PyMODINIT_FUNC | 251 | #if PY_MAJOR_VERSION >= 3 |
| 252 | init_aubio (void) | 252 | // Python3 module definition |
| 253 | static struct PyModuleDef moduledef = { | ||
| 254 | PyModuleDef_HEAD_INIT, | ||
| 255 | "_aubio", /* m_name */ | ||
| 256 | aubio_module_doc, /* m_doc */ | ||
| 257 | -1, /* m_size */ | ||
| 258 | aubio_methods, /* m_methods */ | ||
| 259 | NULL, /* m_reload */ | ||
| 260 | NULL, /* m_traverse */ | ||
| 261 | NULL, /* m_clear */ | ||
| 262 | NULL, /* m_free */ | ||
| 263 | }; | ||
| 264 | #endif | ||
| 265 | |||
| 266 | static PyObject * | ||
| 267 | initaubio (void) | ||
| 253 | { | 268 | { |
| 254 | PyObject *m; | 269 | PyObject *m = NULL; |
| 255 | int err; | 270 | int err; |
| 256 | 271 | ||
| 257 | // fvec is defined in __init__.py | 272 | // fvec is defined in __init__.py |
| @@ -265,13 +280,17 @@ init_aubio (void) · 7 unmodified lines | |||
| 265 | // generated objects | 280 | // generated objects |
| 266 | || (generated_types_ready() < 0 ) | 281 | || (generated_types_ready() < 0 ) |
| 267 | ) { | 282 | ) { |
| 268 | return; | 283 | return m; |
| 269 | } | 284 | } |
| 270 | 285 | ||
| 286 | #if PY_MAJOR_VERSION >= 3 | ||
| 287 | m = PyModule_Create(&moduledef); | ||
| 288 | #else | ||
| 271 | m = Py_InitModule3 ("_aubio", aubio_methods, aubio_module_doc); | 289 | m = Py_InitModule3 ("_aubio", aubio_methods, aubio_module_doc); |
| 290 | #endif | ||
| 272 | 291 | ||
| 273 | if (m == NULL) { | 292 | if (m == NULL) { |
| 274 | return; | 293 | return m; |
| 275 | } | 294 | } |
| 276 | 295 | ||
| 277 | err = _import_array (); | 296 | err = _import_array (); |
| @@ -300,4 +319,20 @@ init_aubio (void) · 22 unmodified lines | |||
| 300 | 319 | ||
| 301 | // add ufunc | 320 | // add ufunc |
| 302 | add_ufuncs(m); | 321 | add_ufuncs(m); |
| 322 | |||
| 323 | return m; | ||
| 303 | } | 324 | } |
| 325 | |||
| 326 | #if PY_MAJOR_VERSION >= 3 | ||
| 327 | // Python3 init | ||
| 328 | PyMODINIT_FUNC PyInit__aubio(void) | ||
| 329 | { | ||
| 330 | return initaubio(); | ||
| 331 | } | ||
| 332 | #else | ||
| 333 | // Python 2 init | ||
| 334 | PyMODINIT_FUNC init_aubio(void) | ||
| 335 | { | ||
| 336 | initaubio(); | ||
| 337 | } | ||
| 338 | #endif | ||