Directory layout for a Python project with C extension modules
- by Kamil Kisiel
We have numerous projects in our organization that are mixed Python/C. Currently we're trying to standardize on a directory layout for our projects and are trying to come up with a convenient scheme. One point of contention is where to put C extension modules in the tree.
We're tossing around a couple of options (relative to project root):
./src/package/subpackage/module.c
or alongside the python modules in the package tree:
./package/subpackage/module.c
or in a src directory in the subpackage:
./package/subpackage/src/module.c
One reason for keeping them out of the package directories could be because it will lead to clutter, especially if there are other .c and .h files which aren't themselves modules but still need to be compiled. Also in the "integrated" scheme, what do you do with headers and files that are used by more than one module? Put them in a common top-level directory?
I'd be interested to know what other people are using, or if there are any established best practices for this.