I want to include a c++-library in my kivy python app. It is possible to automatically do that with swig and distutils, which effectively generates a .pyd python library out of the c++ code. On windows that works without any problems: I included the .pyd file in my Kivy app and everything runs, but I want to run the program on mobile devices as well.
So my problem is how I can generate a python library which is compatible with android (arm) and includes the c++-code I need.
I already asked a different question about how I can cross-compile python code for arm on windows x86_64. There someone recommended Chaquopy. That seems to work, but of course only with python as source code, not with c++.
For the library creation process with swig and distutils I created a 'setup.py' which takes the output from swig and builds the .pyd library. Is it possible to modify that to compile for arm?
#!/usr/bin/env python
"""
setup.py file for SWIG
"""
from distutils.core import setup, Extension
example_module = Extension('_HelloCpp',
sources=['HelloCpp_wrap.cxx', 'HelloCpp.cpp'],
extra_compile_args = ["-std:c++17"]
)
setup (name = 'HelloCpp',
version = '0.1',
author = "simonsays",
description = """Simple swig test with HelloCpp""",
ext_modules = [example_module],
py_modules = ["HelloCpp"],
)
I also stumbled over this Github repository: Virtual Environments for Cross-Compiling Python Extension Modules. Do I need that to compile Python for Android or is there a different approach?