From 1072c5af904bb9a2b1daa2db5d2dbe1a3eb8f3f6 Mon Sep 17 00:00:00 2001 From: cclauss Date: Thu, 26 Sep 2019 11:29:03 +0200 Subject: [PATCH 1/2] more decode stdout on Python 3 --- .travis.yml | 2 +- gyp/gyp_main.py | 10 ++++++++-- gyp/pylib/gyp/common.py | 6 +++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index f27f024f2d..3b1f6a55be 100644 --- a/.travis.yml +++ b/.travis.yml @@ -47,7 +47,7 @@ matrix: before_install: nvm install 12 - name: "Python 3.7 on macOS" os: osx - #osx_image: xcode11 + osx_image: xcode11 language: shell # 'language: python' is not yet supported on macOS env: NODE_GYP_FORCE_PYTHON=python3 EXPERIMENTAL_NODE_GYP_PYTHON3=1 before_install: HOMEBREW_NO_AUTO_UPDATE=1 brew install npm diff --git a/gyp/gyp_main.py b/gyp/gyp_main.py index 8dfc552e81..aece53c8eb 100755 --- a/gyp/gyp_main.py +++ b/gyp/gyp_main.py @@ -8,13 +8,17 @@ import sys import subprocess +PY3 = bytes != str + # Below IsCygwin() function copied from pylib/gyp/common.py def IsCygwin(): try: out = subprocess.Popen("uname", stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - stdout,stderr = out.communicate() + stdout, stderr = out.communicate() + if PY3: + stdout = stdout.decode("utf-8") return "CYGWIN" in str(stdout) except Exception: return False @@ -27,7 +31,9 @@ def UnixifyPath(path): out = subprocess.Popen(["cygpath", "-u", path], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - stdout,stderr = out.communicate() + stdout, stderr = out.communicate() + if PY3: + stdout = stdout.decode("utf-8") return str(stdout) except Exception: return path diff --git a/gyp/pylib/gyp/common.py b/gyp/pylib/gyp/common.py index 8296d11fc3..071ad7e242 100644 --- a/gyp/pylib/gyp/common.py +++ b/gyp/pylib/gyp/common.py @@ -11,6 +11,8 @@ import sys import subprocess +PY3 = bytes != str + # A minimal memoizing decorator. It'll blow up if the args aren't immutable, # among other "problems". @@ -623,7 +625,9 @@ def IsCygwin(): out = subprocess.Popen("uname", stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - stdout,stderr = out.communicate() + stdout, stderr = out.communicate() + if PY3: + stdout = stdout.decode("utf-8") return "CYGWIN" in str(stdout) except Exception: return False From fcf9b27ec481ee0b3d7d76c8d9b313d7d1ae37b9 Mon Sep 17 00:00:00 2001 From: cclauss Date: Thu, 26 Sep 2019 23:57:56 +0200 Subject: [PATCH 2/2] fixup: re-comment --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3b1f6a55be..f27f024f2d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -47,7 +47,7 @@ matrix: before_install: nvm install 12 - name: "Python 3.7 on macOS" os: osx - osx_image: xcode11 + #osx_image: xcode11 language: shell # 'language: python' is not yet supported on macOS env: NODE_GYP_FORCE_PYTHON=python3 EXPERIMENTAL_NODE_GYP_PYTHON3=1 before_install: HOMEBREW_NO_AUTO_UPDATE=1 brew install npm