From 2863402e9eb09db685033ff805b5672fa2aefd70 Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Wed, 22 Aug 2018 02:42:20 +0200 Subject: [PATCH 1/3] move proton from python2.7 to python3 --- proton | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/proton b/proton index a5b8e251..e5e462ba 100755 --- a/proton +++ b/proton @@ -1,4 +1,4 @@ -#!/usr/bin/env python2.7 +#!/usr/bin/env python3 #script to launch Wine with the correct environment @@ -309,7 +309,7 @@ if "nod3d11" in config_opts: del dlloverrides["dxgi"] s = "" -for dll, setting in dlloverrides.iteritems(): +for dll, setting in dlloverrides.items(): if len(s) > 0: s = s + ";" + dll + "=" + setting else: @@ -376,7 +376,7 @@ def dump_dbg_scripts(): f.write("cd \"" + os.getcwd() + "\"\n") dump_dbg_env(f) f.write("\t\"" + wine_path + "\" winedbg \"$@\"\n") - os.chmod("/tmp/proton_winedbg", 0755) + os.chmod("/tmp/proton_winedbg", 0o755) with open("/tmp/proton_winedbg_run", "w") as f: f.write("#!/bin/bash\n") @@ -393,7 +393,7 @@ def dump_dbg_scripts(): f.write(")\n") dump_dbg_env(f) f.write("\t\"" + wine_path + "\" winedbg \"${@:-${DEF_CMD[@]}}\"\n") - os.chmod("/tmp/proton_winedbg_run", 0755) + os.chmod("/tmp/proton_winedbg_run", 0o755) with open("/tmp/proton_gdb_attach", "w") as f: f.write("#!/bin/bash\n") @@ -408,7 +408,7 @@ def dump_dbg_scripts(): f.write("WPID_DEC=$(printf %d 0x$WPID_HEX)\n") dump_dbg_env(f) f.write("\t\"" + wine_path + "\" winedbg --gdb $WPID_DEC\n") - os.chmod("/tmp/proton_gdb_attach", 0755) + os.chmod("/tmp/proton_gdb_attach", 0o755) with open("/tmp/proton_gdb_run", "w") as f: f.write("#!/bin/bash\n") @@ -425,7 +425,7 @@ def dump_dbg_scripts(): f.write(")\n") dump_dbg_env(f) f.write("\t\"" + wine_path + "\" winedbg --gdb \"${@:-${DEF_CMD[@]}}\"\n") - os.chmod("/tmp/proton_gdb_run", 0755) + os.chmod("/tmp/proton_gdb_run", 0o755) with open("/tmp/proton_run", "w") as f: f.write("#!/bin/bash\n") @@ -445,7 +445,7 @@ def dump_dbg_scripts(): f.write("\t\"" + wine_path + "\" start \"${@:-${DEF_CMD[@]}}\"\n") else: f.write("\t\"" + wine_path + "\" \"${@:-${DEF_CMD[@]}}\"\n") - os.chmod("/tmp/proton_run", 0755) + os.chmod("/tmp/proton_run", 0o755) def run(): # if "PROTON_DUMP_DEBUG_COMMAND" in os.environ: #for now, we are always dumping the debug scripts @@ -469,11 +469,11 @@ elif sys.argv[1] == "waitforexitandrun": elif sys.argv[1] == "getcompatpath": #linux -> windows path path = subprocess.check_output([wine_path, "winepath", "-w", sys.argv[2]], env=env, stderr=lfile) - sys.stdout.write(path) + sys.stdout.write(path.decode('utf-8')) elif sys.argv[1] == "getnativepath": #windows -> linux path path = subprocess.check_output([wine_path, "winepath", sys.argv[2]], env=env, stderr=lfile) - sys.stdout.write(path) + sys.stdout.write(path.decode('utf-8')) else: log("Need a verb.") sys.exit(1) From 9c3667c0836fb952df0e1594bdda5c18128c811c Mon Sep 17 00:00:00 2001 From: Mayeul Cantan Date: Thu, 23 Aug 2018 13:21:22 +0200 Subject: [PATCH 2/3] Make proton, gen_wrapper and user_settings python scripts version-agnostic --- lsteamclient/gen_wrapper.py | 4 ++-- proton | 16 ++++++++++++---- user_settings.sample.py | 2 +- vrclient_x64/gen_wrapper.py | 6 +++--- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/lsteamclient/gen_wrapper.py b/lsteamclient/gen_wrapper.py index a9c6e7fd..010689f9 100755 --- a/lsteamclient/gen_wrapper.py +++ b/lsteamclient/gen_wrapper.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python #NOTE: If you make modifications here, consider whether they should #be duplicated in ../vrclient/gen_wrapper.py @@ -502,7 +502,7 @@ for sdkver in sdk_versions: diagnostics = list(tu.diagnostics) if len(diagnostics) > 0: - print 'There were parse errors' + print('There were parse errors') pprint.pprint(diagnostics) else: children = list(tu.cursor.get_children()) diff --git a/proton b/proton index e5e462ba..c9355372 100755 --- a/proton +++ b/proton @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python #script to launch Wine with the correct environment @@ -309,7 +309,8 @@ if "nod3d11" in config_opts: del dlloverrides["dxgi"] s = "" -for dll, setting in dlloverrides.items(): +for dll in dlloverrides: + setting = dlloverrides[dll] if len(s) > 0: s = s + ";" + dll + "=" + setting else: @@ -457,6 +458,13 @@ def run(): else: run_wine([wine_path] + sys.argv[2:]) +if sys.version_info[0] == 2: + binary_stdout = sys.stdout +elif sys.version_info[0] == 3: + binary_stdout = sys.stdout.buffer +else: + raise Exception("Unsuported python version") + #determine mode if sys.argv[1] == "run": #start target app @@ -469,11 +477,11 @@ elif sys.argv[1] == "waitforexitandrun": elif sys.argv[1] == "getcompatpath": #linux -> windows path path = subprocess.check_output([wine_path, "winepath", "-w", sys.argv[2]], env=env, stderr=lfile) - sys.stdout.write(path.decode('utf-8')) + binary_stdout.write(path) elif sys.argv[1] == "getnativepath": #windows -> linux path path = subprocess.check_output([wine_path, "winepath", sys.argv[2]], env=env, stderr=lfile) - sys.stdout.write(path.decode('utf-8')) + binary_stdout.write(path) else: log("Need a verb.") sys.exit(1) diff --git a/user_settings.sample.py b/user_settings.sample.py index 24fa339c..a3ee5331 100755 --- a/user_settings.sample.py +++ b/user_settings.sample.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2.7 +#!/usr/bin/env python #to enable these settings, name this file "user_settings.py" diff --git a/vrclient_x64/gen_wrapper.py b/vrclient_x64/gen_wrapper.py index 0b196ee5..ad28fb4d 100755 --- a/vrclient_x64/gen_wrapper.py +++ b/vrclient_x64/gen_wrapper.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python #NOTE: If you make modifications here, consider whether they should #be duplicated in ../lsteamclient/gen_wrapper.py @@ -403,7 +403,7 @@ def get_capi_thunk_params(method): def toBOOL(x): return "TRUE" if x else "FALSE" returns_record = method.result_type.get_canonical().kind == clang.cindex.TypeKind.RECORD - param_types = map(lambda x: x.type, get_params(method)) + param_types = [x.type for x in get_params(method)] if returns_record: param_types.insert(0, method.result_type) param_count = len(param_types) @@ -970,7 +970,7 @@ for sdkver in sdk_versions: diagnostics = list(tu.diagnostics) if len(diagnostics) > 0: - print 'There were parse errors' + print('There were parse errors') pprint.pprint(diagnostics) else: children = list(tu.cursor.get_children()) From 0f80f2f52c4bd1e9ce54098c25a54d2a71c098df Mon Sep 17 00:00:00 2001 From: Mayeul Cantan Date: Fri, 24 Aug 2018 09:18:36 +0200 Subject: [PATCH 3/3] Import print_function from __future__ for python compatibility This alters the behaviour of python2's print statement to be compatible with python3's print function. While not strictly necessary for now, this might help future compatibility. Thanks to Seppo Yli-Olli (@nanonyme) for suggesting this. --- lsteamclient/gen_wrapper.py | 2 ++ proton | 2 ++ vrclient_x64/gen_wrapper.py | 2 ++ 3 files changed, 6 insertions(+) diff --git a/lsteamclient/gen_wrapper.py b/lsteamclient/gen_wrapper.py index 010689f9..4451d3de 100755 --- a/lsteamclient/gen_wrapper.py +++ b/lsteamclient/gen_wrapper.py @@ -3,6 +3,8 @@ #NOTE: If you make modifications here, consider whether they should #be duplicated in ../vrclient/gen_wrapper.py +from __future__ import print_function + import pprint import sys import clang.cindex diff --git a/proton b/proton index c9355372..da6501d3 100755 --- a/proton +++ b/proton @@ -2,6 +2,8 @@ #script to launch Wine with the correct environment +from __future__ import print_function + import filecmp import json import os diff --git a/vrclient_x64/gen_wrapper.py b/vrclient_x64/gen_wrapper.py index ad28fb4d..13709599 100755 --- a/vrclient_x64/gen_wrapper.py +++ b/vrclient_x64/gen_wrapper.py @@ -3,6 +3,8 @@ #NOTE: If you make modifications here, consider whether they should #be duplicated in ../lsteamclient/gen_wrapper.py +from __future__ import print_function + import pprint import sys import clang.cindex