Move build logic into a shared python script.