Jan 24, 2014

Python Virtualenv awesomeness - and developing openstack-doc-tools

Testing and developing the openstack-doc-tools package, I really came to love the python virtualenv package. The package allows installation of python packages in a local environment (virtualenv = virtual environment) for usage.

Let me guide you on how I use it for openstack-doc-tools - the repo the OpenStack documentation team uses for its tools.

Then, let's setup the virtualenv: I could setup a virtualenv manually using for example "virtualenv myenv" and install packages. But the repository knows already about virtualenv and thus I can run "python tools/install_venv.py" and it installs a virtual python environment named '.venv' using the directory '.venv' of openstack-doc-tools. The requirements for the project as mentioned in the requirements.txt and test-requirements.txt files, will get installed into this virtualenv.

Once the command finishes, it outputs a nice usage information, and I follow the option to "source .venv/bin/activate" from my shell to run commands in the virtualenv.

Next, I need to build the package via "python setup.py build" and then install the package with "python setup.py install".

Now I can easily execute commands for validating repositories. So, I can change my working directory to the api-site repository and run for example the command:"openstack-doc-test --api-site --check-niceness --force"

to test that the recent changes to the niceness check work fine on all files in the repository.