Skip to content

Instantly share code, notes, and snippets.

@zionyx
Forked from stania/setupVSEnv.py
Last active June 11, 2016 22:04
Show Gist options
  • Save zionyx/cd0db3d6027e9a2cd7366e26d1eda289 to your computer and use it in GitHub Desktop.
Save zionyx/cd0db3d6027e9a2cd7366e26d1eda289 to your computer and use it in GitHub Desktop.
python implementation replacing "call vsvars32.bat"
import os
import subprocess as sub
def vs_env_dict(vsver):
cmd = r'cmd /s /c ""%VS{0}COMNTOOLS%vsvars32.bat" & set"'.format(vsver)
output = sub.Popen(cmd, stdout=sub.PIPE, stderr=sub.STDOUT, stdin=sub.PIPE).communicate()[0].split(os.linesep)
return dict((e[0].upper(), e[1]) for e in [p.rstrip().split("=", 1) for p in output] if len(e) == 2)
#VS2010=100, VS2012=110, VS2013=120, VS2015=140
os.environ.update(vs_env_dict(100))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment