rewrite build and package script by python