1. Steve Losh
  2. gorilla

Wiki

Clone wiki

gorilla / WhatOtherSystemsGetWrong

What Other Systems Get Wrong

If we want to make a system that's better than the current options, we need to look at them and see what they do wrong (and right, of course).

easy_install

God, what an ugly name.

Help

So you've installed Python and are ready to install some packages. You've heard about this nifty easy_install thing, so you type easy_install --help and see:

  --script-dir (-s)              install scripts to DIR
  --exclude-scripts (-x)         Don't install scripts
  --always-copy (-a)             Copy all needed packages to install dir
  --index-url (-i)               base URL of Python Package Index
  --find-links (-f)              additional URL(s) to search for packages
  --delete-conflicting (-D)      no longer needed; don't use this
  --ignore-conflicts-at-my-risk  no longer needed; don't use this
  --build-directory (-b)         download/extract/build in DIR; keep the
                                 results
  --optimize (-O)                also compile with optimization: -O1 for
                                 "python -O", -O2 for "python -OO", and -O0 to
                                 disable [default: -O0]
  --record                       filename in which to record list of installed
                                 files
  --always-unzip (-Z)            don't install as a zipfile, no matter what
  --site-dirs (-S)               list of directories where .pth files work
  --editable (-e)                Install specified packages in editable form
  --no-deps (-N)                 don't install dependencies
  --allow-hosts (-H)             pattern(s) that hostnames must match
  --local-snapshots-ok (-l)      allow building eggs from local checkouts

usage: easy_install [options] requirement_or_url ...
   or: easy_install --help

Oh yeah, that looks awesome. Most terminal windows on modern OSes default to 24 lines. easy_install --help clocks in at 42 lines. Fail.

Even better, try running easy_install help (without the dashes):

sjl at ecgtheow in ~
[11] $ easy_install help
Searching for help
Reading http://pypi.python.org/simple/help/
Couldn't find index page for 'help' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading http://pypi.python.org/simple/
No local packages or download links found for help
error: Could not find suitable distribution for Requirement.parse('help')

sjl at ecgtheow in ~
[11] $ 

I have no words for this.

We can do better:

  • gorilla help and gorilla --help must both work.
  • The output must be less than or equal to 22 lines (to support those of us with two-line prompts).
  • It should list the most common commands and simple descriptions, and mentions "see gorilla help <command> for more information".

Yeah, that means we don't get to use optparse to cop out of formatting all the help. Too bad.

Eggs (Especially Zipped Ones)

Kill them. Kill them with fire.

Most (all?) Python packages run just as well when you symlink the package code directly. This keeps the code out in the open where people can tweak it if they need to.

Keeping the packages in real VCS repositories and symlinking them means that when someone does tweak it it's far easier to send a patch to the maintainer. This will help promote contributions in the community, in its own small way.

Dependencies

easy_install really shits the bed on this one. It doesn't do much checking to make sure it can successfully install any dependencies, so it can install some things and not others.

When you install a library with gorilla install which depends on other things, it should:

  • Mention the dependencies it's going to install first, and prompt you to make sure you're cool with those.
  • Clone all the repos. Clean up and bail if any of them fail (after trying all fallbacks, of course).
  • Build all the repos. Clean up and bail if any of them fail.
  • One at a time (in the correct order) symlink and test each library. Clean up and bail if any of them fail.

PIP

One major thing PIP does right is the "freeze" feature and requirements files. Gorilla should support a similar feature. This should only freeze apps installed by gorilla and their versions in the current environment (global, user, venv). This kind of feature is very useful for automated deployment.

$ gorilla freeze
django=1.1.1
django-south=0.6
$ gorilla freeze > frozen.gorilla
$ workon myblog
(myblog)$ gorilla thaw frozen.gorilla
Installing django 1.1.1
Installing django-south 0.6

Updated