18
18
Setting Up a Development Environment
19
19
====================================
21
This page describes how to setup a working Python development environment that can be used in developing on OpenStack on Ubuntu or Mac OSX. These instructions assume you're already familiar with git. Refer to http://wiki.openstack.org/GettingTheCode for additional information.
21
This page describes how to setup a working Python development environment that
22
can be used in developing nova on Ubuntu, Fedora or Mac OS X. These
23
instructions assume you're already familiar with git. Refer to
24
http://wiki.openstack.org/GettingTheCode for additional information.
26
Following these instructions will allow you to run the nova unit tests. If you
27
want to be able to run nova (i.e., launch VM instances), you will also need to
28
install libvirt and at least one of the `supported
29
hypervisors`<http://wiki.openstack.org/HypervisorSupportMatrix>_. Running
30
nova is currently only supported on Linux, although you can run
31
the unit tests on Mac OS X. See :doc:`quickstart` for how to get a working
32
version of OpenStack Compute running as quickly as possible.
37
Nova development uses `virtualenv <http://pypi.python.org/pypi/virtualenv>`_
38
to track and manage Python dependencies while in development and testing. This
39
allows you to install all of the Python package dependencies in a virtual
40
environment or `virtualenv` (a special subdirectory of your nova directory),
41
instead of installing the packages at the system level.
43
Virtualenv is useful for running the unit tests, but is not typically used
44
for full integration testing or production usage.
26
Note: This section is tested for Nova on Ubuntu 10.10-64. Feel free to add notes and change according to your experiences or operating system.
28
Bring down the Nova source with git, then:
30
cd <your_src_dir>/nova
31
sudo apt-get install python-dev swig libssl-dev python-pip
32
sudo easy_install nose
33
pip install virtualenv
49
Note: This section is tested for Nova on Ubuntu (10.10-64) and
50
Fedora-based (RHEL 6.1) distributions. Feel free to add notes and change
51
according to your experiences or operating system.
53
Install the prerequisite packages.
57
sudo apt-get install python-dev swig libssl-dev python-pip git-core
59
On Fedora-based distributions (e.g., Fedora/RHEL/CentOS/Scientific Linux)::
61
sudo yum install python-devel swig openssl-devel python-pip git
67
Install swig, which is needed to build the M2Crypto Python package. If you are
68
using the `homebrew <http://mxcl.github.com/homebrew/>`_, package manager,
69
install swig by doing::
75
sudo easy_install virtualenv
77
Check the version of OpenSSL you have installed::
81
If you have installed OpenSSL 1.0.0a, which can happen when installing a
82
MacPorts package for OpenSSL, you will see an error when running
83
``nova.tests.auth_unittest.AuthTestCase.test_209_can_generate_x509``.
85
The stock version of OpenSSL that ships with Mac OS X 10.6 (OpenSSL 0.9.8l)
86
or Mac OS X 10.7 (OpenSSL 0.9.8r) works fine with nova.
91
Grab the code from GitHub::
93
git clone https://github.com/openstack/nova.git
99
The unit tests will run by default inside a virtualenv in the ``.nova-venv``
100
directory. Run the unit tests by doing::
104
The first time you run them, you will be asked if you want to create a virtual
105
environment (hit "y")::
107
No virtual environment found...create one? (Y/n)
109
See :doc:`unit_tests` for more details.
113
Manually installing and using the virtualenv
114
--------------------------------------------
116
You can manually install the virtual environment instead of having
117
``run_tests.sh`` do it for you::
34
119
python tools/install_venv.py
36
If all goes well, you should get a message something like this:
121
This will install all of the Python packages listed in the
122
``tools/pip-requires`` file into your virtualenv. There will also be some
123
additional packages (pip, distribute, greenlet, M2Crypto) that are installed
124
by the ``tools/install_venv.py`` file into the virutalenv.
126
If all goes well, you should get a message something like this::
38
128
Nova development environment setup is complete.
40
Nova development uses virtualenv to track and manage Python dependencies while in development and testing. Virtual env gives you an independent Python environment.
42
130
To activate the Nova virtualenv for the extent of your current shell session
45
$ source .nova-venv/bin/activate
47
Or, if you prefer, you can run commands in the virtualenv on a case by case
133
$ source .nova-venv/bin/activate
135
Or, if you prefer, you can run commands in the virtualenv on a case by case
50
138
$ tools/with_venv.sh <your command>
52
Also, make test will automatically use the virtualenv.
54
If you don't want to create a virtualenv every time you branch you can reuse a single virtualenv for all branches.
56
#. If you don't have a nova/ directory containing trunk/ and other branches, do so now.
57
#. Go into nova/trunk and install a virtualenv.
58
#. Move it up a level: mv nova/trunk/.nova-venv nova/.nova-venv.
59
#. Symlink the ../nova/.nova-venv directory from your branch::
61
~/openstack/nova/my_branch$ ln -s ../.nova-venv .nova-venv
63
This works with run_tests.sh and nosetests -w nova/tests/api
68
First, install Virtual Env, which creates an isolated "standalone" Python environment.::
70
sudo easy_install virtualenv
73
Here's how to setup the code initially::
75
git clone https://github.com/openstack/nova.git
77
python tools/install_venv.py
78
source .nova_venv/bin/activate
79
pip install pep8 # submitting patch so that Nova has pep8 and pylint in PIP requirements file
82
If you have installed OpenSSL 1.0.0a on MacOS, which can happen when installing a MacPorts package for OpenSSL, you will see an error when running nova.tests.auth_unittest.AuthTestCase.test_209_can_generate_x509. The version that functions correctly is OpenSSL 0.9.8l 5, installed with MacOS 10.6 as a base element.
84
Here's how to get the latest code::
87
git pull # get the latest stuff...
88
source .nova_venv/bin/activate
91
Then you can do cleaning work or hack hack hack with a branched named cleaning.
93
140
Contributing Your Work
94
141
----------------------
96
Once your work is complete you may wish to contribute it to the project. Add your name and email address to the `Authors` file, and also to the `.mailmap` file if you use multiple email addresses. Your contributions can not be merged into trunk unless you are listed in the Authors file. Nova uses the Gerrit code review system. For information on how to submit your branch to Gerrit, see http://wiki.openstack.org/GerritWorkflow
143
Once your work is complete you may wish to contribute it to the project. Add
144
your name and email address to the `Authors` file, and also to the `.mailmap`
145
file if you use multiple email addresses. Your contributions can not be merged
146
into trunk unless you are listed in the Authors file. Nova uses the Gerrit
147
code review system. For information on how to submit your branch to Gerrit,
148
see http://wiki.openstack.org/GerritWorkflow