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

lib: drop Python 2 support in find-python.js #2333

Merged
merged 15 commits into from
Mar 26, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
17 changes: 16 additions & 1 deletion lib/find-python.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,22 @@ PythonFinder.prototype = {
win: win,
pyLauncher: 'py.exe',
winDefaultLocations: [
path.join(process.env.SystemDrive || 'C:', 'Python37', 'python.exe')
path.join(process.env.SystemDrive || 'C:', 'Users', process.env.USERNAME || process.env.USER, 'AppData', 'Local', 'Programs', 'Python', 'Python39', 'python.exe'),
path.join(process.env.SystemDrive || 'C:', 'Program Files', 'Python39', 'python.exe'),
path.join(process.env.SystemDrive || 'C:', 'Users', process.env.USERNAME || process.env.USER, 'AppData', 'Local', 'Programs', 'Python', 'Python39-32', 'python.exe'),
path.join(process.env.SystemDrive || 'C:', 'Program Files (x86)', 'Python39', 'python.exe'),
path.join(process.env.SystemDrive || 'C:', 'Users', process.env.USERNAME || process.env.USER, 'AppData', 'Local', 'Programs', 'Python', 'Python38', 'python.exe'),
path.join(process.env.SystemDrive || 'C:', 'Program Files', 'Python38', 'python.exe'),
path.join(process.env.SystemDrive || 'C:', 'Users', process.env.USERNAME || process.env.USER, 'AppData', 'Local', 'Programs', 'Python', 'Python38-32', 'python.exe'),
path.join(process.env.SystemDrive || 'C:', 'Program Files (x86)', 'Python38', 'python.exe'),
path.join(process.env.SystemDrive || 'C:', 'Users', process.env.USERNAME || process.env.USER, 'AppData', 'Local', 'Programs', 'Python', 'Python37', 'python.exe'),
path.join(process.env.SystemDrive || 'C:', 'Program Files', 'Python37', 'python.exe'),
path.join(process.env.SystemDrive || 'C:', 'Users', process.env.USERNAME || process.env.USER, 'AppData', 'Local', 'Programs', 'Python', 'Python37-32', 'python.exe'),
path.join(process.env.SystemDrive || 'C:', 'Program Files (x86)', 'Python37', 'python.exe'),
path.join(process.env.SystemDrive || 'C:', 'Users', process.env.USERNAME || process.env.USER, 'AppData', 'Local', 'Programs', 'Python', 'Python36', 'python.exe'),
path.join(process.env.SystemDrive || 'C:', 'Program Files', 'Python36', 'python.exe'),
path.join(process.env.SystemDrive || 'C:', 'Users', process.env.USERNAME || process.env.USER, 'AppData', 'Local', 'Programs', 'Python', 'Python36-32', 'python.exe'),
path.join(process.env.SystemDrive || 'C:', 'Program Files (x86)', 'Python36', 'python.exe')
cclauss marked this conversation as resolved.
Show resolved Hide resolved
],

// Logs a message at verbose level, but also saves it to be displayed later
Expand Down
6 changes: 3 additions & 3 deletions test/test-find-python.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,17 +178,17 @@ test('find python - no python, use python launcher', function (t) {
test('find python - no python, no python launcher, good guess', function (t) {
t.plan(2)

var re = /C:[\\/]Python37[\\/]python[.]exe/
var f = new TestPythonFinder(null, done)
f.win = true
const expectedProgram = f.winDefaultLocations[0]

f.execFile = function (program, args, opts, cb) {
if (program === 'py.exe') {
return cb(new Error('not found'))
}
if (/sys\.executable/.test(args[args.length - 1])) {
cb(new Error('not found'))
} else if (re.test(program) &&
} else if (program === expectedProgram &&
/sys\.version_info/.test(args[args.length - 1])) {
cb(null, '3.7.3')
} else {
Expand All @@ -199,7 +199,7 @@ test('find python - no python, no python launcher, good guess', function (t) {

function done (err, python) {
t.strictEqual(err, null)
t.ok(re.test(python))
t.ok(python === expectedProgram)
}
})

Expand Down