Skip to Content

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:

https://github.com/SAP/hana-xsa-python-buildpack

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 CloudFoundry.org 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.

https://www.sap.com/developer/topics/sap-hana-express.html

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

https://github.com/SAP/hana-xsa-python-buildpack

You should follow the repo’s README.md 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 create_my_python_buildpack.sh 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/build.sh 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)

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply