Modulus supports the seamless deployment of Python applications. The Python runtime supports multiple version of Python and serves static content using a configurable nginx frontend.
Creating a Python project can be done by choosing Python on the web portal or when creating a project using the CLI.
Deploying a Python application is done by simply deploying the directory containing your Python source code. Modulus will install your pip dependencies from requirements.txt.
$ cd path/to/project
$ modulus deploy
SETTING PYTHON VERSION
Modulus pre-installs Python versions 2.5.6, 2.6.9, 2.7.10, 3.2.6, 3.3.6, and 3.4.3. You can change the version of Python by deploying an application manifest file (app.json) in the root of your project or by including .python-version file in the root directory. You can set the version to any version (even those not listed), but versions not listed above will require the Python version to be installed prior to deploying, which may delay your deploy. If no version is specified, the project will default to 2.7.10.
CUSTOM NGINX CONFIGURATION
Modulus provides a reasonable base nginx and site configuration that will serve static assets for Python applications. You can provide your own site-specific nginx configuration by deploying a "sites-enabled" folder with configuration files in the root of your project. All config files located in this folder will be included by nginx.
EXAMPLE: DEPLOYING DJANGO
Django is the default method for running a Python application. Django applications are run using gunicorn with an nginx proxy that also serves static assets. Static assets are expected to be located in a directory named static.
The run image automatically calls migrate (./manage.py migrate) for you.
Django applications are started by running gunicorn -b unix:/mnt/home/app.sock wsgi - you may provide your own start command by adding a start script to app.json. Note that your start command must bind to the socket at /mnt/home/app.sock unless you provide custom nginx configuration that handles proxying to your application.
Overriding the start command in app.json
"start": "gunicorn -b unix:/mnt/home/app.sock wsgi"