Installing Python Application in OpenShift PaaS needs some modification and custom commands as you might not able to run. Here are some tips for Python. Basically Python is a high-level programming language, usages can be quite complex scientific usage and OpenShift is a great platform to test whether a Python App is running rightly or not.
Installing Python Application in OpenShift PaaS : Basic Needs
For Installing Python App, at minimum you will need :
- Some experience with Python in ‘normal’ situation
- The OpenShift Command Line Tool
- A new App instance created in OpenShift
- OS X Terminal or iTerm2 (I prefer), Terminal in Linux or PuTTY in Windows (Read the Guide for PuTTY)
Steps For Installing Python Application in OpenShift PaaS
First, you can create an Python instance either from command line or from the web Interface. Python 2.7 is official, Python 3.3 is community edition. After creating the instance, first SSH to to OpenShift’s that instance , for example :
---
1 | ssh 51737db8500446f9b9000020@pn-abhishekghosh.rhcloud.com |
number, namespace ( on-abhishekghosh) are variables, you will get the url from web interface. Change Directory to temporary folder (copy-paste / type exactly) :
1 | cd $OPENSHIFT_TMP_DIR |
For example, I want to deploy this instance from github :
1 | https://github.com/AbhishekGhosh/Neural-Genetic-Algorithm |
Obviously, I can either clone the git or wget the zip file or add the remote git as source from web interface. wget is less complex. The application is actually not made for extra changes neded for OpenShift. We are taking that you have used web interface to install Python as cartridge.
You can run which python command to check whether Python rightly got installed. In the temporary dir (we have changed directory before) :
1 | wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz |
Untar it :
1 | tar zxf setuptools-0.6c11.tar.gz |
Remove the compressed file :
1 | rm -r setuptools-0.6c11.tar.gz |
Go to the folder :
1 | cd setuptools-0.6c11 |
When you will run :
1 | /bin/python setup.py install |
It is the uncanny official method. It will actually point you towards system default Python directory. The version will be different and will ask for root access. You might expect an easy installation. But it will never happen. For this reason there are few ways :
Your App root is here :
1 | /var/lib/openshift/51737db8500446f9b9000020/app-root/ |
Except the digit (
1 | 51737db8500446f9b9000020 |
) part, others are constant. Instead install the modules from the build action hook :
1 2 3 4 5 6 7 | # .openshift/action_hooks/build # # example # # #!/bin/bash MESSAGES_PATH=$HOME/python-2.6/virtenv/lib/python2.6/site-packages/django-messages-patch-src git clone git://github.com/jpardobl/django-messages-patched.git $MESSAGES_PATH ln -s $MESSAGES_PATH/django_messages $HOME/python-2.6/virtenv/lib/python2.6/site-packages/messages |