[Tutor] Suggested source code folder layout

Walker Hale IV walker.hale.iv at gmail.com
Sat Jun 6 19:02:41 CEST 2009


On Tue, Jun 2, 2009 at 5:06 PM, Allen Fowler <allen.fowler at yahoo.com> wrote:
>
> Hello,
>
> I'm looking for some suggestions as to the filesystem source code layout for a new project.
>
> Here is what I am thinking so far:
>
> root_folder/
> - app/ -- Code for our pylons/django/TG/etc web app
> - web/ -- Public static web files (and wsgi / fastCGI connector files)
> - db/ -- SQlite DB
> - scripts/ -- Various custom programs that will also interact with the DB / app. (Some cron, some interactive.)
>
> However, I am still wondering about a couple of items:
>
> 1) Where to create the virtualpython installation that will be used by both the app and the scripts.
>
> 2) Where to put our in-house created python modules that will be imported by both the app and scripts.
>
> Thank you,
> :)

My 2 cents...

1) Since you are describing your source code layout, any virtual
environment should be outside. A virtual environment (virtualenv) is
part of deployment and not part of source. If you need to make a
reproducible deployment environment, then you need a deployment system
such as zc.buildout. You would store just the recipe for the
environment in source, but not the resulting buildout. Your build
recipe will typically go in the top of your source tree.

http://pypi.python.org/pypi/zc.buildout/

2) Common library code shared by both app and scripts belongs in a
directory named lib. During buildout, the lib directory would be
copied to the site-packages of some python environment. Alternatively,
you could add the lib directory to the search path of your running
Python instances. When running either your app or scripts directly
from your source directory, just add the lib directory to your
PYTHONPATH environment variable.

-- 
Walker Hale <walker.hale.iv at gmail.com>


More information about the Tutor mailing list