Deploying a web application into a virtualenv using wheel packages

Written by Miguel González on 2013-12-06

First, assure virtualenv and pip Python tools are installed.

# yum install -y python-virtualenv python-pip
Loaded plugins: etckeeper
xs-extra                                                 | 2.9 kB     00:00
Package python-virtualenv-1.10.1-1.fc18.noarch already installed and latest version
Package python-pip-1.3.1-4.fc18.noarch already installed and latest version
Nothing to do

The pathagar web application and all its dependencies will reside in its own directory.

# mkdir /usr/local/pathagar-v2
# cd /usr/local/pathagar-v2

Then, create the virtual environment inside that directory and activate it.

# virtualenv venv
New python executable in venv/bin/python
Installing Setuptools......................done.
Installing Pip.............................done.
# source venv/bin/activate

This is the different method, install psycopg2 from a wheel package from a custom repository. This is a very fast procedure and avoids the need to compile and to have development packages.

(venv)# pip install --use-wheel --no-index --find-links=http://xsce.activitycentral.com/wheelhouse/ psycopg2==2.5.1
Ignoring indexes: https://pypi.python.org/simple/
Downloading/unpacking psycopg2==2.5.1
  Downloading psycopg2-2.5.1-cp27-none-linux_armv7l.whl (321kB): 321kB downloaded
Installing collected packages: psycopg2
Successfully installed psycopg2
Cleaning up...

The rest of requirements can be installed from PyPI in the standard way.

(venv)# pip install Django==1.4.5 django-tagging==0.3.1 django-sendfile==0.3.0 django-taggit==0.10
Downloading/unpacking Django==1.4.5
  Downloading Django-1.4.5.tar.gz (7.7MB): 7.7MB downloaded

  Running setup.py egg_info for package Django

Downloading/unpacking django-tagging==0.3.1
  Downloading django-tagging-0.3.1.tar.gz
  Running setup.py egg_info for package django-tagging

Downloading/unpacking django-sendfile==0.3.0
  You are installing a potentially insecure and unverifiable file. Future versions of pip will default to disallowing insecure files.
  Downloading django-sendfile-0.3.0.tar.gz
  Running setup.py egg_info for package django-sendfile

Downloading/unpacking django-taggit==0.10
  Downloading django-taggit-0.10.tar.gz
  Running setup.py egg_info for package django-taggit

Installing collected packages: Django, django-tagging, django-sendfile, django-taggit
  Running setup.py install for Django
    changing mode of build/scripts-2.7/django-admin.py from 644 to 755

    changing mode of /usr/local/pathagar-v2/venv/bin/django-admin.py to 755
  Running setup.py install for django-tagging

  Running setup.py install for django-sendfile

  Running setup.py install for django-taggit

Successfully installed Django django-tagging django-sendfile django-taggit
Cleaning up...

Now, we only have to install and deploy pathagar: all its dependencies are installed into the virtual environment totally isolated from site wide Python packages.

Links

Social