make upgrade script work when called from python