Windows: get environment set by subprocess

10 views
Skip to first unread message

sachin...@gmail.com

unread,
Apr 2, 2015, 6:51:47 PM4/2/15
to python...@googlegroups.com
Hi Vinay,

I am using this sarge version: vinay.sajip-sarge-8ef70d2c06b7

I want to do this:
  1) Run this batch script "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\vsvars32.bat". 
        - This script sets some ENV variables and probably some registry settings as well for Visual Studio 2012 build environment
  2) which devenv  # This should not correctly find devenv executable in Visual Studio 11.0 directory

I tried this with sarge:

   p=sarge.Pipeline('"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\\vsvars32.bat"; which devenv')
   p.run()

'which devenv' is not able to find 'devenv'. If I run these 2 commands from cmd.exe in Windows it works fine [Note: I have cygwin installed - so 'which' command works from cmd.exe]

I guess 2 commands in Pipeline are getting executed in 2 different subprocess and that's why ENV set in 1st command is not visible in 2nd subprocess. Is my guess correct?

How do I solve this problem?

Thanks,
Sachin 

Vinay Sajip

unread,
Apr 2, 2015, 6:57:35 PM4/2/15
to python...@googlegroups.com
Dear Sachin,

You can't - environment variables will be set in the individual child process only and not available except to it and its child processes. This behaviour is by design, so it can't be worked around. (I don't believe the registry is altered by vcvars32.bat.)

Regards,

Vinay Sajip

Sachin Gaikwad

unread,
Apr 3, 2015, 1:10:30 AM4/3/15
to python...@googlegroups.com
ok. Is it possible to get ENV of child process which executed 'vsvars32.bat'? Then I can pass that ENV dictionary to my next command as "env=ENV"?

Sachin

--
You received this message because you are subscribed to the Google Groups "sarge" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-sarge...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Vinay Sajip

unread,
Apr 7, 2015, 4:25:35 AM4/7/15
to python...@googlegroups.com
> ok. Is it possible to get ENV of child process which executed 'vsvars32.bat'?

Only from within the process itself or its children. This is not related to sarge - it's just how environments work.

Regards,

Vinay Sajip
Reply all
Reply to author
Forward
0 new messages