Skip to content

Commit c1231f2

Browse files
committed
qt-python: Show error popup when pip install fails
1 parent 684031c commit c1231f2

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

qt-python/src/installer.ts

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -182,29 +182,32 @@ async function tryInstallPySide(
182182
runner.onStdout(logIndented);
183183
runner.onStderr(logIndented);
184184

185-
if (source.source === 'oss') {
186-
await runner.run('pip install PySide6', { useVenv: true });
187-
} else if (source.source === 'local' && source.localPath) {
188-
await runner.run('pip install -r requirements.txt', {
189-
useVenv: true,
190-
cwd: source.localPath
191-
});
192-
} else {
193-
return;
194-
}
185+
try {
186+
if (source.source === 'oss') {
187+
await runner.run('pip install PySide6', { useVenv: true });
188+
} else if (source.source === 'local' && source.localPath) {
189+
await runner.run('pip install -r requirements.txt', {
190+
useVenv: true,
191+
cwd: source.localPath
192+
});
193+
} else {
194+
return;
195+
}
195196

196-
await projectManager.refreshEnv(folder);
197+
const pyside = await env.readPySide6PackageInfo(logIndented);
198+
if (!pyside) {
199+
throw new Error('Cannot read PySide6 package information');
200+
}
197201

198-
const pyside = await env.readPySide6PackageInfo(logIndented);
199-
if (pyside) {
202+
await projectManager.refreshEnv(folder);
200203
void vscode.window.showInformationMessage(
201204
texts.install.popup.installed(
202205
folder.name,
203206
pyside.version,
204207
env.venvName ?? ''
205208
)
206209
);
207-
} else {
210+
} catch (e) {
208211
void vscode.window.showWarningMessage(
209212
texts.install.popup.installFailed(folder.name) + ` (${linkShowLogs})`
210213
);

0 commit comments

Comments
 (0)