Friday, November 26, 2010

Getting Started with a Virtual Python Installation

Working with and developing Python software is complicated by several factors:
  • Many users do not have the administrative privileges that are needed to install packages in the Python site packages directory, where Python packages are most easily installed
  • Python developers often need to manage many Python projects in the same development environment
The Python virtualenv package resolves these issues by allowing users to generate a local Python installation. Thus, a user can create a Python installation into which they can install Python packages using standard tools like easy_install and pip.

Unfortunately, getting started with virtualenv is complicated by the fact that you need to install this package to create virtual Python installations. But, if you do not have administrative privileges, then you are stuck. This is the simplest process that I have seen:
hg clone http://bitbucket.org/ianb/virtualenv
virtualenv/virtualenv.py ENV
Unfortunately, the hg command may not be preinstalled on your machine. It is not available on any of mine...

The pyutilib.virtualenv package contains the vpy_install script, which can bootstrap the setup of virtualenv. This script extends the functionality of the virtualenv driver script to allow direct, and it customization of this initial environment. The vpy_install script can be easily downloaded from the PyUtilib wiki, or it can be downloaded with commands like wget or curl:
wget http://doiop.com/pyutilib/vpy_install
vpy_install ENV

Wednesday, November 10, 2010

Installing Python Software Packages: The Good, The Bad and the Ugly

I almost gave the following presentation at the INFORMS Annual Meeting:


That is, I was scheduled to give this talk but my session co-organizer ran over and I had to summarize these slides in 5 minutes!

Anyway, these slides describe different strategies for installing Python software.  Although I am a big fan of Python software development, robust strategies for software installation remains a challenge.  This talk describes several different installation scenarios:

The Good: the user has administrative privileges
  1. Installing on Windows with an installer executable
  2. Installing with Linux application utility
  3. Installing a Python package from the PyPI repository
  4. Installing a Python package from source

The Bad: the user does not have administrative privileges
  1. Using a virtual environment to isolate package installations
  2. Using an installer executable on Windows with a virtual environment

    The Ugly: the user needs to install an extension package from source
    1. Installing a Python extension package from source
    2. PyCoinInstall – Managing builds for Python extension packages
    The last item referring to PyCoinInstall describes a utility being developed for the COIN-OR software, which is used within the operations research community.  COIN-OR includes a variety of Python and C++ software packages, and this script uses a simple plug-in system to support the management of package builds and installation.  Of course, this mostly does the easy packages right now...

    While preparing these slides I realized that the vpy_install script I use for setting up virtual environments is probably of broader interest.  I'll say more about this in a little bit.  In the meantime, checkout the slides!