Code samples for XSA Python runtime
Branch: master
Clone or download
Latest commit 24707a9 Feb 11, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.

SAP HANA Academy

Setup Python Runtime for XSA

Tutorial Video

Setup Python Run Time for XSA

In the video tutorial, we show how you how to prepare the OS environment, how to build Python and create the runtime. A simple test script generates a sample app to validate all is well in the best possible worlds.

Tutorial Video Playlist

The tutorials has been posted to the following playlist:

SAP HANA, express edition on GCP

We used the SAP HANA, express edition on Google Cloud Platform ( for this sample code. You can use the following commands to download the sample code to your system.

sudo -i
su - hxeadm
cd $HOME
git clone
cd python
chmod u+x *.sh

Compilers and More

The SAP HANA Developer Guide documents the following packages as requirements:

# as root
zypper install tk-devel tcl-devel libffi-devel \
 openssl-devel readline-devel sqlite3-devel \
 ncurses-devel xz-devel zlib-devel

In addition, you can install the Basis-Devel pattern for the compilers and dependencies. Patterns differ per repository, so should Basis-Devel not be present, try and search for an equivalent.

# as root
zypper search -t pattern 
zypper in -t pattern Basis-Devel

Create Runtime

You can download the Python source code from There are many versions available. In the create runtime script, we take the version (e.g. 3.8.0, 3.6.5) as input together with any suffix (e.g. a01, rc1). The SUSE Linux operating system comes with a Python version installed as does SAP HANA, express edition. To avoid any interference with these installation, run "make altinstall" and configure with prefix.

Note that the path here is a hardcoded HXE. If you are not using the express edition, change the path to the SID.

if [[ $# -eq 0 ]] ; then
    echo 'Usage:'
    echo ' [release] [suffix]'
    echo 'See'
    echo 'Examples:'
    echo ' 3.7.2'
    echo ' 3.7.2 rc1'
    echo ' 3.8.0 a1'
    exit 0

# create work directories
cd ~ ; mkdir -p builds source Downloads
# download source to Downloads
wget -P ~/Downloads -N$1/Python-$1$2.tgz
# extract to source
tar xzvf ~/Downloads/Python-$1$2.tgz -C ~/source
# configure to "install" in builds directory
cd ~/source/Python-$1$2
./configure \
--prefix=/usr/sap/HXE/home/builds/Python-$1$2 \
--exec-prefix=/usr/sap/HXE/home/builds/Python-$1$2 \
# make, install and cleanup
make altinstall clean
# Upload runtime and list
xs create-runtime -p ~/builds/Python-$1$2
xs runtimes

Test Runtime

The test script generates the required files for a simple Hello World python script.

if [[ $# -eq 0 ]] ; then
    echo 'Usage:'
    echo ' "release"'
    echo 'e.g.: 3.8.0'
    exit 0

cd ~; mkdir -p pyapp; cd pyapp
# create runtime.txt
cat > runtime.txt <<EOF
export python-$1
# create requirements.txt
cat > requirements.txt <<EOF
# create manifest.yaml
cat > manifest.yml << EOF
- name: pyapp
  host: pyapp
  path: .
  command: python
# create
cat > << EOF
import os
from flask import Flask
app = Flask(__name__)
port = int(os.environ.get('PORT', 3000))
def hello():
    return "Hello World from Python $1"
if __name__ == '__main__':

To upload the app, we switch to the development space and push (upload) the app to the runtime. For housekeeping, we delete the app first (if present). Note that “development” is one of the spaces available out-of-the-box with SAP HANA, express edition. If you are working on a regular platform edition, you might need to change the name otherwise xs push will default to the ‘SAP’ space (not recommended).

# switch to development space, delete any existing pyapp, upload app
xs target -s development
xs delete -f pyapp
xs push

For the documentation, see