In the previous posts of this tutorial series, I’ve shown how to cross compile and embed Python in Android. In my last post I’ve also shown how to build and deploy C++ Cython extensions. In this post, I will show how simple is to create a regular C Cython extension and set it up to run on embedded Python for Android.
In the previous posts of this tutorial series, I’ve shown how to cross-compile Python from Android (using Kivy’s Python-for-Android project), deploy some scripts and needed libraries to the device and start the Python interpreter. Thus, if you have pure python modules, at this time you have everything needed to deploy an embedded python Android application – just copy your python modules somewhere inside the assets/ folder and take care of system paths. However, if you want to use compiled extensions, you will have to cross-compile them to Android. In this post, I will show how you can cross-compile a C++ Cython extension to use on your embedded python interpreter in Android.
On the previous posts I’ve shown how to cross-compile Python for Android, build a native interface for accessing the interpreter from Java code and run some code. However, I still haven’t show how to include modules from the standard library. For instance, the following code produces the following output:
PyRun_SimpleString("import this"); ... I/pyjni ( 9460): Traceback (most recent call last): I/pyjni ( 9460): File "<string>", line 1, in <module> I/pyjni ( 9460): ImportError: No module named this
In this post, I will show how to include modules from the standard library on our embedded Python Android app.
If you have followed the previous post on this tutorial series, you now have a Python interpreter embedded in your Android application. Before we move on to fix the Python standard library, in this post we are going to set up some code to allow “prints” inside Python to be redirected to the Android logcat. The source code is adapted from the bootstrap code for python-for-android.
In the previous post, i have shown how to create an Android application which uses the Java Native Interface to interface with C/C++ code. Specifically, we have created a Java class which exports a native “square(int)” method which returns the square of a number computed in native code. In this post, I will show how to do something similar, but using an embedded Python interpreter to do the calculations. Since we are going to use CPython, the official Python interpreter in C, we must use JNI again to interface with it.
In this tutorial I will show how to write an Android application which uses the Java Native Interface to access native code in C/C++. This will be useful later because we will access our Python interpreter from Java through JNI and C/C++. Our application will be able to compute the square of a number in C/C++ and print it on the Android log. I will assume that the readers know the basic structure of an Android application source code layout, have access to an Android device or simulator, and to its log (logcat).
In the last months I have been implementing a Python library for a cross-platform application of mine. I’ve chose Python for many reasons: it is cross-platform, allows for fast development, has very concise code and great standard library, has many extensions, it is quite popular, and allows to interface with C/C++ using projects such as Cython. Cython lets you write extensions in C/C++ or interface with existing C/C++ libraries in a relatively easy way. Read the rest of this entry »
Yesterday I’ve published a post on how to install Mac OS X – Snow Leopard - in Virtualbox 4.2 using external boot loaders. Unfortunately that method causes a lot of kernel panics and is not reliable because sometimes it boots successfully, sometimes it does not. In this post I will show another way of installing Snow Leopard in Virtualbox, but using the EFI method. With this method your Mac OS virtual machine will be more reliable, and you will be able to do basic things from the Operating System such as reboots, shutdowns and the simple “About my Mac”. The only downside so far is that it seems you won’t be able to set screen resolutions outside of 640×480, 800×600, 1024×768, 1280×1024 and 1440×900.