Creating a Development Environment with pip and virtualenv
Clone this wiki locally
Creating a development environment using virtualenv(wrapper) and pip
See also Development-Environment-in-5-minutes (using vagrant)
Tested on Ubuntu 10.10
Start with Git, Github
Create an account at github. Follow the instructions at http://help.github.com/linux-set-up-git/ to set up git and github access.
You will end up with a URL like https://github.com/$USER/zookeepr.
Clone your fork
git clone firstname.lastname@example.org:USER/zookeepr
This takes a few minutes, so you can continue with the other steps while this is happening...
There are other suggestions at http://help.github.com/fork-a-repo/ for things to do, like keeping track of upstream.
Install required OS packages
sudo apt-get install python-dev sudo apt-get install python-pip
These are required for the Python package lxml:
sudo apt-get install libxml2-dev sudo apt-get install libxslt-dev
Use pip to install virtualenv and virtualenvwrapper
(NB: on Fedora, you can just
sudo yum install python-virtualenvwrapper)
sudo pip install virtualenv sudo pip install virtualenvwrapper
virtualenv is something you can use to create an isolated Python development environment. This helps isolate your dependencies, especially when used with pip. virtualenvwrapper provides some convenient short-hand shell commands to make virtualenv nicer to use. Documentation is at http://www.doughellmann.com/docs/virtualenvwrapper/.
Set up virtualenvwrapper
In your shell initialisation file (eg. ~/.bashrc), add two lines like this:
export WORKON_HOME=$HOME/.virtualenvs source /usr/local/bin/virtualenvwrapper.sh
(Change the path to virtualenvwrapper.sh depending on where it was installed. For instance, on Fedora it is installed at /usr/bin/virtualenvwrapper.sh.)
WORKON_HOME is a directory where virtualenvwrapper is going to collect the virtualenvs that you use it to create.
virtualenvwrapper provides the following commands:
mkvirtualenv foo rmvirtualenv foo workon foo # activate the virtualenv called foo deactivate # whatever the currently active virtualenv is
A full list of commands is at http://www.doughellmann.com/docs/virtualenvwrapper/command_ref.html.
Create a virtualenv for zookeepr
mkvirtualenv --no-site-packages zookeepr
Creating it will also activate it, so now the shell prompt will be prefixed by "(zookeepr)".
Use pip to install Python dependencies
Create a file requirements.txt which contains the following:
AuthKit Beaker FormEncode Mako MarkupSafe Paste PasteDeploy PasteScript PIL Pygments Pydns Pylons==0.9.7 pytz Routes SQLAlchemy==0.6.3 Tempita WebError WebHelpers WebOb==0.9.8 WebTest decorator dnspython elementtree lxml nose python-openid simplejson wsgiref
(This list is based on a previous attempt at this approach, see http://lists.zookeepr.org/public/zookeepr-devel/2010-September/000350.html. It would make sense to commit this to src...)
pip install -r requirements.txt
Make sure your virtualenv is activated when you run this command, then pip will only install these packages for this virtualenv.
Create a lca_info config file
cp zookeepr/config/lca_info.py.sample zookeepr/config/lca_info.py
Set up Pylons
In your zookeepr checkout directory:
python setup.py develop paster make-config zookeepr config.ini paster setup-app config.ini paster serve --reload config.ini
The final line this command will print out is something like "serving on 0.0.0.0:5000 view at http://127.0.0.1:5000" Visit that URL in wala, zookeepr.
By visiting http://127.0.0.1:5000/admin> you will be prompted to log in and redirected to the administration hub. Default credentials are:
- email: email@example.com
- password: password
Q. Why is Pylons 0.9.7 specified?
A. The latest Pylons version is 1.0, but it is not backwards compatible. See https://github.com/zookeepr/zookeepr/issues/37.
Q. I am having trouble with 'import Image' ?
A. Previously it seemed that if PIL was installed via OS packages (as python-imaging), you could do 'import Image', whereas if it was installed via pip (as PIL), you should do 'from PIL import Image'. By 'previously', I mean 'the last time I tried this'. See http://lists.zookeepr.org/public/zookeepr-devel/2010-September/000350.html. Perhaps it has been fixed... But if you have this error, you will need to patch zookeepr as described in that link.