hctgettaef.py 792 B

1234567891011121314151617181920212223
  1. import urllib
  2. import os
  3. import zipfile
  4. url = "https://github.com/Microsoft/WinObjC/raw/develop/deps/prebuilt/nuget/taef.redist.wlk.1.0.170206001-nativetargets.nupkg"
  5. zipfile_name = os.path.join(os.environ['TEMP'], "taef.redist.wlk.1.0.170206001-nativetargets.nupkg.zip")
  6. src_dir = os.environ['HLSL_SRC_DIR']
  7. taef_dir = os.path.join(src_dir, "external", "taef")
  8. if not os.path.isdir(taef_dir):
  9. os.makedirs(taef_dir)
  10. try:
  11. urllib.urlretrieve(url, zipfile_name)
  12. except:
  13. print("Unable to read file with urllib, trying via powershell...")
  14. from subprocess import check_call
  15. cmd = "(new-object System.Net.WebClient).DownloadFile('" + url + "', '" + zipfile_name + "')"
  16. check_call(['powershell.exe', '-Command', cmd])
  17. z = zipfile.ZipFile(zipfile_name)
  18. z.extractall(taef_dir)
  19. z.close()