Intro

Sometimes you may want to test an environment with the latest python-ovs changes before they end up in a release. For example, you might be seeing a bug in Neutron on a devstack environment that looks OVS-related and you want to be a good citizen and verify the bug hasn’t already been fixed before reporting a bug.

pip install -e (but there’s a catch)

Normally, if you need to replace a Python module (in our case, OVS) on a host with an editable version you’ve checked out, you’d just type:

$ git clone https://github.com/openvswitch/ovs
$ cd ovs/python
$ sudo pip install -e .

and that’d be it. But unfortunately, python-ovs’s build is tightly coupled to the OVS build system. There are a couple of extra steps you’ll need to do.

Build OVS

python-ovs has two files that get information from the OVS build process, dirs.py and version.py. We need to build OVS to get these generated properly. We’ll also want to pass in –enable-shared when building so that we can build the C-extension JSON module for better performance (and to match what is likely shipped by your Linux distribution). Make sure you’ve installed autconf/automake/libtool and the openssl and python3 development libraries for your system. See the OVS build documentation for more info.

$ git clone https://github.com/openvswitch/ovs
$ cd ovs/
$ ./boot.sh
$ ./configure --prefix=/usr --enable-shared
$ make -j $(nproc)

Build the C JSON extension

$ cd python/
$ python setup.py build_ext -I ../include -L ../lib/.libs
# The last line of the output should contain the file you need to copy to the ovs module, e.g.:
$ cp build/lib.linux-x86_64-3.10/ovs/_json.cpython-310-x86_64-linux-gnu.so ovs/

Now install with pip install -e

$ sudo pip install -e .

You should now be able to debug your system against the latest unreleased python-ovs. Any changes you make in the python/ovs system will be effective immediately. You’ll need to restart your python-ovs-using services so that they can import the new code.