Development under Gnu/Linux =========================== Risk-in-a-box is built in python and runs as a plugin in `QGIS `_. Quick Installation Guide - Linux (Debian based) ----------------------------------------------- These instructions are for setting up a development version on a Debian based linux system such as Ubuntu or Mint. 1. Goto the area where you do development, e.g cd ~/sandbox 2. wget bit.ly/inasafe-install 3. source ./inasafe-install To verify that the installation works you can run the test suite from the command line:: cd inasafe-dev make test This will run all the regression tests and also highlight any code issues. Note that first time the tests are run they will pull 250MB of test data from our git repository. See further notes on running tests below. To run the plugin start QGIS and enable it from the :menuselection:`Plugins --> Manage Plugins` menu. If this doesn't work see section towards the end of this document about dependencies and try to do a manual install. Manual Installation Guide - Linux (Debian based) ------------------------------------------------ Dependencies ............ The Graphical User Interface components are built using `PyQt4 `_ and the QGIS plugin API (useful resources: `the QGIS Python Cookbook `_ and `the QGIS C++ API documentation `_). As such it is helpful if you are familiar with these technologies (python, Qt4, PyQt4, QGIS). In addition, the following are needed on your machine in order to work effectively with the code base: * git * rsync * pep8 * nosetests (with coverage plugin) * python-numpy (for numerical computations) * python-gdal (python bindings to underlying gis functionality) * python-sphinx (compilation of documents) * cloud-sptheme (sphinx theme) * pyqt4-dev-tools (compiling ui and resources) * qt4-doc (qt4 API documentation) * pyflakes (test for bad coding style like unused imports / vars) * python-nosexcover and python-coverage (code coverage reporting) On an ubuntu system you can install these requirements using apt:: sudo apt-get install git rsync pep8 python-nose python-coverage \ python-gdal python-numpy python-sphinx pyqt4-dev-tools pyflakes sudo pip install cloud-sptheme python-nosexcover In some cases these dependencies may already be on your system via installation process you followed for QGIS. Cloning the source code from git ................................ To develop on the plugin, you first need to copy it to your local system. If you are a developer, the simplest way to do that is go to `~/.qgis/python/plugins` and clone inasafe from our GitHub repository page like this:: git clone git://github.com/AIFDR/inasafe.git (for read only) git clone git@github.com:AIFDR/inasafe.git (to commit changes) QGIS installed in a non-standard location ......................................... For running unit tests that need QGIS, you may need to adjust *PYTHONPATH* and *QGIS_PREFIX_PATH* if QGIS is running in a non standard location. For example with QGIS built from source into /usr/local (and python bindings global install option disabled), you could run these commands (or add them to your ~/.bashrc):: export QGIS_PREFIX_PATH=/usr/local export PYTHONPATH=$PYTHONPATH:/usr/local/share/qgis/python/ .. note:: The above can be set within Eclipse's project properties if you are running your tests using the PyDev IDE environment. Adding inasafe to your python path: ................................... Lastly, you should add the inasafe plugin folder to your PYTHONPATH so that package and module paths can be resolved correctly. E.g:: export PYTHONPATH=$PYTHONPATH:${HOME}/.qgis/python/plugins/inasafe Once again you could add this to your .bashrc or set it in Eclipse for convenience if needed. .. _running-tests-label: Running tests ............. You can run all tests (which includes code coverage reports and other diagnostics) by doing this within the inasafe plugin folder:: make test You can also run individual tests using nose. For example to run the riabclipper test you would do:: nosetests -v gui.test_riabclipper Achievements ............ .. note:: This is optional and thus not hard coded into the makefile. Optionally you can enable nose achievments which is a motivational tool that gives you little achievement awards based on your test results:: sudo pip install git+git://github.com/exogen/nose-achievements.git Now create this file in the root of your inasafe git checkout :file:`setup.cfg`:: [nosetests] with-achievements=1 When you run tests occasionally achievements will be displayed to you at the end of the test run. See the achievements home page at http://exogen.github.com/nose-achievements/. Developing using Eclipse (Linux) -------------------------------- .. note:: This is optional - you can use any environment you like for editing python, or even a simple text editor. If you wish to use an IDE for development, please refer to `this article `_ for detailed information on how to get the basic Eclipse with PyDev setup. Creating a project .................. The procedure for doing this is to do: :menuselection:`File --> New --> Project...` and then from the resulting dialog do :menuselection:`PyDev --> PyDev Project`. In the resulting project dialog, set the following details: * :guilabel:`Project name:` : :kbd:`inasafe` * :guilabel:`Use default` : :kbd:`uncheck` * :guilabel (linux):`Directory` : :kbd:`/home/