Using Python to automate builds

Kosta kosta.koeman at
Thu Aug 6 19:27:56 CEST 2009

On Aug 6, 3:57 am, David Cournapeau <courn... at> wrote:
> On Thu, Aug 6, 2009 at 12:39 AM, Kosta<kosta.koe... at> wrote:
> > Setenv.bat sets up the path and other environment variables build.exe
> > needs to compile and link (and even binplace) its utilities.  So
> > building itself is not the issue.  The problem is that if I call
> > setenv.bat from Python and then build.exe, but the modifications to
> > the path (and other environment settings) are not seen by Python, so
> > the attempt to build without a specified path fails.
> It sounds like you do not propagate the environment when calling
> setenv.bat from python. There is an option to do so in
> subprocess.Popen init method, or you can define your own environment
> if you do not want to propagate the whole environment (but this is
> often difficult to avoid for build environment in my experience,
> expecially if you don't have access to the sources of the whole system
> to check which variables are necessary).
> David


Thanks you.  I looked up the docs on Popen (
library/subprocess.html) where I read:

On Windows: the Popen class uses CreateProcess() to execute the child
program, which operates on strings. If args is a sequence, it will be
converted to a string using the list2cmdline() method. Please note
that not all MS Windows applications interpret the command line the
same way: list2cmdline() is designed for applications using the same
rules as the MS C runtime.

My interpretation of the above (and your email) is that using Popen
allows one to pass the Python environment to a child processs (in my
case, setenv.bat).   I need the reverse, to propagate from the child
to the parent.


More information about the Python-list mailing list