The last half of this file seems like an unnecessary hack that could be better solved with a main.sh. Is there reason for not building up the environment with the shell and then calling python?