pypi: break things into a package and make package pip installable

I will need to upload this to pypi still, but a quick test
confirms that everything seems to be working correctly.