This page attempts to describe how to setup a working Python development environment that can be used in developing on OpenStack.
System Dependencies
You must use Python 2.6.x to work on OpenStack projects. While Python 2.6.1 mostly works, there are a few bugs logged against Nova related to 2.6.1 not running tests correctly (705052 and 670654). Python 2.6.5 works well.
Linux
At present, this was only tested for Nova on Ubuntu 10.10-64. Change accordingly.
Bring down the Nova source with bzr, then:
cd <your_src_dir>/nova sudo apt-get install python-dev swig libssl-dev python-pip sudo easy_install nose sudo pip install virtualenv python tools/install_venv.py
If all goes well, you should get a message something like this:
Nova development environment setup is complete. Nova development uses virtualenv to track and manage Python dependencies while in development and testing. To activate the Nova virtualenv for the extent of your current shell session you can run: $ source .nova-venv/bin/activate Or, if you prefer, you can run commands in the virtualenv on a case by case basis by running: $ tools/with_venv.sh <your command> Also, make test will automatically use the virtualenv.
MacOSX
Paths and Environment Settings
Running Tests
cd $projectdir python run_tests.py
or if you are running the virtual_env
./run_tests.sh
Saving time
If you don't want to create a virtualenv every time you branch (which takes a while as long as we have the large Twisted project as a dependency) you can reuse a single virtualenv for all branches.
- If you don't have a nova/ directory containing trunk/ and other branches, do so now.
- Go into nova/trunk and install a virtualenv.
- Move it up a level: mv nova/trunk/.nova-venv nova/.nova-venv
- Trick the virtualenv into working one level higher than it expected: sed -i 's#/nova/trunk#/nova#' nova/.nova-venv/bin/activate
Add this function to your .bashrc:
# Start the nova virtualenv that is somewhere above us in the tree
function venv() {
dir=$(pwd)
last=$dir
while ! [ -d $dir/.nova-venv ]; do
last=$dir
dir=$(dirname $dir)
done
source $dir/.nova-venv/bin/activate
export PYTHONPATH=$last
}Now you can type 'venv' to enter the virtualenv no matter where you are currently working.
Misc Notes
python-mysqldb seems to be missing from tools/pip-requires ... not sure if it should be there, but when I tried to manually pip it in there it still didn't find it. I had problems with tools/install-venv and python-mysqldb. What I had to do was remove --no-site-packages from {{{tools/install-venv.py and {{{sudo apt-get install python-mysqldb manually. Finally, if you're using XenServer don't forget to copy sdk/XenAPI.py into .nova-venv/lib/python2.6/site-packages