Setuptools support

Here's a new pull request with everything merged from upstream. GitHub says it's fine.