I need to write a script, on Windows, that calls a batch file to set some environment variables, then carries out some actions that make use of those environment variables.
If the calling script is itself a batch file, this works fine.
There would be some advantages to being able to write the calling script in Python, but when I try that, the environment variables set by the batch file don't persist after it returns. I'm guessing that's because subprocess.check_call(..., shell=True) spawns a fresh copy of the command shell, which takes the environment variables with it when it dies at the end of the batch file.
Is there a way to get the environment variables to persist when set by a batch file called from Python, or is it better to resign oneself to the calling script being itself a batch file?
os.environ? Im confused on why you need to call this other scriptdistutils.msvc9compiler.query_vcvarsall. Notice how it adds& setto the command to output the environment variables.