Embedding Python in Android – Compile C Cython extensions

28/04/2014

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.

Read the rest of this entry »

Embedding Python in Android – Compile C++ Cython extensions

28/04/2014

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.

Read the rest of this entry »

Embedding Python in Android – Standard Library

24/04/2014

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.

Read the rest of this entry »

Embedding Python in Android – Adding log to the Python Interpreter

21/04/2014

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.

Read the rest of this entry »

Embedding Python in Android – Python Interpreter

21/04/2014

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.

Read the rest of this entry »

Embedding Python in Android – JNI

21/04/2014

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).

Read the rest of this entry »

Embedding Python in Android (Tutorial series)

21/04/2014

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 »

bq Edison – Restore stock partitions

15/12/2012

If you mess around with an Android device, and you don’t use the Windows-based tools, chance are that one day you are going to brake something. And that is when setting your tablet’s partitions back to stock is important, whether you want to go back to the start, or sell your tablet, or return it to manufacturer because of some hardware problem. In this post I will show how to revert your bq Edison’s partitions back to stock, using the Windows-based tools. When I find how to do that in Linux too, I will add to this post.

Read the rest of this entry »

bq Edison ICS – Root (on any operating system)

14/12/2012

bqEdison_image

The bq Edison is an Android tablet built by the Spanish company bq. It is an affordable device with excellent specifications for its price, namely a Rockchip 3066 Dual-core SoC with a Mali 400 Quad-Core GPU, 16 GB internal SD, 1 GB Ram memory, and shipped originally with Ice Cream Sandwich. In this post I will show how the bq Edison can be rooted in a very simple way, in any of the major operating systems.

Read the rest of this entry »

Install Mac OS X (Snow Leopard) in Virtualbox 4.2 (EFI Method)

04/12/2012

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.

efi

Read the rest of this entry »


Follow

Get every new post delivered to your Inbox.