Host Python in a Community Cart - Archived

Python hosting in community carts on OpenShift picture

Greetings Shifters! Today I am announcing the availability of Python 2.7 and Python 3.3 on OpenShift as part of our Community Cartridge program (or community carts for short). There are two goals to today’s announcement:

1) Make it easier for OpenShift devs to use more versions of Python in the cloud
2) Begin the process of fleshing out our community cartridges.

We are making it easier for contributors to add new community authored cartridges for use in the full suite of OpenShift projects Origin, Online, and Enterprise.Python hosting in community carts on OpenShift picture

Greetings Shifters! Today I am announcing the availability of Python 2.7 and Python 3.3 on OpenShift as part of our Community Cartridge program (or community carts for short). There are two goals to today’s announcement:

1) Make it easier for OpenShift devs to use more versions of Python in the cloud
2) Begin the process of fleshing out our community cartridges.

We are making it easier for contributors to add new community authored cartridges for use in the full suite of OpenShift projects Origin, Online, and Enterprise. Right now community cartridges are an experimental feature until our new cartridge format is fully integrated into production, which should be some time early Q2 this year.

To kickoff the community cartridges we have built community cartridges for Python 2.7 and for Python 3.3. We will be rolling out non-community cartridges for these versions of Python later this year, but we thought Python would be a great place to start. There have been many requests for a new version of our default Python cartridge (at 2.6). Using Python as our inaugural community cartridges was a great way to achieve more current versions of Python along with getting community feedback on the new community cart capability.

How to use the new community cartridges

Ok well, there is not really much to show here since it is so easy.

If you want to build the suspense you can go listen to this wav file

rhc app create newpythonapp python-2.7

or if you want 3.3

rhc app create evennewerpythonapp python-3.3

That’s it – finito! So there is nothing special to using community carts, you reference them just like any other cart.

If you want to take the MongoDB Spatial + Python application for a spin – my coworker Linqing ported it to GitHub quickstart using Bottle instead of Flask for Python 3.3.

They may take longer to spin up than our default cartridges because when you use them, the entire contents of the cartridge is coming from GitHub. Here is the Python 2.7 cartridge and here is the Python 3.3 cartridge in GitHub. One of the side effects of this right now, is that sometimes your app may not get created before the timeout. If this happens please just execute the rhc command again. As this moves out of preview status we will be optimizing start up time to remove this problem.

To show the flexibility of these new community cartridge we are actually using a different web layer than Apache in these cartridges. We are using gevent which is another Python web server for Python 2.7. For Python 3.3 we are using WebOb.

Two other things to keep in mind. Because of the way the carts are done OpenShift actually activates the virtualenv before the first git push. This means the environment is already set up for you. If you ssh in and want to use the virtualenv just do this at the command prompt:

source python-2.7/activate_virtenv

Second, some of our GitHub quickstarts, like this Flask one have a hard coded path to the Python virtual env and runtime, as you can see here. Notice in the setup script for the cartridge some of those environment variables are set. Either way you will need to change the applications to fit the new Python environment.

The goal at the end of this preview phase of community cartridges is to allow you, the developer, to specify any community cart in GitHub to create your application in OpenShift Online. If someone builds a community cartridge with Erlang, you would just pass in the GitHub location and away you go. You like what they did as a base but you want to tweak it a bit; fork their repository, modify it, and then create your application using your forked repository.

To infinity and beyond

Short term goals

Our main goal in the near term is to get feedback on current community cartridge model and how people would like to see this expand. Currently our community carts are a hybrid of our old cartridge format and our forthcoming cartridge format. While we wait for the new cartridge format to land in production, we would love to get your feedback on what you would like to see from the community cartridges.

Specifically, what do you think about:
1) Ease of writing
2) Ease of using
3) Process of getting a custom cartridge into hosted
4) What level of support you would expect for these carts

Longer term goals

Over time we hope to build a robust group of partners and developers creating cartridges for a wide array of technology. Since the new cartridge format is more powerful than our current DIY (it will allow opening intraports between gears, the ability to scale the gears, and more robust life-cycle hooks), we hope to see things like a Redis cartridge or a MemCache cartridge or a Twisted cartridge or a NGINX cartrdige. I would personally love to see cartridges for TileMill/MapBox, MapServer, and Neo4J with spatial support.

Either way, we hope you enjoy the new Python carts and you should be getting excited about all the new cartridges coming down the pipe! Leave your feedback here in the comments or in this forum thread.

Categories
Python
Tags
,
Comments are closed.