Organizing code into src, bin, and test
As we noted in the previous section, there's no essential need for a complex directory structure. Simple Python applications can be built in a simple, flat directory. We can include the application modules, test modules, as well as setup.py
and README
. This is pleasantly simple and easy to work with.
When the modules and packages get more complex, however, we'll often need to be a bit more structured. For complex applications, one common approach is to segregate Python code into three bundles. To make the examples concrete, let's assume that our application is called my_app
. Here are the typical directories we might create:
my_app/my_app
: This directory has all of the working application code. All of the various modules and packages are here. A vaguely namedsrc
directory is uninformative. Thismy_app
directory should include an empty__init__.py
file so that the application also acts as a package.my_app/bin
ormy_spp/scripts
: This directory can have...