Python Pyramid on Codio.com

Here are some notes on getting a Pyramid project up and running on codio.com

This is a technical article aimed at Python developers!

1. Create your project on Codio

I’ll let you follow your nose on that one.

2. Install pip

This is the slightly non-obvious bit that has you scrambling for documentation, but let’s cut to the chase.

Codio has it’s own installer system called parts so you don’t have to mess with sudo and installing packages of your own (which isn’t allowed). This actually simplifies things greatly once you understand it!

 

Set up your packages

parts install pip
parts install virtualenv
parts install mongodb

Initialise your environment

Assuming your source code is checked out nicely into your ~/workspace directory (which it will be if you followed the regular Codio / git project setup) you’re now ready to set up your app.

virtualenv env
source env/bin/activate
python setup.py develop

Running your app

In your Codio menu bar, you’ll have a default “Launch” menu item. Pull that down and you’ll find “Configure…”. Update the “commands” block to include something like the following:


// Run button configuration

"commands": {
"Launch MyProject": "env/bin/gunicorn -w 2 --reload --paste development.ini",
"Tests" : "env/bin/nosetests"
},

While you’re there edit the “Box URL” to match the port number your app is running on:


"Box URL": "http://{{domain}}:6543/",

The Codio editor saves continuously, so now go back to the menu bar and click the “Launch MyProject” menu. Assuming you have gunicorn loaded in your setup.py, you’ll see your app start up in a terminal window.

Click the “Box URL” option in the Preview menu and a new tab will open with your web app in it.

Well it worked for me, your mileage may vary but let me know how you got on below.

 

Sample output from the “parts” commands.

~/workspace$ parts install pip
=> Downloading http://parts.codio.com/box-codio-v1/python2-2.7.6-2-binary.tar.gz...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    41  100    41    0     0   1091      0 --:--:-- --:--:-- --:--:--  3153
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 26.0M  100 26.0M    0     0  61.2M      0 --:--:-- --:--:-- --:--:-- 73.4M
=> Extracting archive...
=> Installing...
=> Activating...
=> Installed python2 2.7.6-2
=> Downloading http://parts.codio.com/box-codio-v1/setuptools-2.2-2-binary.tar.gz...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    41  100    41    0     0   1070      0 --:--:-- --:--:-- --:--:--  2928
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  455k  100  455k    0     0  4526k      0 --:--:-- --:--:-- --:--:-- 6072k
=> Extracting archive...
=> Installing...
=> Activating...
=> Installed setuptools 2.2-2
=> Downloading http://parts.codio.com/box-codio-v1/pip-1.5.4-2-binary.tar.gz...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    41  100    41    0     0   1118      0 --:--:-- --:--:-- --:--:--  2733
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 2014k  100 2014k    0     0  18.0M      0 --:--:-- --:--:-- --:--:-- 22.6M
=> Extracting archive...
=> Installing...
=> Activating...
=> Installed pip 1.5.4-2                                                               

~/workspace$ pip install virtualenv
Requirement already satisfied (use --upgrade to upgrade): virtualenv in /home/codio/.parts/packages/python2/2.7.6-2/lib/python2.7/site-packages/virtualenv
-1.11.4-py2.7.egg
Cleaning up...
codio@partner-model:~/workspace$ virtualenv env
-bash: virtualenv: command not found
codio@partner-model:~/workspace$ parts install virtualenv
=> Downloading http://parts.codio.com/box-codio-v1/virtualenv-1.11.4-2-binary.tar.gz...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    41  100    41    0     0   1080      0 --:--:-- --:--:-- --:--:--  2928
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   412  100   412    0     0   5510      0 --:--:-- --:--:-- --:--:-- 10564
=> Extracting archive...
=> Installing...
=> Activating...
=> Installed virtualenv 1.11.4-2 

On July 29, 2014, posted in: Cloud, Dev by

Tags: , , , ,