diff modules-and-plug-ins/python-module/btrack_python_module.cpp @ 110:0fdaf082ad1a

Got compiling on M1 mac and Python 3
author Adam Stark <adamstark.uk@gmail.com>
date Sun, 31 Oct 2021 23:34:44 +0000
parents ce806db4468b
children
line wrap: on
line diff
--- a/modules-and-plug-ins/python-module/btrack_python_module.cpp	Sat Dec 30 23:48:41 2017 +0000
+++ b/modules-and-plug-ins/python-module/btrack_python_module.cpp	Sun Oct 31 23:34:44 2021 +0000
@@ -292,21 +292,30 @@
 };
 
 //=======================================================================
-PyMODINIT_FUNC initbtrack(void)
+static struct PyModuleDef btrack_definition = {
+    PyModuleDef_HEAD_INIT,
+    "btrack",
+    "Python bindings for the BTrack beat tracker",
+    -1,
+    btrack_methods
+};
+
+//=======================================================================
+PyMODINIT_FUNC PyInit_btrack(void)
 {
-    (void)Py_InitModule("btrack", btrack_methods);
     import_array();
+    return PyModule_Create(&btrack_definition);
 }
 
 //=======================================================================
 int main(int argc, char *argv[])
 {
-    /* Pass argv[0] to the Python interpreter */
-    Py_SetProgramName(argv[0]);
+    wchar_t* program = Py_DecodeLocale (argv[0], NULL);
+    Py_SetProgramName (program);
     
     /* Initialize the Python interpreter.  Required. */
     Py_Initialize();
     
     /* Add a static module */
-    initbtrack();
+    PyInit_btrack();
 }
\ No newline at end of file