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

Check if Python dependencies is installed before setting flag #92

Merged
merged 1 commit into from
Sep 2, 2024
Merged
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
6 changes: 3 additions & 3 deletions src/common/callPythonScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { getInterpreterDetails } from './python';
* @param context - The context object.
* @returns A promise that resolves when the script execution is complete.
*/
export async function callPythonScript(pathToScript: string, scriptArgv: string, context: any): Promise<void> {
return new Promise<void>(async (resolve, reject) => {
export async function callPythonScript(pathToScript: string, scriptArgv: string, context: any): Promise<string> {
return new Promise<string>(async (resolve, reject) => {
const script = context.asAbsolutePath(pathToScript);
const interpreterDetails = await getInterpreterDetails();
const pythonPath = interpreterDetails['path'] && interpreterDetails['path'][0];
Expand All @@ -21,7 +21,7 @@ export async function callPythonScript(pathToScript: string, scriptArgv: string,
reject(error);
} else {
console.log(stdout);
resolve();
resolve(stdout);
}
});
});
Expand Down
11 changes: 7 additions & 4 deletions src/common/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,14 @@ export async function installDependenciesIfNeeded(context: vscode.ExtensionConte
if (!alreadyInstalled) {
const pathToScript = 'bundled/tool/install_dependencies.py';
try {
await callPythonScript(pathToScript, EXTENSION_ROOT_DIR, context);
context.globalState.update('dependenciesInstalled', true);
const stdout = await callPythonScript(pathToScript, EXTENSION_ROOT_DIR, context);

traceLog(`Python dependencies installed!`);
console.log('Python dependencies installed!');
// Check if the script output contains the success message
if (stdout.includes('Successfully installed')) {
context.globalState.update('dependenciesInstalled', true);
traceLog(`Python dependencies installed!`);
console.log('Python dependencies installed!');
}
} catch (error) {
traceError(`Failed to install Python dependencies:: ${error}`);
console.error(`Failed to install Python dependencies:: ${error}`);
Expand Down