Reworked to script; py3 fixes in setup.py