From c07ae1c75b07765213f11189c3caae5af5383863 Mon Sep 17 00:00:00 2001 From: chengzihan2 Date: Tue, 15 Sep 2020 10:07:28 +0800 Subject: [PATCH] default to python3 instead of python2 --- node-gyp-python3.patch | 104 +++++++++++++++++++++++++++++++++++++++++ node-gyp.spec | 7 ++- 2 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 node-gyp-python3.patch diff --git a/node-gyp-python3.patch b/node-gyp-python3.patch new file mode 100644 index 0000000..ff2f540 --- /dev/null +++ b/node-gyp-python3.patch @@ -0,0 +1,104 @@ +commit d0eb1892fcb0b256fc2b0e747a51d94ab0da3cb3 +Author: Tom Hughes +Date: Thu Aug 15 21:30:32 2019 +0100 + + Default to python3 instead of python2 + +diff --git a/lib/configure.js b/lib/configure.js +index 5538e44..0f7c19b 100644 +--- a/lib/configure.js ++++ b/lib/configure.js +@@ -29,7 +29,7 @@ exports.usage = 'Generates ' + (win ? 'MSVC project files' : 'a Makefile') + ' f + + function configure (gyp, argv, callback) { + +- var python = gyp.opts.python || process.env.PYTHON || 'python2' ++ var python = gyp.opts.python || process.env.PYTHON || 'python3' + , buildDir = path.resolve('build') + , configNames = [ 'config.gypi', 'common.gypi' ] + , configs = [] +@@ -461,7 +461,7 @@ PythonFinder.prototype = { + this.log.silly('stripping "rc" identifier from version') + version = version.replace(/rc(.*)$/ig, '') + } +- var range = semver.Range('>=2.5.0 <3.0.0') ++ var range = semver.Range('>=3.7.0 <4.0.0') + var valid = false + try { + valid = range.test(version) +@@ -490,7 +490,7 @@ PythonFinder.prototype = { + 'Python executable "' + this.python + + '" is v' + badVersion + ', which is not supported by gyp.\n' + + 'You can pass the --python switch to point to ' + +- 'Python >= v2.5.0 & < 3.0.0.' ++ 'Python >= v3.7.0 & < 4.0.0.' + this.callback(new Error(errmsg)) + }, + +diff --git a/test/test-find-python.js b/test/test-find-python.js +index 2581a8e..4a43fd3 100644 +--- a/test/test-find-python.js ++++ b/test/test-find-python.js +@@ -38,7 +38,7 @@ test('find python - python', function (t) { + f.execFile = function(program, args, opts, cb) { + t.strictEqual(program, 'python') + t.ok(/import platform/.test(args[1])) +- cb(null, '2.7.0') ++ cb(null, '3.7.0') + } + f.checkPython() + +@@ -59,7 +59,7 @@ test('find python - python too old', function (t) { + f.execFile = function(program, args, opts, cb) { + t.strictEqual(program, 'python') + t.ok(/import platform/.test(args[1])) +- cb(null, '2.3.4') ++ cb(null, '3.4.5') + } + f.checkPython() + +@@ -79,7 +79,7 @@ test('find python - python too new', function (t) { + f.execFile = function(program, args, opts, cb) { + t.strictEqual(program, 'python') + t.ok(/import platform/.test(args[1])) +- cb(null, '3.0.0') ++ cb(null, '4.0.0') + } + f.checkPython() + +@@ -118,7 +118,7 @@ test('find python - no python2', function (t) { + f.execFile = function(program, args, opts, cb) { + t.strictEqual(program, 'python') + t.ok(/import platform/.test(args[1])) +- cb(null, '2.7.0') ++ cb(null, '3.7.0') + } + f.checkPython() + +@@ -165,7 +165,7 @@ test('find python - no python, use python launcher', function (t) { + f.execFile = function(program, args, opts, cb) { + t.strictEqual(program, 'Z:\\snake.exe') + t.ok(/import platform/.test(args[1])) +- cb(null, '2.7.0') ++ cb(null, '3.7.0') + } + t.strictEqual(program, 'py.exe') + t.notEqual(args.indexOf('-2'), -1) +@@ -196,7 +196,7 @@ test('find python - python 3, use python launcher', function (t) { + f.execFile = function(program, args, opts, cb) { + t.strictEqual(program, 'Z:\\snake.exe') + t.ok(/import platform/.test(args[1])) +- cb(null, '2.7.0') ++ cb(null, '3.7.0') + } + t.strictEqual(program, 'py.exe') + t.notEqual(args.indexOf('-2'), -1) +@@ -267,7 +267,7 @@ test('find python - no python, no python launcher, good guess', function (t) { + f.execFile = function(program, args, opts, cb) { + t.ok(re.test(program)) + t.ok(/import platform/.test(args[1])) +- cb(null, '2.7.0') ++ cb(null, '3.7.0') + } + t.strictEqual(program, 'py.exe') + cb(new Error('not found')) diff --git a/node-gyp.spec b/node-gyp.spec index ae7a593..9258daa 100644 --- a/node-gyp.spec +++ b/node-gyp.spec @@ -1,7 +1,7 @@ %{?nodejs_find_provides_and_requires} Name: node-gyp Version: 3.6.0 -Release: 1 +Release: 2 Summary: Node.js native addon build tool License: MIT URL: https://github.com/nodejs/node-gyp @@ -10,6 +10,7 @@ Source1: addon-rpm.gypi Patch1: node-gyp-addon-gypi.patch Patch2: node-gyp-system-gyp.patch Patch3: node-gyp-python.patch +Patch4: node-gyp-python3.patch BuildArch: noarch ExclusiveArch: %{nodejs_arches} noarch Requires: gyp nodejs-devel libuv-devel http-parser-devel gcc-c++ @@ -50,5 +51,9 @@ ln -sf ../lib/node_modules/node-gyp/bin/node-gyp.js %{buildroot}%{_bindir}/node- %{_bindir}/node-gyp %changelog +* Tue Sep 15 2020 chengzihan - 3.6.0-2 +- add patch node-gyp-python3.patch +- default to python3 instead of python2 + * Mon Aug 17 2020 Shaoqiang Kang - 3.6.0-1 - Package init -- Gitee