Posted on August 4, 2011 by

CloudFoundry Python Support

I am very interested by VMWare’s CloudFoundry Platform solution because it is open to any infrastructure, including private clouds. Its also open source, and there are many people involved in building it up. It is built on Ruby, and therefore has its strongest roots in the Ruby community, but there are also some Python folks involved.

I went to Garethr’s Github page (his blog is here) to check out his additions to CloudFoundry. He has made commits to support Django and WSGI. It took a little bit of tinkering, but these seem to be reproducible steps to create a Python install.

First
Start off by following VMWare’s installation instructions. You want the latest version of vcap installed and tested before we go further. When I try to pull from anyone else’s git repo I end up having problems with Ruby and rvm that I don’t fully understand.

Grab Garethr’s Modifications
Now you can pull in the modifications from Garethr’s repo. In the vcap directory:
git remote add garethr git://github.com/garethr/vcap
git fetch garethr
git merge garethr/master

I ended up with a conflict in cloud_controller/app/models.app.rb (two line conflict, just remove the lines without Python options). At this point I also tried to merge the garethr/django-gunicorn branch, but I was told everything is up to date. His commits seem to indicate he has already merged that branch into master a couple months ago, so no need to worry.

Grab gunicorn/django/virtualenv/web.py
The next problem you will encounter (using my method) is that Garethr’s setup code has not actually run. So although support is in the vcap code, none of the python modules have been downloaded. The file setup/vcap_setup controls what dependencies are added during the setup procedure, so that is where you need to go if you are building your own support. I kept running into problems when using Garethrs repo directly from the install script, so I had to do this step manually.

Install Garethr’s VMC
git clone https://github.com/garethr/vmc.git
A quick note, I don’t understand RVM and would love help her. After cloning his repo, I run vmc from the vmc/bin directory directly. The vmc in my path still points to the old vmc, which won’t let you use python code.

Install Web.Py
easy_install web.py
This will need to be installed on your target. You can either do this manually, or you can come up with you own

Alright! Now you should have Python support, and web.py installed! You can test this by looking through Garethr’s vcap-tests and copy the WSGI sample to make a quick test. To use web.py is pretty straightforward.

Any external requirements need to be placed in a requirements.txt file in the applications root directory. This file just needs the name of the module that will be imported into the application.