I'm trying to write a python wrapper for building some software. I need to automate building it hundreds of times with different configurations which means I can't just autogen.sh ; ./configure ; make ; make install
. Some of the configurations I use require running a script which conditionally set up some environment variables. What I want is to be able to do something like this:
command = './autogen.sh'
ret = subprocess.call(command.split())
if ret != 0:
sys.exit(ret)
command = './script.sh ; ./configure <configure-flags>'
ret = subprocess.call(command.split())
if ret != 0:
sys.exit(ret)
command = 'make'
ret = subprocess.call(command.split())
if ret != 0:
sys.exit(ret)
command = 'make install'
ret = subprocess.call(command.split())
if ret != 0):
sys.exit(ret)
The problem I'm running into is that the environment variables set in script.sh
are not getting preserved for configure
. I saw a partial solution in Sending multiple commands to a bash shell which must share an environment, but that involves flushing the commands to stdin
and polling for a result which won't really work when you have a really long makefile (mine takes about 10 - 20 minutes) and it also doesn't give you the return value which I need to know if the build was successful or not.
Does anyone know a better way to do this?