Project Bootstrapping

Filesystem Layout

Note

This document is heavily biased towards Unix-style filesystems and may require additional effort to use in other operating systems.

Virtualenv is a must for Python projects. It provides a method to isolate different Python environments. We typically host our production sites from /opt/webapps/<site_name> and our development sites from ~/webapps/<site_name>. Each individual project gets its own virtualenv that also serves as the directory for all the source files associated with the project. We use pip to populate the virtualenv with the necessary packages.

The bootstrap process looks like this:

cd /opt/webapps
virtualenv mysite.com
cd mysite.com
pip install -E . -r path/to/requirements.txt
source bin/activate

Tip

For convenience, you can symlink your Django project into the root of your virtualenv. The name of the symlink does not matter since your project should already live in the Python path. By giving the symlink the same name across all your projects, you can leverage some convenient bash functions to save time.

Packaging

One of the keys to successful deployment is to ensure that the software you develop on is as close as possible to the software you deploy on. Pip provides a simple repeatable method allowing you to consistently deploy Python projects across many machines. Every application that requires third-party libraries should include a pip requirements file called requirements.txt. Projects should aggregate the application requirements files adding any additional requirements as needed.

What to include in your requirements files

Our rule of thumb is to include any application that is not included in your operating system’s package repository. The only packages we exclude from our requirements files are PIL, database drivers and packages that are uninstallable via pip. These requirements are documented in the project’s README.

Table Of Contents

Previous topic

Deployment

Next topic

Servers

Interested in working with us?
Fill out the form below or contact us at:

PO Box 774441
Steamboat Springs, CO
80477

ph: 970.879.8810
fx:  970.367.8596
info@lincolnloop.com