The pre-built Linux image provided by Toradex is built on top of the Ångström distribution. It comes with a package manager (opkg) and the Ångström feeds already configured, which enables the installation of packages in an existing image. It is a good starting point for quick prototypes and tests.

To see a list of relevant packages, enter the following commands:

opkg update
opkg list | grep python

Python (and any additional packages) may be installed with the following command:

opkg install python [optionally list additional packages...]

The same applies for Python 3. The packages are usually referred as python3-package, for instance python3-pyserial.

A set of python packages can be added to an OpenEmbedded Linux build for inclusion into the image's root file system. After establishing the image build configuration, additionally append the following line to the oe-core/build/conf/local.conf file:

local.conf

IMAGE_INSTALL_append = "python"

Then execute (or re-execute) 'bitbake' for the image (ie. 'bitbake angstrom-lxde-image'). For more information about building a Linux image, see OpenEmbedded (core).

Even if you are starting with OpenEmbedded, writing recipes for Python modules is usually straightforward. There are many recipes out there that do it for you to use as examples and their structure looks very alike.

A possible path for writing a recipe is provided below. We use the TinyDB 3.7.0 release for illustration:

Tests results are pending; however, Python is expected to perform at least an order of magnitude slower than equivalent compiled C/C++ code due to Python's run-time interpreted nature. Use of a Just-in-Time or Ahead-of-Time compiler should improve performance; however, such compilers have not been tested with our Linux images.

Regardless, Python is still a viable alternative for performing lighter processing tasks. It can be effective for low level IO operations as well as high level applications such as web services. Furthermore, Python code can be rapidly modified and tested without the need to recompile.