Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

configure: use sys.version_info to get python version #1504

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions lib/configure.js
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ PythonFinder.prototype = {
},

checkPythonVersion: function checkPythonVersion () {
var args = ['-c', 'import platform; print(platform.python_version());']
var args = ['-c', 'import sys; print "%s.%s.%s" % sys.version_info[:3];']
var env = extend({}, this.env)
env.TERM = 'dumb'

Expand All @@ -460,14 +460,6 @@ PythonFinder.prototype = {
'`%s -c "' + args[1] + '"` returned: %j',
this.python, stdout)
var version = stdout.trim()
if (~version.indexOf('+')) {
this.log.silly('stripping "+" sign(s) from version')
version = version.replace(/\+/g, '')
}
if (~version.indexOf('rc')) {
this.log.silly('stripping "rc" identifier from version')
version = version.replace(/rc(.*)$/ig, '')
}
var range = semver.Range('>=2.5.0 <3.0.0')
var valid = false
try {
Expand Down
20 changes: 10 additions & 10 deletions test/test-find-python.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,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]))
t.ok(/import sys/.test(args[1]))
cb(null, '2.7.0')
}
f.checkPython()
Expand All @@ -83,7 +83,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]))
t.ok(/import sys/.test(args[1]))
cb(null, '2.3.4')
}
f.checkPython()
Expand All @@ -103,7 +103,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]))
t.ok(/import sys/.test(args[1]))
cb(null, '3.0.0')
}
f.checkPython()
Expand Down Expand Up @@ -142,7 +142,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]))
t.ok(/import sys/.test(args[1]))
cb(null, '2.7.0')
}
f.checkPython()
Expand Down Expand Up @@ -189,7 +189,7 @@ test('find python - no python, use python launcher', function (t) {
f.execFile = function(program, args, opts, cb) {
f.execFile = function(program, args, opts, cb) {
t.strictEqual(program, 'Z:\\snake.exe')
t.ok(/import platform/.test(args[1]))
t.ok(/import sys/.test(args[1]))
cb(null, '2.7.0')
}
t.strictEqual(program, 'py.exe')
Expand Down Expand Up @@ -220,7 +220,7 @@ test('find python - python 3, use python launcher', function (t) {
f.execFile = function(program, args, opts, cb) {
f.execFile = function(program, args, opts, cb) {
t.strictEqual(program, 'Z:\\snake.exe')
t.ok(/import platform/.test(args[1]))
t.ok(/import sys/.test(args[1]))
cb(null, '2.7.0')
}
t.strictEqual(program, 'py.exe')
Expand All @@ -229,7 +229,7 @@ test('find python - python 3, use python launcher', function (t) {
cb(null, 'Z:\\snake.exe')
}
t.strictEqual(program, 'python')
t.ok(/import platform/.test(args[1]))
t.ok(/import sys/.test(args[1]))
cb(null, '3.0.0')
}
f.checkPython()
Expand Down Expand Up @@ -257,7 +257,7 @@ test('find python - python 3, use python launcher, python 2 too old',
f.execFile = function(program, args, opts, cb) {
f.execFile = function(program, args, opts, cb) {
t.strictEqual(program, 'Z:\\snake.exe')
t.ok(/import platform/.test(args[1]))
t.ok(/import sys/.test(args[1]))
cb(null, '2.3.4')
}
t.strictEqual(program, 'py.exe')
Expand All @@ -266,7 +266,7 @@ test('find python - python 3, use python launcher, python 2 too old',
cb(null, 'Z:\\snake.exe')
}
t.strictEqual(program, 'python')
t.ok(/import platform/.test(args[1]))
t.ok(/import sys/.test(args[1]))
cb(null, '3.0.0')
}
f.checkPython()
Expand All @@ -291,7 +291,7 @@ test('find python - no python, no python launcher, good guess', function (t) {
f.execFile = function(program, args, opts, cb) {
f.execFile = function(program, args, opts, cb) {
t.ok(re.test(program))
t.ok(/import platform/.test(args[1]))
t.ok(/import sys/.test(args[1]))
cb(null, '2.7.0')
}
t.strictEqual(program, 'py.exe')
Expand Down