Using Python plug-ins with the Apama Core installation

We introduced Python plug-ins for EPL in this post. The full community installation provides a Python installation, but users of the community core package will need to provide their own. Today we’re going to explore how to do this on various common operating systems.

Configuring Apama to use an external Python

By default Apama will look inside the installation to locate a copy of the Python library when loading Python plug-ins. In order to load one in another location you can set the AP_PYTHONHOME environment variable. It should be set to the location in which you installed Python.

Note that you will need to install exactly Python 3.6. Apama does not support other versions of Python.

If you have correctly installed and configured Python you will see in the correlator log that it has loaded the correct version of Python:

Installation of Python on common operating systems

On the latest release of each of the major Linux distributions, Python 3.6 can be installed using the system package manager.

Ubuntu Linux Bionic (18.04 LTS)

Python 3.6 is available in the standard repository and can be installed simply with:#

This will enable support for running both the Pysys test framework and other Python-based tools included in the Apama distribution, and also Python EPL plug-ins.

Ubuntu Linux Xenial (16.04 LTS)

For the Xenial 16.04 release of Ubuntu, Python 3.6 is not available in the main repository, but can be accessed via a PPA:

This will enable support for running both the Pysys test framework and other Python-based tools included in the Apama distribution, and also Python EPL plug-ins.

Debian Buster (10 Testing)

Python 3.6 is available in the standard repository and can be installed simply with:

This will enable support for running both the Pysys test framework and other Python-based tools included in the Apama distribution, and also Python EPL plug-ins.

CentOS 7 / RHEL 7

RHEL 7, and therefore CentOS, does not include Python3.6 in the standard repository. Instead it is accessible from the EPEL repositories. In addition, the Python 3.6 packages in those repositories don’t by default provide Python via the python3 name, but only via python3.6.

This will enable support for running both the Pysys test framework and other Python-based tools included in the Apama distribution, and also Python EPL plug-ins.

OpenSuse Leap 15.0 / SLES 15.0

Python 3.6 is available in the standard repository and can be installed simply with:

This will enable support for running both the Pysys test framework and other Python-based tools included in the Apama distribution, and also Python EPL plug-ins.

Windows

To install Python on Windows we recommend downloading the installation package from https://www.python.org/downloads/windows/. You need to download the Python 3.6.6 x86-64 executable installer.

Run the Python installer with the default options but also select ‘Add to PATH’.

You will also need to install the PyWin32 extensions. Once you’ve installed Python, start a command prompt and run:

Finally, configure Apama to use the installation. If you installed to a non-default location you will need to change the path you use:

This will enable support for running both the Pysys test framework and other Python-based tools included in the Apama distribution, and also Python EPL plug-ins.

Older/other Linux distributions

Other Linux distributions based on the appropriate versions above of the major distributions should be able to install packages in the standard fashion listed above. If you’re using a non-standard distribution first consult your distribution packaging to see whether you can install it via their packages. If you can then it’s likely that after you do so you can run the correlator just by using:

If Python is not available packaged, or you are using an older release of the distribution which only has an older version of Python available, then you may need to build from source. This definitely applies to Debian Stretch (9, the latest stable release at time of writing), Debian Jessie (8), Ubuntu Trusty (14.04 LTS), OpenSuse Leap 42.3, SLES 12.3 and versions of Raspian based on Debian Jessie or Stretch.

On these distributions you will first need to install the dependencies necessary to build Python, then get the Python sources, build and install it.

On Debian, Ubuntu or Raspian systems you can install the dependencies with:

On OpenSuse Leap or SLES systems you can install the dependencies with:

On other systems you will need to consult your package manager documentation for how to install the dependencies.

Once you have the dependencies the instructions are the same on all operating systems.

This will enable support for running both the Pysys test framework and other Python-based tools included in the Apama distribution, and also Python EPL plug-ins.

Installing in Docker

Dockerfiles for all of the above Linux distributions can be found on https://github.com/mjj29/linux-python-apama-docker which demonstrate adding Python to the base operating system, adding an installation of Apama Core and adding a trivial Apama project to demonstrate that Python can be loaded and run.

For further information on how to use Python plug-ins from EPL please check out our other blog posts, the documentation available on http://www.apamacommunity.com/ or post with the “apama” tag on https://stackoverflow.com/questions/tagged/apama. See you next time.

— Matt