0

I need to compile my c extension that is invokable by python in kodi. Can anyone please list the steps involved. I think I have actually cross compiled the c extension but it wouldn't work with kodi.

bir433
  • 61
  • 5
  • I hate trying to debug this kind of crap :( ... sorry not helpful, but I feel for you :( – Joran Beasley Apr 28 '15 at 18:24
  • Thanks Joran... Actually I need to put the dependency of my .so file on the libkodi.so so that it finds symbols for python from within there. Wondering if there is a way. – bir433 Apr 28 '15 at 20:13
  • wish i could help but the only way I can compile anything is following someone elses instructions and hoping i get them right :/ – Joran Beasley Apr 28 '15 at 20:15

1 Answers1

0

Sorry that I cannot provide you specific steps, but from what I know building binary modules for Kodi-Android is not a trivial task. Here's what I know:

  • You need to use Python.h from the Python sources used for Kodi's built-in interpreter.
  • You need to link against libkodi.so to find necessary Python symbols.
  • This is important: import mechanism for binary nodules in Kodi-Android is broken.

If you use:

import foo

Kodi-Android will actually search for libfoo.so because it automatically appends lib- when searches for shared library files and your import will fail. Simple renaming foo.so to libfoo.so won't help because the name must match the module declaration, for example:

PyMODINIT_FUNC
initspam(void)
{
    (void) Py_InitModule("libfoo", SpamMethods);
}

Only if the module declaration "libfoo" matches the filename libfoo.so ("lib-" part is mandatory for Kodi-Android), then the import should succeed provided there are no other pitfall. As I've said, it's not a trivial task.

BTW, you can build a pure C shared library and use ctypes, and don't mess with all this broken Python-C modules stuff. Naturally, your library name must start with "lib-" (again, this is mandatory for Kodi-Android) but using shared libs via ctypes is easier provided your library doesn't have external dependencies.

UPD: I forgot about permission issues. Android does not allow to import binary modules from everywhere. Kodi's temporary directory is known to work but not always. Again, as far as binary Python modules concerned, Kodi-Android is a totall mess.

Roman Miroshnychenko
  • 1,496
  • 1
  • 10
  • 16