Use distlib to emulate pkg_resources

I've merged the latest changes. I got some test failures, but all of these appear to be because the test virtualenv created in `tests/tests_cache/test_ws/setuptools/.virtualenv` had *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.

I fixed the failures by adding code to ensure that any old `pip` directory is removed after the uninstallation.

*Note:* There are some occurrences of `pkg_resources` in string literals, which I haven't changed. These might need looking at.