pip

"pip is a replacement for easy_install"

Relatively immature, released late 2008. Still alpha-ish to my mind (some features are flaky) - but already enormously useful to developers.

Written by Ian Bicking

Homepage: http://pypi.python.org/pypi/pip

Why Replace easy_install?

Features Ian/Others like:

Why Replace easy_install?

Features I can't live without:

Features I wish worked:

Why I Need pip

or the wild world of Web Development

My projects involve a mixture of mature libraries (PIL), projects with frequent releases (Django), 3rd party django apps (may not have a release cycle), and my own custom code (usually Django apps).

Without pip (and virtualenv) I was dealing with all that complexity with svn and symlinks. Creating a new project meant starting a django project, symlinking the correct version of django, "installing" 3rd party apps (svn co in project directory), and adding my own custom apps to the project directory.

Using pip

$ pip -E pyenv install south

Creating new virtualenv environment in /tmp/pyenv
...snip...
Successfully installed south

No real advantage over easy_install - it did create the virtualenv for me but I could have created the env, run easy_install in the activated env and done the same thing.

Can your easy_install do this?

$ pip -E pyenv install -e \
  hg+http://bitbucket.org/ubernostrum/django-contact-form/#egg=contact_form
Checking out contact-form from ...snip...
Adding django-contact-form 0.3 to easy-install.pth file
Installed /tmp/pyenv/src/contact-form
Successfully installed contact-form

And repeat for the other half dozen 3rd party packages... Now we're installing directly from source trees without a release. Source tree must provide a basic setup.py. See the distutils docs http://docs.python.org/distutils/setupscript.html

Can your easy_install do this?

$ pip -E pyenv install -e \
  bzr+http://castor/my_apps/editing_utils/trunk#egg=editing_utils
Checking out editing-utils from ...snip...
Successfully installed editing-utils

And install my own reusable apps that I do not customise on a project by project basis.

How pip saves the day

So far - pip hasn't done anything we couldn't do with a combination of easy_install, virtualenv, and VCS tools.

But - replicating the environment is simple

$ pip -E pyenv freeze > requirements.txt
$ pip -E new_env install -r requirements.txt

The requirements file includes version numbers and revision numbers for installed packages to ensure an exact environment match. There's even a bundles feature to package all the source into a single file that can be used to build a new environment. Warning - bundles are definitely the most "alpha" feature of pip.

Results

Formerly:

django_project/
  templates/
  static/
  external_app1/
  external_app2/
  ...
  my_external_app10/
  custom_app1/
  custom_app2/
  setup.py
  local_settings.py

Results

Now:

project/
  pyenv/
  django_project/
    templates/
    static/
    custom_app1/
    custom_app2/
    setup.py
    local_settings.py

Conclusions

Pip is mostly useful to projects with many external dependencies that need to frequently replicate their environment.

It's useful if you work with externally developed code that doesn't have a release cycle that's useful to you.

Or you may just hate easy_install, eggs, and the whole idea of shared site-packages.