Project layout

A complex project needs to be well-organized in order to be able to find your way in the mess that is created by countless modules, README files, graphics files and license notices. Most likely, your project directory layout will also be the layout of the application when you deliver it to the user. It thus serves a dual purpose: facilitating development and deployment. For deployment, see Chapter 26.

Over the last decade, a standard project layout has grown to maturity for open source projects. This layout consists of a toplevel directory that contains README's, installation instructions, and directories for documentation, data and source code.

A Python project often consists of several modules: one for your document classes, one for custom GUI widgets and one for the application classes, and one for scripts needed to create database definitions. For example:

The toplevel directory layout of a large project

Here, the datamodel directory contains SQL scripts to create the database. The directory dbobj contains a module which handles database access. The directory dialogs contains designer .ui files. The directory html contains the application documentation in html format - it would be better to write the documentation in docbook and automatically generate html and pdf versions of the manual. Finally, the kuraapp, kuralib and kuragui directories are Python modules (that will have to be put on the Python path) for the application, document and custom widgets needed for this application. notes contains implementation notes and pixmaps graphics needed for the toolbar. The rest of the files speak for themselves: starter scripts for Windows and Unix, and various standard files, like INSTALL and CHANGELOG

In contrast with Java application, it is not wise to nest Python modules — keeping the structure relatively flat makes it easier to import modules into each other.

Generally, Python applications start out very simple, with just one script file, and then blossom out in modules and directories. The development of the codebase in this part is a lively demonstration of that fact.