Imagine that you want to develop a non-trivial end-user desktop (not web) application in Python. What is the best way to structure the project’s folder hierarchy?
Desirable features are ease of maintenance, IDE-friendliness, suitability for source control branching/merging, and easy generation of install packages.
In particular:
- Where do you put the source?
- Where do you put application startup scripts?
- Where do you put the IDE project cruft?
- Where do you put the unit/acceptance tests?
- Where do you put non-Python data such as config files?
- Where do you put non-Python sources such as C++ for pyd/so binary extension modules?
Doesn’t too much matter. Whatever makes you happy will work. There aren’t a lot of silly rules because Python projects can be simple.
/scriptsor/binfor that kind of command-line interface stuff/testsfor your tests/libfor your C-language libraries/docfor most documentation/apidocfor the Epydoc-generated API docs.And the top-level directory can contain README’s, Config’s and whatnot.
The hard choice is whether or not to use a
/srctree. Python doesn’t have a distinction between/src,/lib, and/binlike Java or C has.Since a top-level
/srcdirectory is seen by some as meaningless, your top-level directory can be the top-level architecture of your application./foo/bar/bazI recommend putting all of this under the ‘name-of-my-product’ directory. So, if you’re writing an application named
quux, the directory that contains all this stuff is named/quux.Another project’s
PYTHONPATH, then, can include/path/to/quux/footo reuse theQUUX.foomodule.In my case, since I use Komodo Edit, my IDE cuft is a single .KPF file. I actually put that in the top-level
/quuxdirectory, and omit adding it to SVN.