Skip to content

Commit f4d353c

Browse files
committed
VS Code extension: bump to 0.3.10, fix CMake/Python invocation
1 parent a1f0293 commit f4d353c

File tree

3 files changed

+25
-14
lines changed

3 files changed

+25
-14
lines changed

tools/vscode-extension/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "psx-dev",
33
"displayName": "PSX.Dev",
44
"description": "PlayStation 1 development made easy",
5-
"version": "0.3.9",
5+
"version": "0.3.10",
66
"engines": {
77
"vscode": "^1.75.0"
88
},

tools/vscode-extension/templates.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const path = require('node:path')
44
const fs = require('fs-extra')
55
const Mustache = require('mustache')
66
const { simpleGit } = require('simple-git')
7+
const tools = require('./tools.js')
78
const terminal = require('./terminal.js')
89
const progressNotification = require('./progressnotification.js')
910

@@ -524,13 +525,17 @@ async function createGitRepository (fullPath, template, progressReporter) {
524525
}
525526

526527
async function createPythonEnv (fullPath, name, packages, requirementsFiles) {
527-
// On Windows "python" and "python3" are aliased to a script that opens the
528-
// Microsoft Store by default, so the "py" launcher is invoked instead.
529-
const pythonCommand = (process.platform === 'win32') ? 'py' : 'python3'
528+
const pythonCommand = await tools.findPython()
529+
const pipCommand = path.join(
530+
fullPath,
531+
name,
532+
(process.platform === 'win32') ? 'Scripts' : 'bin',
533+
'pip'
534+
)
535+
530536
await terminal.run(pythonCommand, ['-m', 'venv', name], {
531537
cwd: fullPath
532538
})
533-
const pipCommand = path.join(fullPath, name, 'bin', 'pip')
534539
if (packages && packages.length) {
535540
await terminal.run(pipCommand, ['install', ...packages], {
536541
cwd: fullPath

tools/vscode-extension/tools.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,20 @@ async function checkInstalled (name) {
2727
return tools[name].installed
2828
}
2929

30-
async function checkCommands (commands, args) {
30+
async function findCommand (commands, args) {
3131
for (const command of commands) {
3232
try {
3333
await execFile(command, args)
3434
} catch (error) {
3535
continue
3636
}
37-
return true
37+
return command
3838
}
39-
return false
39+
return null
40+
}
41+
42+
async function checkCommands (commands, args) {
43+
return (await findCommand(commands, args)) !== null
4044
}
4145

4246
let mipsInstalling = false
@@ -306,7 +310,7 @@ async function installCMake () {
306310
asset.browser_download_url.split('/').pop()
307311
)
308312
await downloader.downloadFile(asset.browser_download_url, filename)
309-
await execFile('start', [filename])
313+
await execFile('msiexec', ['/i', filename])
310314
requiresReboot = true
311315
break
312316
case 'linux':
@@ -457,7 +461,7 @@ async function installPython () {
457461
}
458462
}
459463

460-
async function checkPython () {
464+
async function findPython () {
461465
switch (process.platform) {
462466
case 'win32':
463467
/*
@@ -501,12 +505,12 @@ async function checkPython () {
501505
} catch (error) {
502506
continue
503507
}
504-
return true
508+
return fullPath
505509
}
506510
}
507-
return false
511+
return null
508512
default:
509-
return checkCommands(['python3', 'python'], ['--version'])
513+
return await findCommand(['python3', 'python'], ['--version'])
510514
}
511515
}
512516

@@ -606,7 +610,7 @@ const tools = {
606610
'Python language runtime, required to run some project templates\' scripts',
607611
homepage: 'https://python.org/',
608612
install: installPython,
609-
check: checkPython
613+
check: async () => (await findPython()) !== null
610614
},
611615
clangd: {
612616
type: 'extension',
@@ -702,6 +706,8 @@ exports.setGlobalStorageUri = (uri) => {
702706
globalStorageUri = uri
703707
}
704708

709+
exports.findPython = findPython
710+
705711
exports.install = async (toInstall, force) => {
706712
if (requiresReboot) {
707713
return true

0 commit comments

Comments
 (0)