Rewrite script/build in Python