From 81ebc1a1de97f515e127d33786328df7092c767d Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Wed, 24 Jul 2019 16:47:20 +0200 Subject: [PATCH 1/5] build: add test run Node.js 12 & Python 3.7 on macOS Refs: https://github.com/nodejs/node-gyp/pull/1846 PR-URL: https://github.com/nodejs/node-gyp/pull/1843 --- .travis.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a6dd2dcf28..1e0aaf0357 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ matrix: python: 2.7 - name: "Python 2.7 on macOS" os: osx - osx_image: xcode10.2 + osx_image: xcode11 language: shell # 'language: python' is not yet supported on macOS env: NODE_GYP_FORCE_PYTHON=python2 before_install: HOMEBREW_NO_AUTO_UPDATE=1 brew install npm @@ -28,6 +28,7 @@ matrix: PATH=/c/Python27:/c/Python27/Scripts:$PATH NODE_GYP_FORCE_PYTHON=/c/Python27/python.exe before_install: choco install python2 + - name: "Node.js 6 & Python 3.7 on Linux" python: 3.7 env: NODE_GYP_FORCE_PYTHON=python3 EXPERIMENTAL_NODE_GYP_PYTHON3=1 @@ -44,6 +45,12 @@ matrix: python: 3.7 env: NODE_GYP_FORCE_PYTHON=python3 EXPERIMENTAL_NODE_GYP_PYTHON3=1 before_install: nvm install 12 + - name: "Node.js 12 & Python 3.7 on macOS" + os: osx + 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 - name: "Node.js 12 & Python 3.7 on Windows" os: windows language: node_js @@ -53,6 +60,7 @@ matrix: NODE_GYP_FORCE_PYTHON=/c/Python37/python.exe EXPERIMENTAL_NODE_GYP_PYTHON3=1 before_install: choco install python + allow_failures: - env: NODE_GYP_FORCE_PYTHON=python3 EXPERIMENTAL_NODE_GYP_PYTHON3=1 - env: >- From 0a4ee0f73dfada5ed77880e913ffcd495f9543ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Reis?= Date: Tue, 23 Jul 2019 14:58:10 +0100 Subject: [PATCH 2/5] test: accept Python 3 in test-find-python.js PR-URL: https://github.com/nodejs/node-gyp/pull/1843 --- .travis.yml | 3 ++- test/test-find-python.js | 15 ++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1e0aaf0357..5e744b64e2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -62,7 +62,8 @@ matrix: before_install: choco install python allow_failures: - - env: NODE_GYP_FORCE_PYTHON=python3 EXPERIMENTAL_NODE_GYP_PYTHON3=1 + - os: osx + env: NODE_GYP_FORCE_PYTHON=python3 EXPERIMENTAL_NODE_GYP_PYTHON3=1 - env: >- PATH=/c/Python37:/c/Python37/Scripts:$PATH NODE_GYP_FORCE_PYTHON=/c/Python37/python.exe diff --git a/test/test-find-python.js b/test/test-find-python.js index c52a579666..1c86f45b73 100644 --- a/test/test-find-python.js +++ b/test/test-find-python.js @@ -1,13 +1,12 @@ 'use strict' +delete process.env.PYTHON + const test = require('tap').test const findPython = require('../lib/find-python') const execFile = require('child_process').execFile const PythonFinder = findPython.test.PythonFinder -delete process.env.PYTHON -delete process.env.NODE_GYP_FORCE_PYTHON - require('npmlog').level = 'warn' test('find python', function (t) { @@ -17,8 +16,13 @@ test('find python', function (t) { t.strictEqual(err, null) var proc = execFile(found, ['-V'], function (err, stdout, stderr) { t.strictEqual(err, null) - t.strictEqual(stdout, '') - t.ok(/Python 2/.test(stderr)) + if (/Python 2/.test(stderr)) { + t.strictEqual(stdout, '') + t.ok(/Python 2/.test(stderr)) + } else { + t.ok(/Python 3/.test(stdout)) + t.strictEqual(stderr, '') + } }) proc.stdout.setEncoding('utf-8') proc.stderr.setEncoding('utf-8') @@ -51,6 +55,7 @@ TestPythonFinder.prototype.log = { warn: () => {}, error: () => {} } +delete TestPythonFinder.prototype.env.NODE_GYP_FORCE_PYTHON test('find python - python', function (t) { t.plan(6) From 5c89edb626f7a9cd3e5a643010f6d6005c5523c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Reis?= Date: Tue, 23 Jul 2019 16:02:09 +0100 Subject: [PATCH 3/5] gyp: Python 3 Windows fixes PR-URL: https://github.com/nodejs/node-gyp/pull/1843 --- .travis.yml | 4 ---- gyp/pylib/gyp/MSVSNew.py | 2 +- gyp/pylib/gyp/common.py | 3 +++ gyp/pylib/gyp/easy_xml.py | 4 ++-- gyp/pylib/gyp/generator/msvs.py | 8 ++++---- 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5e744b64e2..1bebc668b7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -64,10 +64,6 @@ matrix: allow_failures: - os: osx env: NODE_GYP_FORCE_PYTHON=python3 EXPERIMENTAL_NODE_GYP_PYTHON3=1 - - env: >- - PATH=/c/Python37:/c/Python37/Scripts:$PATH - NODE_GYP_FORCE_PYTHON=/c/Python37/python.exe - EXPERIMENTAL_NODE_GYP_PYTHON3=1 install: #- pip install -r requirements.txt - pip install flake8 # pytest # add another testing frameworks later diff --git a/gyp/pylib/gyp/MSVSNew.py b/gyp/pylib/gyp/MSVSNew.py index 0ec628cc1f..9b64e2c1c8 100644 --- a/gyp/pylib/gyp/MSVSNew.py +++ b/gyp/pylib/gyp/MSVSNew.py @@ -45,7 +45,7 @@ def MakeGuid(name, seed='msvs_new'): not change when the project for a target is rebuilt. """ # Calculate a MD5 signature for the seed and name. - d = hashlib.md5(str(seed) + str(name)).hexdigest().upper() + d = hashlib.md5((str(seed) + str(name)).encode('utf-8')).hexdigest().upper() # Convert most of the signature to GUID form (discard the rest) guid = ('{' + d[:8] + '-' + d[8:12] + '-' + d[12:16] + '-' + d[16:20] + '-' + d[20:32] + '}') diff --git a/gyp/pylib/gyp/common.py b/gyp/pylib/gyp/common.py index 834a8e6c95..657134a78f 100644 --- a/gyp/pylib/gyp/common.py +++ b/gyp/pylib/gyp/common.py @@ -394,6 +394,9 @@ def close(self): os.unlink(self.tmp_path) raise + def write(self, s): + self.tmp_file.write(s.encode('utf-8')) + return Writer() diff --git a/gyp/pylib/gyp/easy_xml.py b/gyp/pylib/gyp/easy_xml.py index 7c3f621f1f..1ddd909175 100644 --- a/gyp/pylib/gyp/easy_xml.py +++ b/gyp/pylib/gyp/easy_xml.py @@ -120,7 +120,7 @@ def WriteXmlIfChanged(content, path, encoding='utf-8', pretty=False, default_encoding = locale.getdefaultlocale()[1] if default_encoding.upper() != encoding.upper(): - xml_string = xml_string.decode(default_encoding).encode(encoding) + xml_string = xml_string.encode(encoding) # Get the old content try: @@ -132,7 +132,7 @@ def WriteXmlIfChanged(content, path, encoding='utf-8', pretty=False, # It has changed, write it if existing != xml_string: - f = open(path, 'w') + f = open(path, 'wb') f.write(xml_string) f.close() diff --git a/gyp/pylib/gyp/generator/msvs.py b/gyp/pylib/gyp/generator/msvs.py index 2dc967d709..5e5b2ee52a 100644 --- a/gyp/pylib/gyp/generator/msvs.py +++ b/gyp/pylib/gyp/generator/msvs.py @@ -1753,8 +1753,8 @@ def _CollapseSingles(parent, node): # such projects up one level. if (type(node) == dict and len(node) == 1 and - node.keys()[0] == parent + '.vcproj'): - return node[node.keys()[0]] + list(node)[0] == parent + '.vcproj'): + return node[list(node)[0]] if type(node) != dict: return node for child in node: @@ -1773,8 +1773,8 @@ def _GatherSolutionFolders(sln_projects, project_objects, flat): # Walk down from the top until we hit a folder that has more than one entry. # In practice, this strips the top-level "src/" dir from the hierarchy in # the solution. - while len(root) == 1 and type(root[root.keys()[0]]) == dict: - root = root[root.keys()[0]] + while len(root) == 1 and type(root[list(root)[0]]) == dict: + root = root[list(root)[0]] # Collapse singles. root = _CollapseSingles('', root) # Merge buckets until everything is a root entry. From 6ff85b574d35cc8cc82e93f14fef53a8f2daacad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Reis?= Date: Thu, 25 Jul 2019 01:16:36 +0100 Subject: [PATCH 4/5] fixup: macOS actually uses Node 10 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1bebc668b7..63c1005297 100644 --- a/.travis.yml +++ b/.travis.yml @@ -45,7 +45,7 @@ matrix: python: 3.7 env: NODE_GYP_FORCE_PYTHON=python3 EXPERIMENTAL_NODE_GYP_PYTHON3=1 before_install: nvm install 12 - - name: "Node.js 12 & Python 3.7 on macOS" + - name: "Python 3.7 on macOS" os: osx osx_image: xcode11 language: shell # 'language: python' is not yet supported on macOS From 3428750c3eca7240564056d08bfb64018e4c4163 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Reis?= Date: Thu, 25 Jul 2019 03:00:47 +0100 Subject: [PATCH 5/5] try without xcode11 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 63c1005297..ab77f250af 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