Use distlib to emulate pkg_resources

I've merged the latest changes. I'm getting four test failures, but all of these appear to be because the test virtualenv created in `tests/tests_cache/test_ws/setuptools/.virtualenv` has *both* pip-1.3.1 and pip-1.4.dev1 in its `site-packages`. I can't see any reason why the uninstallation of pip during the test environment creation fails, and there's no check for failure in the env creation process.

It may be something to do with my test environment, but I'm not sure what (I'm running a vanilla Ubuntu Oneiric 64-bit).