Brubeck Framework – Python
June 2, 2012
Installing the Environment
We have to install few things first.
$ sudo apt-get update
$ sudo apt-get install build-essential python-dev libevent-dev
$ sudo install python-setuptools
$ sudo easy_install pip
Brubeck depends in Mongrel2, ZeroMQ and few python packages
1) Installing ZeroMQ
ZeroMQ from a python perspective is actually two pieces: libzmq & pyzmq.
$ sudo apt-get install libzmq-dev
$ sudo apt-get install python-zmq
and you are done::
$python
Python 2.7.3 (default, Apr 20 2012, 22:44:07)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import zmq
>>> zmq.zmq_version()
'2.2.0'
After completed those steps, you have to download the repos to your Desktop
$ wget http://download.zeromq.org/historic/zeromq-2.1.9.tar.gz
$ tar zxf zeromq-2.1.9.tar.gz
$ cd ~/Desktop/zeromq-2.1.9
$ ./autogen.sh
$ ./configure
$ make
$ sudo make install
2) Mongrel2
Mongrel2 installation is also painless to setup.
you have to get repos to your desktop like zeroMQ.But before that you need to install sqlite3 & libsqlite3-dev packages.
$ sudo apt-get install sqlite3
$ sudo apt-get install libsqlite3-dev
$ cd ~/Desktop
$ git clone https://github.com/zedshaw/mongrel2.git
$ cd mongrel2
$ make
$ sudo make install
Hope, you install both ZeroMQ and Mongrel2 successfully.
Virtualenv & Virtualenvwrapper
Brubeck works great with virtualenv.
Virtualenv is a way to construct isolated python environments. Very handy for managing multiple environments in a single machine.
Install both virtualenv and virtualenvwrapper with pip.
$ pip install virtualenv virtualenvwrapper
Then, we must configure our shell to know where to store our virtualenv’s. While we’re there, we’ll source the virtualenvwrapper shell script.
$ export WORKON_HOME=~/Envs
$ mkdir -p $WORKON_HOME
$ source /usr/local/bin/virtualenvwrapper.sh
$ mkvirtualenv env1
Installing
distribute..........................................
....................................................
....................................................
...............................done.
Python Packages & Brubeck
Download the Brubeck repos to your Desktop
$ git clone https://github.com/j2labs/brubeck.git
you can install everything with the requirements file.
$ cd ~/Desktop/brubeck
$ pip install -I -r ./envs/brubeck.reqs
Note: While running the command, if it throws permission denied error then add sudo before pip
To install eventlet support:
$ pip install -I -r ./envs.eventlet.reps
As last step, install Brubeck
$ cd ~/Desktop/brubeck
$ python setup.py install
Running an Demo Application
First we setup the Mongrel2 config
$ cd ~/Desktop/brubeck/demos
$ m2sh load -config mongrel2.conf -db the.db
$ m2sh start -db the.db -host localhost
Now come back to Brubeck instance
$ cd ~/Desktop/brubeck/demos
$ ./demo_minimal
INFO:root:Using coroutine library: eventlet
Brubeck v0.4.0 online ]———————————–
Now go back to your browser and give http://localhost:6768/brubeck
Reference Links :-
http://brubeck.io/installing.html
http://www.doughellmann.com/docs/virtualenvwrapper/
http://j2labs.tumblr.com/post/5181438807/quick-dirty-virtualenv-virtualenvwrapper