diff --git a/src/notebooks/controllers/ipywidgets/scriptSourceProvider/nbExtensionsPathProvider.node.ts b/src/notebooks/controllers/ipywidgets/scriptSourceProvider/nbExtensionsPathProvider.node.ts index 986e28515fb..4adffa5f8f8 100644 --- a/src/notebooks/controllers/ipywidgets/scriptSourceProvider/nbExtensionsPathProvider.node.ts +++ b/src/notebooks/controllers/ipywidgets/scriptSourceProvider/nbExtensionsPathProvider.node.ts @@ -25,6 +25,20 @@ export class NbExtensionsPathProvider implements INbExtensionsPathProvider { } return Uri.joinPath(Uri.file(sysPrefix), 'share', 'jupyter'); } + case 'startUsingLocalKernelSpec': { + // If the local kernelspec has an associated Python interpreter, + // use the same logic as startUsingPythonInterpreter + if (kernel.kernelConnectionMetadata.interpreter) { + const sysPrefix = await getSysPrefix(kernel.kernelConnectionMetadata.interpreter); + if (!sysPrefix) { + return; + } + return Uri.joinPath(Uri.file(sysPrefix), 'share', 'jupyter'); + } + // If no interpreter, we haven't come across scenarios with non-python kernels that use widgets + // & have custom widget sources. If we do, we can implement that as we come across them. + return; + } default: { // We haven't come across scenarios with non-python kernels that use widgets // & have custom widget sources. If we do, we can implement that as we come across them. diff --git a/src/notebooks/controllers/ipywidgets/scriptSourceProvider/nbExtensionsPathProvider.unit.test.ts b/src/notebooks/controllers/ipywidgets/scriptSourceProvider/nbExtensionsPathProvider.unit.test.ts index acc8b0f542c..6a8611c3e47 100644 --- a/src/notebooks/controllers/ipywidgets/scriptSourceProvider/nbExtensionsPathProvider.unit.test.ts +++ b/src/notebooks/controllers/ipywidgets/scriptSourceProvider/nbExtensionsPathProvider.unit.test.ts @@ -36,6 +36,13 @@ import { dispose } from '../../../../platform/common/utils/lifecycle'; id: 'interpreterId' } as any }); + const localKernelSpecWithPythonInterpreter = LocalKernelSpecConnectionMetadata.create({ + id: 'localKernelSpecWithPythonInterpreter', + kernelSpec: mock(), + interpreter: { + id: 'interpreterId' + } as any + }); const serverProviderHandle = { handle: 'handle', id: 'id', extensionId: '' }; const remoteKernelSpec = RemoteKernelSpecConnectionMetadata.create({ id: '', @@ -82,6 +89,15 @@ import { dispose } from '../../../../platform/common/utils/lifecycle'; assert.strictEqual(baseUrl?.toString(), Uri.file(path.join(__dirname, 'share', 'jupyter')).toString()); } }); + test('Returns base url for local kernelspec with python interpreter', async () => { + when(kernel.kernelConnectionMetadata).thenReturn(localKernelSpecWithPythonInterpreter); + const baseUrl = await provider.getNbExtensionsParentPath(instance(kernel)); + if (isWeb) { + assert.isUndefined(baseUrl); + } else { + assert.strictEqual(baseUrl?.toString(), Uri.file(path.join(__dirname, 'share', 'jupyter')).toString()); + } + }); test('Returns base url for remote kernelspec', async () => { when(kernel.kernelConnectionMetadata).thenReturn(remoteKernelSpec); const baseUrl = await provider.getNbExtensionsParentPath(instance(kernel));