Skip to Content
Author's profile photo Andrew Lunde

XSA Python Buildpack and MTA Example

Update: HANA2 SP03 now ships with a working python buildpack which renders this blog post useless unless you’re looking for an example as a basis for creating buildpacks for other languages.



While the HANA documentation gives some guidance as to how to create your own buildpacks to support custom run-time environments, to date there hasn’t been a stand-alone example that illustrates the concept in action.  This post intends to fill the gap for developers wishing to use the python programming language as a component to their HANA XS-A(on-prem) and SAP Cloud Foundry Cloud Platform(SAP CFCP) development scenarios.

This post refers to the HANA XS Advanced on-premise python buildpack that can be found at:

From the repo’s README:

This Buildpack adds support for modules based on Python code to a HANA XS Advanced system. If you want to deploy your Python to a Cloud Foundry based multi-tenant system such as SAP Cloud Foundry Cloud Platform or Pivotal Cloud Foundry, this buildpack WILL NOT WORK! For those Cloud Foundry based deployment environments, use the community Python Buildpack documented at Python Buildpack.

Now that the disclaimer is out of the way, let’s discuss the current gap (as of the writing of this post).

As of HANA2 SPS02, the development environment for XS Advanced Multi-Target Applications (MTAs) contains support for two programming languages, Java, and NodeJS(Javascript).  Application developers who need to run python code were forced to run it external of the HANA XS-A environment.  This then becomes a custom solution and is inherently limited in it’s deployment opportunities.  Currently the SAP Cloud Foundry Cloud Platform inherits a set of buildpacks from the open source community including one for python as well as now includes two key services (XSUAA and HANA) that bring it in alignment with the set of services available in the on-premise version of HANA.

By providing an on-premise python buildpack, both environments have parity in terms of language support and underlying services for cases where these are the main requirements.  Applications built using the on-premise MTA tooling can be then deployed also into the SAP CFCP environment without modification….Deploy Nirvana.

The hitch is that the SAP CFCP doesn’t currently include any developer tooling for creating an MTA from scratch while the HANA on-prem solution does.  The good news is that a developer version of the HANA on-prem system is freely available as HANA Express and can be downloaded from here.

The rest of this post will focus on the details of the python buildpack itself and leave the exercise of deploying to SAP CFCP for another post.

The first thing to do is to find a HANA on-prem system (HANA Express or otherwise) and log into the WebIDE.  This by default is running on port 53075 if your installation is in port mapping mode.

Using the Git->Clone Repository feature, pull this repo into the WebIDE using https(not ssh).

You should follow the repo’s file for detailed steps as it will be more up to date that this post, but the general flow of steps you should follow are these.

  1. Build the db module so that the hdi-container is created.
  2. Create a service-instance of the xsuaa for this example app.
  3. Build and run the js module which provides and example of using ODATA to access the hdi-container and a target for the app-router.
  4. Build and run the web module to provide an app-router and handle authorizations.
  5. Test that the application runs and can access the js module features.
  6. Clone the same repo in a location where you can run the XS CLI program.
  7. Change into the tools directory and run the script and follow it’s instructions for installing the python buildpack into your system.
  8. Change back to the main directory and run the tools/ script to perform the steps needed to build the python module and remap the app-router as the python module’s port may change between builds.
  9. Test the application again, this time exercising the python module and verifying that the request is validated and that database can be accessed.

From this point you have a functional example using python in a module.  In order to deploy your project into SAP CFCP, you will need to build a complete MTAR file and use the “cf deploy” command.  The details of this are outside the scope of this post, but it is possible and a good use case for continuous integration.

In the future the WebIDE should be extended such that the build steps for python modules can be triggered from within the WebIDE, but today this isn’t the case.

The same dilemma exists for any other programming language (PHP, Ruby, Swift, Go, Erlang, Modula2, Lisp, etc.).  Until there is buildpack support for these languages and the WebIDE can accommodate the build process required for each, there will be a need to handle the assembly and deployment of such scenarios manually.

Please see the buildpack repo for details and understand that this is an experimental buildpack and as such is NOT supported by SAP directly so please post any questions to the SAP Community Network.

If you will be attending TechEd in 2017 in Las Vegas, please join my session on this topic.

HDB100 – SAP HANA Extended Application Services and BYOL (Bring Your Own Language)

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Markus Theilen
      Markus Theilen

      Hi, Andrew!

      Thank you for this post, as it complements the instructions in python buildpack repo quite nicely for me.

      My question is: Do you see any chance that Python (preferable in a 3.x version) will be put on the list of offically supported buildpacks soon?

      If you are working as a data scientist, the combination of HANA and all the cool Python frameworks looks really interesting. And to be honest, you will probably find way more data scientist that are fluent in Python as compared to the ones that live and breath PAL, SAP PA and the rest of the predictive analytics tool family for HANA.


      Thank you, Markus

      Author's profile photo Andrew Lunde
      Andrew Lunde
      Blog Post Author

      Hey Markus,

      Thanks for the comment.  Fuller Python support from an SAP official perspective is in the works, but I can't relate any details at this point.  So keep an eye out as SP03 gets closer.  I'll relate anything I can as I'm able.