mirror of
https://github.com/electron/node-gyp.git
synced 2025-08-15 12:58:19 +02:00
gyp: decode stdout on Python 3
PR-URL: https://github.com/nodejs/node-gyp/pull/1890 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Richard Lau <riclau@uk.ibm.com>
This commit is contained in:
parent
8d4ea7f13e
commit
d90d9c5426
2 changed files with 7 additions and 4 deletions
|
@ -61,9 +61,6 @@ matrix:
|
|||
EXPERIMENTAL_NODE_GYP_PYTHON3=1
|
||||
before_install: choco install python
|
||||
|
||||
allow_failures:
|
||||
- os: osx
|
||||
env: NODE_GYP_FORCE_PYTHON=python3 EXPERIMENTAL_NODE_GYP_PYTHON3=1
|
||||
install:
|
||||
#- pip install -r requirements.txt
|
||||
- pip install flake8 # pytest # add another testing frameworks later
|
||||
|
|
|
@ -20,6 +20,8 @@ import sys
|
|||
import tempfile
|
||||
from gyp.common import GypError
|
||||
|
||||
PY3 = bytes != str
|
||||
|
||||
# Populated lazily by XcodeVersion, for efficiency, and to fix an issue when
|
||||
# "xcodebuild" is called too quickly (it has been found to return incorrect
|
||||
# version number).
|
||||
|
@ -1277,7 +1279,7 @@ def XcodeVersion():
|
|||
except:
|
||||
version = CLTVersion()
|
||||
if version:
|
||||
version = re.match(r'(\d+\.\d+\.?\d*)', version).groups()[0]
|
||||
version = ".".join(version.split(".")[:3])
|
||||
else:
|
||||
raise GypError("No Xcode or CLT version detected!")
|
||||
# The CLT has no build information, so we return an empty string.
|
||||
|
@ -1322,6 +1324,8 @@ def GetStdoutQuiet(cmdlist):
|
|||
Raises |GypError| if the command return with a non-zero return code."""
|
||||
job = subprocess.Popen(cmdlist, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
out = job.communicate()[0]
|
||||
if PY3:
|
||||
out = out.decode("utf-8")
|
||||
if job.returncode != 0:
|
||||
raise GypError('Error %d running %s' % (job.returncode, cmdlist[0]))
|
||||
return out.rstrip('\n')
|
||||
|
@ -1332,6 +1336,8 @@ def GetStdout(cmdlist):
|
|||
Raises |GypError| if the command return with a non-zero return code."""
|
||||
job = subprocess.Popen(cmdlist, stdout=subprocess.PIPE)
|
||||
out = job.communicate()[0]
|
||||
if PY3:
|
||||
out = out.decode("utf-8")
|
||||
if job.returncode != 0:
|
||||
sys.stderr.write(out + '\n')
|
||||
raise GypError('Error %d running %s' % (job.returncode, cmdlist[0]))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue