mirror of
https://github.com/godotengine/godot
synced 2024-10-06 12:54:26 +00:00
Fix build with Python 3 on Windows
This commit is contained in:
parent
277e730d34
commit
a6d53effa5
|
@ -12,6 +12,8 @@ if sys.version_info < (3,):
|
||||||
return cStringIO.StringIO()
|
return cStringIO.StringIO()
|
||||||
def encode_utf8(x):
|
def encode_utf8(x):
|
||||||
return x
|
return x
|
||||||
|
def decode_utf8(x):
|
||||||
|
return x
|
||||||
def iteritems(d):
|
def iteritems(d):
|
||||||
return d.iteritems()
|
return d.iteritems()
|
||||||
def escape_string(s):
|
def escape_string(s):
|
||||||
|
@ -38,6 +40,8 @@ else:
|
||||||
import codecs
|
import codecs
|
||||||
def encode_utf8(x):
|
def encode_utf8(x):
|
||||||
return codecs.utf_8_encode(x)[0]
|
return codecs.utf_8_encode(x)[0]
|
||||||
|
def decode_utf8(x):
|
||||||
|
return codecs.utf_8_decode(x)[0]
|
||||||
def iteritems(d):
|
def iteritems(d):
|
||||||
return iter(d.items())
|
return iter(d.items())
|
||||||
def charcode_to_c_escapes(c):
|
def charcode_to_c_escapes(c):
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
|
|
||||||
|
from compat import decode_utf8
|
||||||
|
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
import sys
|
import sys
|
||||||
if sys.version_info < (3,):
|
if sys.version_info < (3,):
|
||||||
|
@ -12,7 +14,7 @@ if os.name == 'nt':
|
||||||
def _reg_open_key(key, subkey):
|
def _reg_open_key(key, subkey):
|
||||||
try:
|
try:
|
||||||
return winreg.OpenKey(key, subkey)
|
return winreg.OpenKey(key, subkey)
|
||||||
except WindowsError, OSError:
|
except (WindowsError, OSError):
|
||||||
if platform.architecture()[0] == '32bit':
|
if platform.architecture()[0] == '32bit':
|
||||||
bitness_sam = winreg.KEY_WOW64_64KEY
|
bitness_sam = winreg.KEY_WOW64_64KEY
|
||||||
else:
|
else:
|
||||||
|
@ -40,7 +42,7 @@ def _find_mono_in_reg(subkey, bits):
|
||||||
with _reg_open_key_bits(winreg.HKEY_LOCAL_MACHINE, subkey, bits) as hKey:
|
with _reg_open_key_bits(winreg.HKEY_LOCAL_MACHINE, subkey, bits) as hKey:
|
||||||
value, regtype = winreg.QueryValueEx(hKey, 'SdkInstallRoot')
|
value, regtype = winreg.QueryValueEx(hKey, 'SdkInstallRoot')
|
||||||
return value
|
return value
|
||||||
except WindowsError, OSError:
|
except (WindowsError, OSError):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
@ -79,7 +81,7 @@ def find_msbuild_tools_path_reg():
|
||||||
lines = subprocess.check_output([vswhere] + vswhere_args).splitlines()
|
lines = subprocess.check_output([vswhere] + vswhere_args).splitlines()
|
||||||
|
|
||||||
for line in lines:
|
for line in lines:
|
||||||
parts = line.split(':', 1)
|
parts = decode_utf8(line).split(':', 1)
|
||||||
|
|
||||||
if len(parts) < 2 or parts[0] != 'installationPath':
|
if len(parts) < 2 or parts[0] != 'installationPath':
|
||||||
continue
|
continue
|
||||||
|
@ -96,7 +98,7 @@ def find_msbuild_tools_path_reg():
|
||||||
print('Error reading output from vswhere: ' + e.message)
|
print('Error reading output from vswhere: ' + e.message)
|
||||||
except WindowsError:
|
except WindowsError:
|
||||||
pass # Fine, vswhere not found
|
pass # Fine, vswhere not found
|
||||||
except subprocess.CalledProcessError, OSError:
|
except (subprocess.CalledProcessError, OSError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Try to find 14.0 in the Registry
|
# Try to find 14.0 in the Registry
|
||||||
|
@ -106,7 +108,7 @@ def find_msbuild_tools_path_reg():
|
||||||
with _reg_open_key(winreg.HKEY_LOCAL_MACHINE, subkey) as hKey:
|
with _reg_open_key(winreg.HKEY_LOCAL_MACHINE, subkey) as hKey:
|
||||||
value, regtype = winreg.QueryValueEx(hKey, 'MSBuildToolsPath')
|
value, regtype = winreg.QueryValueEx(hKey, 'MSBuildToolsPath')
|
||||||
return value
|
return value
|
||||||
except WindowsError, OSError:
|
except (WindowsError, OSError):
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
return ''
|
return ''
|
||||||
|
|
Loading…
Reference in a new issue