diff --git a/src/api.unstable.d.ts b/src/api.unstable.d.ts index 96552744dec..1bf89a25d7b 100644 --- a/src/api.unstable.d.ts +++ b/src/api.unstable.d.ts @@ -77,7 +77,6 @@ declare module './api' { displayName?: string; uri: Uri; version?: PythonVersion; - sysPrefix: string; envType?: EnvironmentType; envName?: string; envPath?: Uri; diff --git a/src/kernels/errors/kernelErrorHandler.unit.test.ts b/src/kernels/errors/kernelErrorHandler.unit.test.ts index a7393ea9239..24feb11b99e 100644 --- a/src/kernels/errors/kernelErrorHandler.unit.test.ts +++ b/src/kernels/errors/kernelErrorHandler.unit.test.ts @@ -62,8 +62,7 @@ suite('Error Handler Unit Tests', () => { const jupyterInterpreter: PythonEnvironment = { displayName: 'Hello', uri: Uri.file('Some Path'), - id: Uri.file('Some Path').fsPath, - sysPrefix: '' + id: Uri.file('Some Path').fsPath }; let disposables: IDisposable[] = []; let environments: PythonExtension['environments']; @@ -181,7 +180,6 @@ suite('Error Handler Unit Tests', () => { interpreter: { uri: Uri.file('Hello There'), id: Uri.file('Hello There').fsPath, - sysPrefix: 'Something else', displayName: 'Hello (Some Path)' }, kernelSpec: { diff --git a/src/kernels/execution/helpers.unit.test.ts b/src/kernels/execution/helpers.unit.test.ts index 98d5fd01524..e90efdde1a3 100644 --- a/src/kernels/execution/helpers.unit.test.ts +++ b/src/kernels/execution/helpers.unit.test.ts @@ -20,7 +20,6 @@ suite(`UpdateNotebookMetadata`, () => { const python36Global: PythonEnvironment = { uri: Uri.file('/usr/bin/python36'), id: Uri.file('/usr/bin/python36').fsPath, - sysPrefix: '/usr', displayName: 'Python 3.6', envType: EnvironmentType.Unknown }; @@ -33,7 +32,6 @@ suite(`UpdateNotebookMetadata`, () => { const python37Global: PythonEnvironment = { uri: Uri.file('/usr/bin/python37'), id: Uri.file('/usr/bin/python37').fsPath, - sysPrefix: '/usr', displayName: 'Python 3.7', envType: EnvironmentType.Unknown }; diff --git a/src/kernels/helpers.unit.test.ts b/src/kernels/helpers.unit.test.ts index 1c4cefeda6b..064b7db6b66 100644 --- a/src/kernels/helpers.unit.test.ts +++ b/src/kernels/helpers.unit.test.ts @@ -96,8 +96,7 @@ suite('Kernel Connection Helpers', () => { }, interpreter: { uri: Uri.file('pyPath'), - id: Uri.file('pyPath').fsPath, - sysPrefix: 'sysPrefix' + id: Uri.file('pyPath').fsPath } }) ); @@ -116,7 +115,6 @@ suite('Kernel Connection Helpers', () => { interpreter: { uri: Uri.file('pyPath'), id: Uri.file('pyPath').fsPath, - sysPrefix: 'sysPrefix', envType: EnvironmentType.Unknown } }) @@ -136,7 +134,6 @@ suite('Kernel Connection Helpers', () => { interpreter: { uri: Uri.file('pyPath'), id: Uri.file('pyPath').fsPath, - sysPrefix: 'sysPrefix', envName: '', displayName: 'Something', envType: EnvironmentType.Pipenv @@ -158,7 +155,6 @@ suite('Kernel Connection Helpers', () => { interpreter: { uri: Uri.file('pyPath'), id: Uri.file('pyPath').fsPath, - sysPrefix: 'sysPrefix', envName: '', displayName: 'Something 64-bit', envType: EnvironmentType.Pipenv @@ -180,7 +176,6 @@ suite('Kernel Connection Helpers', () => { interpreter: { uri: Uri.file('pyPath'), id: Uri.file('pyPath').fsPath, - sysPrefix: 'sysPrefix', envName: '.env', displayName: 'Something', envType: EnvironmentType.Conda @@ -202,7 +197,6 @@ suite('Kernel Connection Helpers', () => { interpreter: { uri: Uri.file('pyPath'), id: Uri.file('pyPath').fsPath, - sysPrefix: 'sysPrefix', envName: '.env', displayName: 'Something 64-bit', envType: EnvironmentType.Conda @@ -243,7 +237,6 @@ suite('Kernel Connection Helpers', () => { interpreter: { uri: Uri.file('pyPath'), id: Uri.file('pyPath').fsPath, - sysPrefix: 'sysPrefix', envName: '.env', displayName: 'Something 64-bit' } @@ -265,7 +258,6 @@ suite('Kernel Connection Helpers', () => { interpreter: { uri: Uri.file('pyPath'), id: Uri.file('pyPath').fsPath, - sysPrefix: 'sysPrefix', envName: '.env', displayName: 'Something 64-bit', envType: EnvironmentType.Unknown @@ -288,7 +280,6 @@ suite('Kernel Connection Helpers', () => { interpreter: { uri: Uri.file('pyPath'), id: Uri.file('pyPath').fsPath, - sysPrefix: 'sysPrefix', envName: '', displayName: 'Something', envType: EnvironmentType.Pipenv @@ -311,7 +302,6 @@ suite('Kernel Connection Helpers', () => { interpreter: { uri: Uri.file('pyPath'), id: Uri.file('pyPath').fsPath, - sysPrefix: 'sysPrefix', envName: '', displayName: 'Something 64-bit', envType: EnvironmentType.Pipenv @@ -334,7 +324,6 @@ suite('Kernel Connection Helpers', () => { interpreter: { uri: Uri.file('pyPath'), id: Uri.file('pyPath').fsPath, - sysPrefix: 'sysPrefix', envName: '', displayName: 'Something 64-bit', envType: EnvironmentType.Conda @@ -369,7 +358,6 @@ suite('Kernel Connection Helpers', () => { interpreter: { uri: Uri.file('pyPath'), id: Uri.file('pyPath').fsPath, - sysPrefix: 'sysPrefix', envName: '.env', displayName: 'Something 64-bit', envType: EnvironmentType.Conda @@ -404,7 +392,6 @@ suite('Kernel Connection Helpers', () => { interpreter: { uri: Uri.file('pyPath'), id: Uri.file('pyPath').fsPath, - sysPrefix: 'sysPrefix', envName: '.env', displayName: 'Something 64-bit', envType: EnvironmentType.Conda @@ -429,7 +416,6 @@ suite('Kernel Connection Helpers', () => { interpreter: { uri: Uri.file('pyPath'), id: Uri.file('pyPath').fsPath, - sysPrefix: 'sysPrefix', envName: '', displayName: 'Something 64-bit' } @@ -451,7 +437,6 @@ suite('Kernel Connection Helpers', () => { interpreter: { uri: Uri.file('pyPath'), id: Uri.file('pyPath').fsPath, - sysPrefix: 'sysPrefix', envName: '', displayName: 'Something 64-bit', envType: EnvironmentType.Unknown @@ -486,7 +471,6 @@ suite('Kernel Connection Helpers', () => { interpreter: { uri: Uri.file('pyPath'), id: Uri.file('pyPath').fsPath, - sysPrefix: 'sysPrefix', envName: '', displayName: 'Something 64-bit', envType: EnvironmentType.Unknown @@ -509,7 +493,6 @@ suite('Kernel Connection Helpers', () => { interpreter: { uri: Uri.file('pyPath'), id: Uri.file('pyPath').fsPath, - sysPrefix: 'sysPrefix', envName: '', displayName: 'Something', envType: EnvironmentType.Pipenv @@ -532,7 +515,6 @@ suite('Kernel Connection Helpers', () => { interpreter: { uri: Uri.file('pyPath'), id: Uri.file('pyPath').fsPath, - sysPrefix: 'sysPrefix', envName: '', displayName: 'Something 64-bit', envType: EnvironmentType.Pipenv diff --git a/src/kernels/jupyter/interpreter/jupyterInterpreterDependencyService.unit.test.ts b/src/kernels/jupyter/interpreter/jupyterInterpreterDependencyService.unit.test.ts index 609de10226d..fa0e9c17042 100644 --- a/src/kernels/jupyter/interpreter/jupyterInterpreterDependencyService.unit.test.ts +++ b/src/kernels/jupyter/interpreter/jupyterInterpreterDependencyService.unit.test.ts @@ -24,8 +24,7 @@ suite('Jupyter Interpreter Configuration', () => { let command: IJupyterCommand; const pythonInterpreter: PythonEnvironment = { uri: Uri.file(''), - id: Uri.file('').fsPath, - sysPrefix: '' + id: Uri.file('').fsPath }; let disposables: Disposable[] = []; setup(() => { diff --git a/src/kernels/jupyter/interpreter/jupyterInterpreterService.unit.test.ts b/src/kernels/jupyter/interpreter/jupyterInterpreterService.unit.test.ts index 517367e9e8a..fafbca87f20 100644 --- a/src/kernels/jupyter/interpreter/jupyterInterpreterService.unit.test.ts +++ b/src/kernels/jupyter/interpreter/jupyterInterpreterService.unit.test.ts @@ -32,13 +32,11 @@ suite('Jupyter Interpreter Service', () => { const selectedJupyterInterpreter = createPythonInterpreter({ displayName: 'JupyterInterpreter' }); const pythonInterpreter: PythonEnvironment = { uri: Uri.file('some path'), - id: Uri.file('some path').fsPath, - sysPrefix: '' + id: Uri.file('some path').fsPath }; const secondPythonInterpreter: PythonEnvironment = { uri: Uri.file('second interpreter path'), - id: Uri.file('second interpreter path').fsPath, - sysPrefix: '' + id: Uri.file('second interpreter path').fsPath }; let disposables: IDisposable[] = []; diff --git a/src/kernels/jupyter/launcher/juypterServerProvider.unit.test.ts b/src/kernels/jupyter/launcher/juypterServerProvider.unit.test.ts index 234f4847485..458a8e4d6c2 100644 --- a/src/kernels/jupyter/launcher/juypterServerProvider.unit.test.ts +++ b/src/kernels/jupyter/launcher/juypterServerProvider.unit.test.ts @@ -30,8 +30,7 @@ suite('Jupyter Server Provider', () => { let interpreterService: IInterpreterService; const workingPython: PythonEnvironment = { uri: Uri.file('/foo/bar/python.exe'), - id: Uri.file('/foo/bar/python.exe').fsPath, - sysPrefix: 'Python' + id: Uri.file('/foo/bar/python.exe').fsPath }; let disposables: Disposable[] = []; let source: CancellationTokenSource; diff --git a/src/kernels/jupyter/session/jupyterKernelService.unit.test.ts b/src/kernels/jupyter/session/jupyterKernelService.unit.test.ts index 6bd8c9413d4..ac07b372404 100644 --- a/src/kernels/jupyter/session/jupyterKernelService.unit.test.ts +++ b/src/kernels/jupyter/session/jupyterKernelService.unit.test.ts @@ -67,8 +67,7 @@ suite('JupyterKernelService', () => { interpreter: { id: '/usr/bin/python3', displayName: 'Python 3 Environment', - uri: Uri.file(os.platform() === 'win32' ? '/usr/bin/python3.exe' : '/usr/bin/python3'), - sysPrefix: 'python' + uri: Uri.file(os.platform() === 'win32' ? '/usr/bin/python3.exe' : '/usr/bin/python3') }, id: '0' }), @@ -92,7 +91,6 @@ suite('JupyterKernelService', () => { id: '/usr/bin/conda/python3', displayName: 'Conda Environment', uri: Uri.file(os.platform() === 'win32' ? '/usr/bin/conda/python3.exe' : '/usr/bin/conda/python3'), - sysPrefix: 'conda', envType: EnvironmentType.Conda }, id: '1' @@ -115,7 +113,6 @@ suite('JupyterKernelService', () => { interpreter: { displayName: 'Python 3 Environment', path: os.platform() === 'win32' ? '/usr/bin/python3.exe' : '/usr/bin/python3', - sysPrefix: 'python', version: { major: 3, minor: 8, raw: '3.8', patch: 0 } } } @@ -123,8 +120,7 @@ suite('JupyterKernelService', () => { interpreter: { id: '/usr/bin/python3', displayName: 'Python 3 Environment', - uri: Uri.file(os.platform() === 'win32' ? '/usr/bin/python3.exe' : '/usr/bin/python3'), - sysPrefix: 'python' + uri: Uri.file(os.platform() === 'win32' ? '/usr/bin/python3.exe' : '/usr/bin/python3') }, id: '2' }), @@ -157,8 +153,7 @@ suite('JupyterKernelService', () => { interpreter: { id: '/usr/bin/python', displayName: 'Python 2 Environment', - uri: Uri.file(os.platform() === 'win32' ? '/usr/bin/python.exe' : '/usr/bin/python'), - sysPrefix: 'python' + uri: Uri.file(os.platform() === 'win32' ? '/usr/bin/python.exe' : '/usr/bin/python') }, id: '4' }), @@ -180,7 +175,6 @@ suite('JupyterKernelService', () => { interpreter: { displayName: 'Python 3 Environment', path: os.platform() === 'win32' ? '/usr/bin/python3.exe' : '/usr/bin/python3', - sysPrefix: 'python', version: { major: 3, minor: 8, raw: '3.8', patch: 0 } } } @@ -188,8 +182,7 @@ suite('JupyterKernelService', () => { interpreter: { id: '/usr/bin/python3', displayName: 'Python 3 Environment', - uri: Uri.file(os.platform() === 'win32' ? '/usr/bin/python3.exe' : '/usr/bin/python3'), - sysPrefix: 'python' + uri: Uri.file(os.platform() === 'win32' ? '/usr/bin/python3.exe' : '/usr/bin/python3') }, id: '5' }), @@ -222,8 +215,7 @@ suite('JupyterKernelService', () => { interpreter: { id: '/usr/bin/python', displayName: 'Python 2 Environment', - uri: Uri.file(os.platform() === 'win32' ? '/usr/bin/python.exe' : '/usr/bin/python'), - sysPrefix: 'python' + uri: Uri.file(os.platform() === 'win32' ? '/usr/bin/python.exe' : '/usr/bin/python') }, id: '7' }), @@ -245,7 +237,6 @@ suite('JupyterKernelService', () => { interpreter: { displayName: 'Python 3 Environment', path: os.platform() === 'win32' ? '/usr/bin/python3.exe' : '/usr/bin/python3', - sysPrefix: 'python', version: { major: 3, minor: 8, raw: '3.8', patch: 0 } } } @@ -253,8 +244,7 @@ suite('JupyterKernelService', () => { interpreter: { id: '/usr/bin/python3', displayName: 'Python 3 Environment', - uri: Uri.file(os.platform() === 'win32' ? '/usr/bin/python3.exe' : '/usr/bin/python3'), - sysPrefix: 'python' + uri: Uri.file(os.platform() === 'win32' ? '/usr/bin/python3.exe' : '/usr/bin/python3') }, id: '8' }), @@ -287,8 +277,7 @@ suite('JupyterKernelService', () => { interpreter: { id: '/usr/bin/python', displayName: 'Python 2 Environment', - uri: Uri.file(os.platform() === 'win32' ? '/usr/bin/python.exe' : '/usr/bin/python'), - sysPrefix: 'python' + uri: Uri.file(os.platform() === 'win32' ? '/usr/bin/python.exe' : '/usr/bin/python') }, id: '10' }), @@ -310,7 +299,6 @@ suite('JupyterKernelService', () => { interpreter: { displayName: 'Conda base environment', path: '/usr/conda/envs/base/python', - sysPrefix: 'conda', envType: EnvironmentType.Conda } }, @@ -324,7 +312,6 @@ suite('JupyterKernelService', () => { uri: Uri.file( os.platform() === 'win32' ? '/usr/conda/envs/base/python.exe' : '/usr/conda/envs/base/python' ), - sysPrefix: 'conda', envType: EnvironmentType.Conda }, id: '11' @@ -355,7 +342,6 @@ suite('JupyterKernelService', () => { os.platform() === 'win32' ? '/usr/don/home/envs/sample/bin/python.exe' : '/usr/don/home/envs/sample/bin/python', - sysPrefix: 'python', version: { major: 3, minor: 8, raw: '3.8', patch: 0 } } }, @@ -370,8 +356,7 @@ suite('JupyterKernelService', () => { os.platform() === 'win32' ? '/usr/don/home/envs/sample/bin/python.exe' : '/usr/don/home/envs/sample/bin/python' - ), - sysPrefix: 'python' + ) }, id: '12' }), @@ -393,7 +378,6 @@ suite('JupyterKernelService', () => { os.platform() === 'win32' ? '/usr/don/home/envs/sample/bin/python.exe' : '/usr/don/home/envs/sample/bin/python', - sysPrefix: 'python', version: { major: 3, minor: 8, raw: '3.8', patch: 0 } } }, @@ -408,8 +392,7 @@ suite('JupyterKernelService', () => { os.platform() === 'win32' ? '/usr/don/home/envs/sample/bin/python.exe' : '/usr/don/home/envs/sample/bin/python' - ), - sysPrefix: 'python' + ) }, id: '13' }), @@ -428,7 +411,6 @@ suite('JupyterKernelService', () => { os.platform() === 'win32' ? '/usr/don/home/envs/sample/bin/python.exe' : '/usr/don/home/envs/sample/bin/python', - sysPrefix: 'python', version: { major: 3, minor: 8, raw: '3.8', patch: 0 } } }, @@ -443,8 +425,7 @@ suite('JupyterKernelService', () => { os.platform() === 'win32' ? '/usr/don/home/envs/sample/bin/python.exe' : '/usr/don/home/envs/sample/bin/python' - ), - sysPrefix: 'python' + ) }, id: '14' }) diff --git a/src/kernels/jupyter/session/jupyterKernelSessionFactory.unit.test.ts b/src/kernels/jupyter/session/jupyterKernelSessionFactory.unit.test.ts index a3406175564..2fee56fd98f 100644 --- a/src/kernels/jupyter/session/jupyterKernelSessionFactory.unit.test.ts +++ b/src/kernels/jupyter/session/jupyterKernelSessionFactory.unit.test.ts @@ -112,7 +112,6 @@ suite('New Jupyter Kernel Session Factory', () => { }, interpreter: { id: '1234', - sysPrefix: '', displayName: '' } as any }); diff --git a/src/kernels/kernelDependencyService.unit.test.ts b/src/kernels/kernelDependencyService.unit.test.ts index 9d9afa1280b..5e5c285d440 100644 --- a/src/kernels/kernelDependencyService.unit.test.ts +++ b/src/kernels/kernelDependencyService.unit.test.ts @@ -77,9 +77,6 @@ suite('Kernel Dependency Service', () => { kernelSpec: await createInterpreterKernelSpec(interpreter, Uri.file('')), id: '1' }); - // when(environments.resolveEnvironment(jupyterInterpreter.id)).thenResolve({ - // executable: { sysPrefix: '' } - // } as any); }); teardown(() => (disposables = dispose(disposables))); [undefined, Uri.file('test.py'), Uri.file('test.ipynb')].forEach((resource) => { diff --git a/src/kernels/raw/finder/contributedKerneFinder.node.unit.test.ts b/src/kernels/raw/finder/contributedKerneFinder.node.unit.test.ts index 7fd1d4f70db..c2d03399028 100644 --- a/src/kernels/raw/finder/contributedKerneFinder.node.unit.test.ts +++ b/src/kernels/raw/finder/contributedKerneFinder.node.unit.test.ts @@ -75,9 +75,9 @@ import { setPythonApi } from '../../../platform/interpreter/helpers'; let changeEventFired: TestEventHandler; type TestData = { interpreters?: ( - | PythonEnvironment + | (PythonEnvironment & { sysPrefix: string }) | { - interpreter: PythonEnvironment; + interpreter: PythonEnvironment & { sysPrefix: string }; /** * These are all of the kernelspecs found within the Python environment. * Could be python or non-python kernlespecs. @@ -91,7 +91,7 @@ import { setPythonApi } from '../../../platform/interpreter/helpers'; */ globalKernelSpecs?: KernelSpec.ISpecModel[]; }; - async function initialize(testData: TestData, activeInterpreter?: PythonEnvironment) { + async function initialize(testData: TestData, activeInterpreter?: PythonEnvironment & { sysPrefix: string }) { disposables.push(cancelToken); cancelToken = new CancellationTokenSource(); const getOSTypeStub = sinon.stub(platform, 'getOSType'); @@ -109,7 +109,7 @@ import { setPythonApi } from '../../../platform/interpreter/helpers'; if (activeInterpreter) { testData.interpreters = testData.interpreters || []; } - const distinctInterpreters = new Set(); + const distinctInterpreters = new Set(); (testData.interpreters || []).forEach((item) => 'interpreter' in item ? distinctInterpreters.add(item.interpreter) : distinctInterpreters.add(item) ); @@ -309,28 +309,28 @@ import { setPythonApi } from '../../../platform/interpreter/helpers'; HELLO: 'WORLD' } }; - const python2Global: PythonEnvironment = { + const python2Global: PythonEnvironment & { sysPrefix: string } = { uri: Uri.file(isWindows ? 'C:/Python/Python2/scripts/python.exe' : '/usr/bin/python27'), id: Uri.file(isWindows ? 'C:/Python/Python2/scripts/python.exe' : '/usr/bin/python27').fsPath, sysPrefix: isWindows ? 'C:/Python/Python2' : '/usr', displayName: 'Python 2.7', envType: EnvironmentType.Unknown }; - const python36Global: PythonEnvironment = { + const python36Global: PythonEnvironment & { sysPrefix: string } = { uri: Uri.file(isWindows ? 'C:/Python/Python3.6/scripts/python.exe' : '/usr/bin/python36'), id: Uri.file(isWindows ? 'C:/Python/Python3.6/scripts/python.exe' : '/usr/bin/python36').fsPath, sysPrefix: isWindows ? 'C:/Python/Python3.6' : '/usr', displayName: 'Python 3.6', envType: EnvironmentType.Unknown }; - const python37Global: PythonEnvironment = { + const python37Global: PythonEnvironment & { sysPrefix: string } = { uri: Uri.file(isWindows ? 'C:/Python/Python3.7/scripts/python.exe' : '/usr/bin/python37'), id: Uri.file(isWindows ? 'C:/Python/Python3.7/scripts/python.exe' : '/usr/bin/python37').fsPath, sysPrefix: isWindows ? 'C:/Python/Python3.7' : '/usr', displayName: 'Python 3.7', envType: EnvironmentType.Unknown }; - const python39PyEnv_HelloWorld: PythonEnvironment = { + const python39PyEnv_HelloWorld: PythonEnvironment & { sysPrefix: string } = { uri: Uri.file( isWindows ? 'C:/pyenv/envs/temp/scripts/python.exe' : '/users/username/pyenv/envs/temp/python' ), @@ -341,7 +341,7 @@ import { setPythonApi } from '../../../platform/interpreter/helpers'; envName: 'temp', envType: EnvironmentType.Pyenv }; - const python38VenvEnv: PythonEnvironment = { + const python38VenvEnv: PythonEnvironment & { sysPrefix: string } = { uri: Uri.file( isWindows ? 'C:/temp/venv/.venv/scripts/python.exe' : '/users/username/temp/.venv/bin/python' ), @@ -352,7 +352,7 @@ import { setPythonApi } from '../../../platform/interpreter/helpers'; envName: '.venv', envType: EnvironmentType.VirtualEnv }; - const condaEnv1: PythonEnvironment = { + const condaEnv1: PythonEnvironment & { sysPrefix: string } = { uri: Uri.file(isWindows ? 'C:/conda/envs/env1/scripts/python.exe' : '/conda/envs/env1/bin/python'), id: Uri.file(isWindows ? 'C:/conda/envs/env1/scripts/python.exe' : '/conda/envs/env1/bin/python').fsPath, sysPrefix: isWindows ? 'C:/conda/envs/env1' : '/conda/envs/env1', @@ -455,10 +455,10 @@ import { setPythonApi } from '../../../platform/interpreter/helpers'; async function generateExpectedKernels( expectedGlobalKernelSpecs: KernelSpec.ISpecModel[], expectedInterpreterKernelSpecFiles: { - interpreter: PythonEnvironment; + interpreter: PythonEnvironment & { sysPrefix: string }; kernelspec: KernelSpec.ISpecModel; }[], - expectedInterpreters: PythonEnvironment[] + expectedInterpreters: (PythonEnvironment & { sysPrefix: string })[] ) { const duplicates = new Set(); expectedInterpreters = expectedInterpreters.filter((item) => { @@ -544,13 +544,13 @@ import { setPythonApi } from '../../../platform/interpreter/helpers'; * Expected list of kernlespecs that are associated with a Python interpreter. */ expectedInterpreterKernelSpecFiles?: { - interpreter: PythonEnvironment; + interpreter: PythonEnvironment & { sysPrefix: string }; kernelspec: KernelSpec.ISpecModel; }[]; /** * Expected list of kernlespecs used to start Python environments. */ - expectedInterpreters?: PythonEnvironment[]; + expectedInterpreters?: (PythonEnvironment & { sysPrefix: string })[]; }; function cloneWithAppropriateCase(obj: any) { diff --git a/src/kernels/raw/finder/interpreterKernelSpecFinderHelper.node.unit.test.ts b/src/kernels/raw/finder/interpreterKernelSpecFinderHelper.node.unit.test.ts index dfbb02b83b7..3f7f8f9a331 100644 --- a/src/kernels/raw/finder/interpreterKernelSpecFinderHelper.node.unit.test.ts +++ b/src/kernels/raw/finder/interpreterKernelSpecFinderHelper.node.unit.test.ts @@ -29,13 +29,13 @@ suite('Interpreter Kernel Spec Finder Helper', () => { let interpreterService: IInterpreterService; let extensionChecker: IPythonExtensionChecker; let trustedKernels: ITrustedKernelPaths; - let venvInterpreter: PythonEnvironment; - const condaInterpreter: PythonEnvironment = { + let venvInterpreter: PythonEnvironment & { sysPrefix: string }; + const condaInterpreter: PythonEnvironment & { sysPrefix: string } = { id: 'conda', sysPrefix: 'home/conda', uri: Uri.file('conda') }; - const globalInterpreter: PythonEnvironment = { + const globalInterpreter: PythonEnvironment & { sysPrefix: string } = { id: 'globalInterpreter', sysPrefix: 'home/global', uri: Uri.joinPath(Uri.file('globalSys'), 'bin', 'python') diff --git a/src/kernels/raw/finder/jupyterPaths.node.ts b/src/kernels/raw/finder/jupyterPaths.node.ts index 7b9e5a7679a..8270e7e3103 100644 --- a/src/kernels/raw/finder/jupyterPaths.node.ts +++ b/src/kernels/raw/finder/jupyterPaths.node.ts @@ -207,15 +207,11 @@ export class JupyterPaths { } // 3. Add the paths based on user and env data directories - if (interpreter && !interpreter.sysPrefix) { - traceWarning(`sysPrefix was not set for ${interpreter.id}`); - const sysPrefix = await getSysPrefix(interpreter); - interpreter.sysPrefix = sysPrefix || interpreter.sysPrefix; - traceInfoIfCI(`sysPrefix after getting details ${interpreter.sysPrefix}`); + let sysPrefix: string | undefined; + if (interpreter) { + sysPrefix = await getSysPrefix(interpreter); } - const possibleEnvJupyterPath = interpreter?.sysPrefix - ? Uri.joinPath(Uri.file(interpreter.sysPrefix), 'share', 'jupyter') - : undefined; + const possibleEnvJupyterPath = sysPrefix ? Uri.joinPath(Uri.file(sysPrefix), 'share', 'jupyter') : undefined; const systemDataDirectories = this.getSystemJupyterPaths(); const envJupyterPath = possibleEnvJupyterPath diff --git a/src/kernels/raw/finder/jupyterPaths.node.unit.test.ts b/src/kernels/raw/finder/jupyterPaths.node.unit.test.ts index c7bc086a8db..ec27c653039 100644 --- a/src/kernels/raw/finder/jupyterPaths.node.unit.test.ts +++ b/src/kernels/raw/finder/jupyterPaths.node.unit.test.ts @@ -4,6 +4,7 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable local-rules/dont-use-process */ +import * as sinon from 'sinon'; import { assert } from 'chai'; import { anything, deepEqual, instance, mock, when } from 'ts-mockito'; import { CancellationTokenSource, ExtensionContext, Memento, Uri } from 'vscode'; @@ -18,8 +19,10 @@ import { IPythonExecutionService, IPythonExecutionFactory } from '../../../platf import { PythonEnvironment } from '../../../platform/pythonEnvironments/info'; import * as path from '../../../platform/vscode-path/path'; import { EXTENSION_ROOT_DIR_FOR_TESTS } from '../../../test/constants.node'; -import { uriEquals } from '../../../test/datascience/helpers'; +import { resolvableInstance, uriEquals } from '../../../test/datascience/helpers'; import { IInterpreterService } from '../../../platform/interpreter/contracts'; +import { PythonExtension } from '@vscode/python-extension'; +import { setPythonApi } from '../../../platform/interpreter/helpers'; suite('Jupyter Paths', () => { let disposables: IDisposable[] = []; @@ -38,8 +41,8 @@ suite('Jupyter Paths', () => { const oldALLUSERSPROFILE = process.env['ALLUSERSPROFILE']; const windowsHomeDir = Uri.file('C:/users/username'); const extensionUri = Uri.file('extension'); + const sysPrefix = `PythonEnv${path.sep}PythonSysPrefix`; const interpreter: PythonEnvironment = { - sysPrefix: `PythonEnv${path.sep}PythonSysPrefix`, uri: Uri.file('PythonEnv'), id: Uri.file('PythonEnv').fsPath }; @@ -82,6 +85,18 @@ suite('Jupyter Paths', () => { delete process.env['JUPYTER_CONFIG_DIR']; delete process.env['JUPYTER_DATA_DIR']; delete process.env['ALLUSERSPROFILE']; + + const mockedApi = mock(); + sinon.stub(PythonExtension, 'api').resolves(resolvableInstance(mockedApi)); + disposables.push({ dispose: () => sinon.restore() }); + const environments = mock(); + when(mockedApi.environments).thenReturn(instance(environments)); + when(environments.known).thenReturn([]); + setPythonApi(instance(mockedApi)); + disposables.push({ dispose: () => setPythonApi(undefined as any) }); + when(environments.resolveEnvironment(interpreter.id)).thenResolve({ + executable: { sysPrefix } + } as any); }); teardown(async () => { disposables = dispose(disposables); @@ -186,10 +201,7 @@ suite('Jupyter Paths', () => { assert.strictEqual(dataDirs[1].toString(), Uri.file(jupyter_Paths[1]).toString()); assert.strictEqual(dataDirs[2].toString(), Uri.file(jupyter_Paths[2]).toString()); assert.strictEqual(dataDirs[3].toString(), Uri.file(jupyterDataDir).toString()); - assert.strictEqual( - dataDirs[4].toString(), - Uri.joinPath(Uri.file(interpreter.sysPrefix!), 'share', 'jupyter').toString() - ); + assert.strictEqual(dataDirs[4].toString(), Uri.joinPath(Uri.file(sysPrefix), 'share', 'jupyter').toString()); }); test('Get datadir for python kernel on Windows with Python DataDir, JUPYTER_CONFIG_DIR, PROGRAMDATA, JUPYTER_DATA_DIR & JUPYTER_PATH', async () => { @@ -214,10 +226,7 @@ suite('Jupyter Paths', () => { assert.strictEqual(dataDirs[2].toString(), Uri.file(jupyter_Paths[2]).toString()); assert.strictEqual(dataDirs[3].toString(), Uri.file('JupyterDataDirFromPython').toString()); assert.strictEqual(dataDirs[4].toString(), Uri.file(jupyterDataDir).toString()); - assert.strictEqual( - dataDirs[5].toString(), - Uri.joinPath(Uri.file(interpreter.sysPrefix!), 'share', 'jupyter').toString() - ); + assert.strictEqual(dataDirs[5].toString(), Uri.joinPath(Uri.file(sysPrefix), 'share', 'jupyter').toString()); }); test('Get datadir for non-python kernel on Unix', async () => { @@ -278,10 +287,7 @@ suite('Jupyter Paths', () => { assert.strictEqual(dataDirs.length, 2); assert.strictEqual(dataDirs[0].toString(), Uri.file(jupyterDataDir).toString()); - assert.strictEqual( - dataDirs[1].toString(), - Uri.joinPath(Uri.file(interpreter.sysPrefix!), 'share', 'jupyter').toString() - ); + assert.strictEqual(dataDirs[1].toString(), Uri.joinPath(Uri.file(sysPrefix), 'share', 'jupyter').toString()); }); test('Get datadir for python kernel on mac with Python DataDir, JUPYTER_CONFIG_DIR, PROGRAMDATA, JUPYTER_DATA_DIR & JUPYTER_PATH', async () => { when(platformService.homeDir).thenReturn(macHomeDir); @@ -305,10 +311,7 @@ suite('Jupyter Paths', () => { assert.strictEqual(dataDirs[2].toString(), Uri.file(jupyter_Paths[2]).toString()); assert.strictEqual(dataDirs[3].toString(), Uri.file('JupyterDataDirFromPython').toString()); assert.strictEqual(dataDirs[4].toString(), Uri.file(jupyterDataDir).toString()); - assert.strictEqual( - dataDirs[5].toString(), - Uri.joinPath(Uri.file(interpreter.sysPrefix!), 'share', 'jupyter').toString() - ); + assert.strictEqual(dataDirs[5].toString(), Uri.joinPath(Uri.file(sysPrefix), 'share', 'jupyter').toString()); }); test('Get kernelspec root paths on Windows', async () => { diff --git a/src/kernels/raw/finder/localPythonAndRelatedNonPythonKernelSpecFinder.node.unit.test.ts b/src/kernels/raw/finder/localPythonAndRelatedNonPythonKernelSpecFinder.node.unit.test.ts index 640f4d87440..9790a9d3918 100644 --- a/src/kernels/raw/finder/localPythonAndRelatedNonPythonKernelSpecFinder.node.unit.test.ts +++ b/src/kernels/raw/finder/localPythonAndRelatedNonPythonKernelSpecFinder.node.unit.test.ts @@ -56,7 +56,6 @@ suite(`Local Python and related kernels`, async () => { id: 'python', interpreter: { id: 'python', - sysPrefix: 'home/python', uri: Uri.file('python') }, kernelSpec: { @@ -68,12 +67,10 @@ suite(`Local Python and related kernels`, async () => { }); const condaInterpreter: PythonEnvironment = { id: 'conda', - sysPrefix: 'home/conda', uri: Uri.file('conda') }; const globalInterpreter: PythonEnvironment = { id: 'globalInterpreter', - sysPrefix: 'home/global', uri: Uri.joinPath(Uri.file('globalSys'), 'bin', 'python') }; let condaKernel: PythonKernelConnectionMetadata; @@ -129,7 +126,6 @@ suite(`Local Python and related kernels`, async () => { }); const venvInterpreter: PythonEnvironment = { id: 'venvPython', - sysPrefix: 'home/venvPython', uri: Uri.file('home/venvPython/bin/python') }; const cachedVenvInterpreterWithOlderVersionOfPython = { @@ -599,10 +595,9 @@ suite(`Local Python and related kernels`, async () => { when(kernelSpecsFromKnownLocations.kernels).thenReturn([]); when(interpreterService.resolvedEnvironments).thenReturn([condaInterpreter]); // Conda kernel should have a java kernelspec. - findKernelSpecsInPathsReturnValue.set( - Uri.joinPath(Uri.file(condaKernel.interpreter.sysPrefix!), baseKernelPath), - [Uri.file(javaKernelSpec.kernelSpec.specFile!)] - ); + findKernelSpecsInPathsReturnValue.set(Uri.joinPath(Uri.file('home/conda'), baseKernelPath), [ + Uri.file(javaKernelSpec.kernelSpec.specFile!) + ]); // Java Kernel spec should load and return the kernelspec json. loadKernelSpecReturnValue.set(Uri.file(javaKernelSpec.kernelSpec.specFile!), javaKernelSpec.kernelSpec); const onDidChange = createEventHandler(finder, 'onDidChangeKernels', disposables); diff --git a/src/kernels/raw/launcher/kernelEnvVarsService.unit.test.ts b/src/kernels/raw/launcher/kernelEnvVarsService.unit.test.ts index 171e97cb429..3a8ab13b0ab 100644 --- a/src/kernels/raw/launcher/kernelEnvVarsService.unit.test.ts +++ b/src/kernels/raw/launcher/kernelEnvVarsService.unit.test.ts @@ -33,8 +33,7 @@ suite('Kernel Environment Variables Service', () => { const interpreter: PythonEnvironment = { envType: EnvironmentType.Conda, uri: pathFile, - id: pathFile.fsPath, - sysPrefix: '0' + id: pathFile.fsPath }; let kernelSpec: IJupyterKernelSpec; let processEnv: NodeJS.ProcessEnv; @@ -173,8 +172,7 @@ suite('Kernel Environment Variables Service', () => { when(interpreterService.getInterpreterDetails(anything(), anything())).thenResolve({ envType: EnvironmentType.Conda, uri: Uri.joinPath(Uri.file('env'), 'foopath'), - id: Uri.joinPath(Uri.file('env'), 'foopath').fsPath, - sysPrefix: 'foosysprefix' + id: Uri.joinPath(Uri.file('env'), 'foopath').fsPath }); when(envActivation.getActivatedEnvironmentVariables(anything(), anything(), anything())).thenResolve({ PATH: 'pathInInterpreterEnv' @@ -193,8 +191,7 @@ suite('Kernel Environment Variables Service', () => { when(interpreterService.getInterpreterDetails(anything(), anything())).thenResolve({ envType: EnvironmentType.Conda, uri: Uri.joinPath(Uri.file('env'), 'foopath'), - id: Uri.joinPath(Uri.file('env'), 'foopath').fsPath, - sysPrefix: 'foosysprefix' + id: Uri.joinPath(Uri.file('env'), 'foopath').fsPath }); when(envActivation.getActivatedEnvironmentVariables(anything(), anything(), anything())).thenResolve({ PATH: 'pathInInterpreterEnv' @@ -215,8 +212,7 @@ suite('Kernel Environment Variables Service', () => { when(interpreterService.getInterpreterDetails(anything(), anything())).thenResolve({ envType: EnvironmentType.Conda, uri: Uri.joinPath(Uri.file('env'), 'foopath'), - id: Uri.joinPath(Uri.file('env'), 'foopath').fsPath, - sysPrefix: 'foosysprefix' + id: Uri.joinPath(Uri.file('env'), 'foopath').fsPath }); when(envActivation.getActivatedEnvironmentVariables(anything(), anything(), anything())).thenResolve({ PATH: 'pathInInterpreterEnv' @@ -242,8 +238,7 @@ suite('Kernel Environment Variables Service', () => { when(interpreterService.getInterpreterDetails(anything(), anything())).thenResolve({ envType, uri: Uri.file('foopath'), - id: Uri.file('foopath').fsPath, - sysPrefix: 'foosysprefix' + id: Uri.file('foopath').fsPath }); when(envActivation.getActivatedEnvironmentVariables(anything(), anything(), anything())).thenResolve({ PATH: 'foobar' diff --git a/src/kernels/raw/launcher/kernelLauncher.unit.test.ts b/src/kernels/raw/launcher/kernelLauncher.unit.test.ts index 604ea7bbde5..a0e53607565 100644 --- a/src/kernels/raw/launcher/kernelLauncher.unit.test.ts +++ b/src/kernels/raw/launcher/kernelLauncher.unit.test.ts @@ -73,7 +73,6 @@ suite('kernel Launcher', () => { id: '1', interpreter: { id: '2', - sysPrefix: '', uri: Uri.file('python') }, kernelSpec: { diff --git a/src/kernels/types.ts b/src/kernels/types.ts index 11f0275d31d..650e50b4797 100644 --- a/src/kernels/types.ts +++ b/src/kernels/types.ts @@ -33,7 +33,6 @@ import { } from '../platform/common/constants'; import { sendTelemetryEvent } from '../telemetry'; import { generateIdFromRemoteProvider } from './jupyter/jupyterUtils'; -import { traceInfoIfCI } from '../platform/logging'; export type WebSocketData = string | Buffer | ArrayBuffer | Buffer[]; @@ -287,13 +286,6 @@ export class PythonKernelConnectionMetadata { }; } public updateInterpreter(interpreter: PythonEnvironment) { - if (!interpreter.sysPrefix) { - traceInfoIfCI( - `WARNING: Interpreter ${interpreter.id} has no sysPrefix and existing item ${ - this.interpreter.sysPrefix - } will be blown away, ${new Error().stack}` - ); - } Object.assign(this.interpreter, interpreter); } public static fromJSON(options: Record | PythonKernelConnectionMetadata) { diff --git a/src/kernels/variables/preWarmVariables.unit.test.ts b/src/kernels/variables/preWarmVariables.unit.test.ts index 38b162e44ed..c2977870c21 100644 --- a/src/kernels/variables/preWarmVariables.unit.test.ts +++ b/src/kernels/variables/preWarmVariables.unit.test.ts @@ -26,8 +26,7 @@ suite('PreWarm Env Vars', () => { setup(() => { interpreter = { uri: Uri.file(''), - id: Uri.file('').fsPath, - sysPrefix: '' + id: Uri.file('').fsPath }; onDidChangeInterpreter = new EventEmitter(); envActivationService = mock(); diff --git a/src/notebooks/controllers/controllerRegistration.unit.test.ts b/src/notebooks/controllers/controllerRegistration.unit.test.ts index bfc0888cc66..84f1a93a66a 100644 --- a/src/notebooks/controllers/controllerRegistration.unit.test.ts +++ b/src/notebooks/controllers/controllerRegistration.unit.test.ts @@ -32,7 +32,6 @@ import { mockedVSCodeNamespaces } from '../../test/vscode-mock'; suite('Controller Registration', () => { const activePythonEnv: PythonEnvironment = { id: 'activePythonEnv', - sysPrefix: '', uri: Uri.file('activePythonEnv') }; const activePythonConnection = PythonKernelConnectionMetadata.create({ @@ -47,7 +46,6 @@ suite('Controller Registration', () => { }); const condaPython: PythonEnvironment = { id: 'condaPython', - sysPrefix: '', uri: Uri.file('condaPython'), envType: EnvironmentType.Conda }; diff --git a/src/notebooks/controllers/ipywidgets/scriptSourceProvider/nbExtensionsPathProvider.unit.test.ts b/src/notebooks/controllers/ipywidgets/scriptSourceProvider/nbExtensionsPathProvider.unit.test.ts index 337c9d30728..acc8b0f542c 100644 --- a/src/notebooks/controllers/ipywidgets/scriptSourceProvider/nbExtensionsPathProvider.unit.test.ts +++ b/src/notebooks/controllers/ipywidgets/scriptSourceProvider/nbExtensionsPathProvider.unit.test.ts @@ -33,8 +33,7 @@ import { dispose } from '../../../../platform/common/utils/lifecycle'; id: 'localPythonKernelSpec', kernelSpec: mock(), interpreter: { - id: 'interpreterId', - sysPrefix: __dirname + id: 'interpreterId' } as any }); const serverProviderHandle = { handle: 'handle', id: 'id', extensionId: '' }; diff --git a/src/notebooks/controllers/kernelConnector.unit.test.ts b/src/notebooks/controllers/kernelConnector.unit.test.ts index 43ce0db6bd8..10c20aa7cff 100644 --- a/src/notebooks/controllers/kernelConnector.unit.test.ts +++ b/src/notebooks/controllers/kernelConnector.unit.test.ts @@ -35,7 +35,6 @@ suite('Kernel Connector', () => { id: 'python', interpreter: { id: 'id', - sysPrefix: '', uri: Uri.file('python') }, kernelSpec: { @@ -59,7 +58,6 @@ suite('Kernel Connector', () => { id: 'python', interpreter: { id: 'id', - sysPrefix: '', uri: Uri.file('python') }, kernelSpec: { diff --git a/src/notebooks/controllers/pythonEnvKernelConnectionCreator.unit.test.ts b/src/notebooks/controllers/pythonEnvKernelConnectionCreator.unit.test.ts index 9d14fb95f50..89efe4a29cc 100644 --- a/src/notebooks/controllers/pythonEnvKernelConnectionCreator.unit.test.ts +++ b/src/notebooks/controllers/pythonEnvKernelConnectionCreator.unit.test.ts @@ -52,7 +52,6 @@ suite('Python Environment Kernel Connection Creator', () => { }, interpreter: { id: 'venv', - sysPrefix: '', uri: Uri.file('venv') } }); @@ -67,7 +66,6 @@ suite('Python Environment Kernel Connection Creator', () => { }, interpreter: { id: 'conda', - sysPrefix: '', uri: Uri.file('.conda/bin/python'), envType: EnvironmentType.Conda } diff --git a/src/platform/api/pythonApi.ts b/src/platform/api/pythonApi.ts index 54852e52fea..c492164db6a 100644 --- a/src/platform/api/pythonApi.ts +++ b/src/platform/api/pythonApi.ts @@ -50,7 +50,6 @@ export function deserializePythonEnvironment( if (pythonVersion) { const result = { ...pythonVersion, - sysPrefix: pythonVersion.sysPrefix || '', uri: Uri.file(pythonVersion.path || ''), id: pythonEnvId || (pythonVersion as any).id, envPath: pythonVersion.envPath ? Uri.file(pythonVersion.envPath) : undefined, @@ -100,13 +99,9 @@ export function resolvedPythonEnvToJupyterEnv( let isCondaEnvWithoutPython = false; let uri: Uri; let id = env.id; - let sysPrefix = env.executable.sysPrefix; if (!env.executable.uri) { if (envType === EnvironmentType.Conda && supportsEmptyCondaEnv) { isCondaEnvWithoutPython = true; - // sysprefix is the same as the env path. - // eslint-disable-next-line local-rules/dont-use-fspath - sysPrefix = sysPrefix || env.environment?.folderUri?.fsPath || ''; uri = getOSType() === OSType.Windows ? Uri.joinPath(env.environment?.folderUri || Uri.file(env.path), 'python.exe') @@ -121,7 +116,6 @@ export function resolvedPythonEnvToJupyterEnv( return { id, - sysPrefix: sysPrefix || '', envPath: env.environment?.folderUri, displayPath: env.environment?.folderUri || Uri.file(env.path), envName: env.environment?.name || '', @@ -136,13 +130,9 @@ export function pythonEnvToJupyterEnv(env: Environment, supportsEmptyCondaEnv: b let isCondaEnvWithoutPython = false; let uri: Uri; let id = env.id; - let sysPrefix = env.executable.sysPrefix; if (!env.executable.uri) { if (envType === EnvironmentType.Conda && supportsEmptyCondaEnv) { isCondaEnvWithoutPython = true; - // sysprefix is the same as the env path. - // eslint-disable-next-line local-rules/dont-use-fspath - sysPrefix = sysPrefix || env.environment?.folderUri?.fsPath || ''; uri = getOSType() === OSType.Windows ? Uri.joinPath(env.environment?.folderUri || Uri.file(env.path), 'python.exe') @@ -157,7 +147,6 @@ export function pythonEnvToJupyterEnv(env: Environment, supportsEmptyCondaEnv: b return { id, - sysPrefix: sysPrefix || '', envPath: env.environment?.folderUri, displayPath: env.environment?.folderUri || Uri.file(env.path), envName: env.environment?.name || '', diff --git a/src/platform/api/types.ts b/src/platform/api/types.ts index d34593961c9..e0c06205964 100644 --- a/src/platform/api/types.ts +++ b/src/platform/api/types.ts @@ -53,7 +53,6 @@ export type InterpreterInformation_PythonApi = { path: string; version?: PythonVersion; sysVersion?: string; - sysPrefix: string; }; export type PythonEnvironment_PythonApi = InterpreterInformation_PythonApi & { diff --git a/src/platform/interpreter/environmentActivationService.node.ts b/src/platform/interpreter/environmentActivationService.node.ts index ff7a982882d..797c0935e09 100644 --- a/src/platform/interpreter/environmentActivationService.node.ts +++ b/src/platform/interpreter/environmentActivationService.node.ts @@ -23,7 +23,7 @@ import { GlobalPythonExecutablePathService } from './globalPythonExePathService. import { noop } from '../common/utils/misc'; import { CancellationToken, workspace } from 'vscode'; import { raceCancellation } from '../common/cancellation'; -import { getEnvironmentType, getPythonEnvDisplayName, isCondaEnvironmentWithoutPython } from './helpers'; +import { getEnvironmentType, getPythonEnvDisplayName, getSysPrefix, isCondaEnvironmentWithoutPython } from './helpers'; import { Environment } from '@vscode/python-extension'; const ENV_VAR_CACHE_TIMEOUT = 60_000; @@ -230,9 +230,7 @@ export class EnvironmentActivationService implements IEnvironmentActivationServi // Patch for conda envs. if (getEnvironmentType(environment) === EnvironmentType.Conda) { - const sysPrefix = - this.interpreterService.known.find((e) => e.id === environment.id)?.executable.sysPrefix || - (await this.interpreterService.resolveEnvironment(environment))?.executable.sysPrefix; + const sysPrefix = await getSysPrefix(environment); if (sysPrefix) { env.CONDA_PREFIX = sysPrefix; } else { diff --git a/src/platform/interpreter/installer/channelManager.channels.unit.test.ts b/src/platform/interpreter/installer/channelManager.channels.unit.test.ts index 7e256bbc64c..fe8ac31e3ae 100644 --- a/src/platform/interpreter/installer/channelManager.channels.unit.test.ts +++ b/src/platform/interpreter/installer/channelManager.channels.unit.test.ts @@ -18,8 +18,7 @@ suite('Installation - installation channels', () => { const interpreter: PythonEnvironment = { envType: EnvironmentType.Conda, uri: Uri.file('foobar'), - id: Uri.file('foobar').fsPath, - sysPrefix: '0' + id: Uri.file('foobar').fsPath }; setup(() => { diff --git a/src/platform/interpreter/installer/channelManager.messages.unit.test.ts b/src/platform/interpreter/installer/channelManager.messages.unit.test.ts index b695630904f..5a33644b689 100644 --- a/src/platform/interpreter/installer/channelManager.messages.unit.test.ts +++ b/src/platform/interpreter/installer/channelManager.messages.unit.test.ts @@ -18,8 +18,7 @@ const info: PythonEnvironment = { envName: '', uri: Uri.file(''), id: Uri.file('').fsPath, - envType: EnvironmentType.Unknown, - sysPrefix: '' + envType: EnvironmentType.Unknown }; suite('Installation - channel messages', () => { diff --git a/src/platform/interpreter/installer/condaInstaller.unit.test.ts b/src/platform/interpreter/installer/condaInstaller.unit.test.ts index 1e31a708cc3..e681f1125b8 100644 --- a/src/platform/interpreter/installer/condaInstaller.unit.test.ts +++ b/src/platform/interpreter/installer/condaInstaller.unit.test.ts @@ -47,8 +47,7 @@ suite('Common - Conda Installer', () => { const interpreter: PythonEnvironment = { envType: EnvironmentType.Conda, uri: Uri.file('foobar'), - id: Uri.file('foobar').fsPath, - sysPrefix: '0' + id: Uri.file('foobar').fsPath }; installer._isCondaAvailable = false; @@ -61,8 +60,7 @@ suite('Common - Conda Installer', () => { const interpreter: PythonEnvironment = { envType: EnvironmentType.Conda, uri: Uri.file('foobar'), - id: Uri.file('foobar').fsPath, - sysPrefix: '0' + id: Uri.file('foobar').fsPath }; when(condaService.isCondaAvailable()).thenResolve(false); @@ -74,8 +72,7 @@ suite('Common - Conda Installer', () => { const interpreter: PythonEnvironment = { envType: EnvironmentType.Unknown, uri: Uri.file('foobar'), - id: Uri.file('foobar').fsPath, - sysPrefix: '0' + id: Uri.file('foobar').fsPath }; const settings = mock(JupyterSettings); @@ -90,8 +87,7 @@ suite('Common - Conda Installer', () => { const interpreter: PythonEnvironment = { envType: EnvironmentType.Conda, uri: Uri.file('foobar'), - id: Uri.file('foobar').fsPath, - sysPrefix: '0' + id: Uri.file('foobar').fsPath }; const settings = mock(JupyterSettings); @@ -107,7 +103,6 @@ suite('Common - Conda Installer', () => { envType: EnvironmentType.Conda, uri: Uri.file('foobar'), id: Uri.file('foobar').fsPath, - sysPrefix: '0', envName: 'baz' }; const settings = mock(JupyterSettings); @@ -128,7 +123,6 @@ suite('Common - Conda Installer', () => { envType: EnvironmentType.Conda, uri: Uri.file('foobar'), id: Uri.file('foobar').fsPath, - sysPrefix: '0', envName: 'baz' }; const settings = mock(JupyterSettings); @@ -148,8 +142,7 @@ suite('Common - Conda Installer', () => { const interpreter: PythonEnvironment = { envType: EnvironmentType.Conda, uri: Uri.file('baz/foobar/python.exe'), - id: Uri.file('baz/foobar/python.exe').fsPath, - sysPrefix: '0' + id: Uri.file('baz/foobar/python.exe').fsPath }; const condaPath = Uri.file('some Conda Path'); @@ -168,8 +161,7 @@ suite('Common - Conda Installer', () => { const interpreter: PythonEnvironment = { envType: EnvironmentType.Conda, uri: Uri.file('baz/foobar/bin/python.exe'), - id: Uri.file('baz/foobar/bin/python.exe').fsPath, - sysPrefix: '0' + id: Uri.file('baz/foobar/bin/python.exe').fsPath }; const condaPath = Uri.file('some Conda Path'); diff --git a/src/platform/interpreter/installer/pipInstaller.unit.test.ts b/src/platform/interpreter/installer/pipInstaller.unit.test.ts index 6fec8a7ec72..77686ad187c 100644 --- a/src/platform/interpreter/installer/pipInstaller.unit.test.ts +++ b/src/platform/interpreter/installer/pipInstaller.unit.test.ts @@ -84,8 +84,7 @@ suite('Pip installer', async () => { const interpreter: PythonEnvironment = { envType: EnvironmentType.Unknown, uri: Uri.file('foobar'), - id: Uri.file('foobar').fsPath, - sysPrefix: '0' + id: Uri.file('foobar').fsPath }; when(pythonExecutionService.isModuleInstalled('pip')).thenResolve(true); @@ -98,8 +97,7 @@ suite('Pip installer', async () => { const interpreter: PythonEnvironment = { envType: EnvironmentType.Unknown, uri: Uri.file('foobar'), - id: Uri.file('foobar').fsPath, - sysPrefix: '0' + id: Uri.file('foobar').fsPath }; when(pythonExecutionService.isModuleInstalled('pip')).thenResolve(false); @@ -113,8 +111,7 @@ suite('Pip installer', async () => { const interpreter: PythonEnvironment = { envType: EnvironmentType.Unknown, uri: Uri.file('foobar'), - id: Uri.file('foobar').fsPath, - sysPrefix: '0' + id: Uri.file('foobar').fsPath }; when(pythonExecutionService.isModuleInstalled('pip')).thenReject( new Error('Unable to check if module is installed') @@ -131,8 +128,7 @@ suite('Pip installer', async () => { const interpreter: PythonEnvironment = { envType, uri: Uri.file('foobar'), - id: Uri.file('foobar').fsPath, - sysPrefix: '0' + id: Uri.file('foobar').fsPath }; when(pythonExecutionService.isModuleInstalled('pip')).thenReject( new Error('Unable to check if module is installed') diff --git a/src/platform/interpreter/installer/poetryInstaller.unit.test.ts b/src/platform/interpreter/installer/poetryInstaller.unit.test.ts index b1761f42caf..b46602f16d7 100644 --- a/src/platform/interpreter/installer/poetryInstaller.unit.test.ts +++ b/src/platform/interpreter/installer/poetryInstaller.unit.test.ts @@ -87,8 +87,7 @@ suite('Module Installer - Poetry', () => { const interpreter: PythonEnvironment = { envType: EnvironmentType.Poetry, uri: Uri.file('foobar'), - id: Uri.file('foobar').fsPath, - sysPrefix: '0' + id: Uri.file('foobar').fsPath }; when(mockedVSCodeNamespaces.workspace.getWorkspaceFolder(anything())).thenReturn(); @@ -101,8 +100,7 @@ suite('Module Installer - Poetry', () => { const interpreter: PythonEnvironment = { envType: EnvironmentType.Poetry, uri: Uri.file('foobar'), - id: Uri.file('foobar').fsPath, - sysPrefix: '0' + id: Uri.file('foobar').fsPath }; const settings = mock(JupyterSettings); @@ -119,8 +117,7 @@ suite('Module Installer - Poetry', () => { const interpreter: PythonEnvironment = { envType: EnvironmentType.Poetry, uri: Uri.file(path.join(project1, '.venv', 'scripts', 'python.exe')), - id: Uri.file(path.join(project1, '.venv', 'scripts', 'python.exe')).fsPath, - sysPrefix: '0' + id: Uri.file(path.join(project1, '.venv', 'scripts', 'python.exe')).fsPath }; when(configurationService.getSettings(anything())).thenReturn(instance(settings)); @@ -138,8 +135,7 @@ suite('Module Installer - Poetry', () => { const interpreter: PythonEnvironment = { envType: EnvironmentType.Poetry, uri: Uri.file('foobar'), - id: Uri.file('foobar').fsPath, - sysPrefix: '0' + id: Uri.file('foobar').fsPath }; when(configurationService.getSettings(anything())).thenReturn(instance(settings)); @@ -157,8 +153,7 @@ suite('Module Installer - Poetry', () => { const interpreter: PythonEnvironment = { envType: EnvironmentType.Conda, uri: Uri.file('foobar'), - id: Uri.file('foobar').fsPath, - sysPrefix: '0' + id: Uri.file('foobar').fsPath }; when(configurationService.getSettings(anything())).thenReturn(instance(settings)); diff --git a/src/platform/interpreter/installer/productInstaller.unit.test.ts b/src/platform/interpreter/installer/productInstaller.unit.test.ts index fbab8757c6b..0e3457adc96 100644 --- a/src/platform/interpreter/installer/productInstaller.unit.test.ts +++ b/src/platform/interpreter/installer/productInstaller.unit.test.ts @@ -63,8 +63,7 @@ suite('DataScienceInstaller install', async () => { envName: 'test', envPath: interpreterPath, id: interpreterPath.fsPath, - uri: interpreterPath, - sysPrefix: '' + uri: interpreterPath }; installationChannelManager .setup((c) => c.getInstallationChannels(TypeMoq.It.isAny())) @@ -79,8 +78,7 @@ suite('DataScienceInstaller install', async () => { envName: 'test', envPath: interpreterPath, id: interpreterPath.fsPath, - uri: interpreterPath, - sysPrefix: '' + uri: interpreterPath }; const testInstaller = TypeMoq.Mock.ofType(); testInstaller.setup((c) => c.type).returns(() => ModuleInstallerType.Conda); @@ -110,8 +108,7 @@ suite('DataScienceInstaller install', async () => { envName: 'test', envPath: interpreterPath, id: interpreterPath.fsPath, - uri: interpreterPath, - sysPrefix: '' + uri: interpreterPath }; const testInstaller = TypeMoq.Mock.ofType(); testInstaller.setup((c) => c.type).returns(() => ModuleInstallerType.Conda); @@ -141,8 +138,7 @@ suite('DataScienceInstaller install', async () => { envName: 'test', envPath: interpreterPath, uri: interpreterPath, - id: interpreterPath.fsPath, - sysPrefix: '' + id: interpreterPath.fsPath }; const testInstaller = TypeMoq.Mock.ofType(); @@ -173,8 +169,7 @@ suite('DataScienceInstaller install', async () => { envName: 'test', envPath: interpreterPath, id: interpreterPath.fsPath, - uri: interpreterPath, - sysPrefix: '' + uri: interpreterPath }; const testInstaller = TypeMoq.Mock.ofType(); @@ -205,8 +200,7 @@ suite('DataScienceInstaller install', async () => { envName: 'test', envPath: interpreterPath, id: interpreterPath.fsPath, - uri: interpreterPath, - sysPrefix: '' + uri: interpreterPath }; const testInstaller = TypeMoq.Mock.ofType(); diff --git a/src/platform/interpreter/internal/scripts/index.node.ts b/src/platform/interpreter/internal/scripts/index.node.ts index 0150d214801..340825d33cd 100644 --- a/src/platform/interpreter/internal/scripts/index.node.ts +++ b/src/platform/interpreter/internal/scripts/index.node.ts @@ -31,18 +31,6 @@ const SCRIPTS_DIR = _SCRIPTS_DIR; // ignored scripts: // * install_debugpy.py (used only for extension development) -//============================ -// interpreterInfo.py - -type ReleaseLevel = 'alpha' | 'beta' | 'candidate' | 'final'; -type PythonVersionInfo = [number, number, number, ReleaseLevel, number]; -export type PythonEnvInfo = { - versionInfo: PythonVersionInfo; - sysPrefix: string; - is64Bit: boolean; - exe: string; -}; - //============================ // normalizeSelection.py diff --git a/src/platform/pythonEnvironments/info/index.ts b/src/platform/pythonEnvironments/info/index.ts index 073ed385d92..25216e5cc44 100644 --- a/src/platform/pythonEnvironments/info/index.ts +++ b/src/platform/pythonEnvironments/info/index.ts @@ -29,7 +29,6 @@ export type InterpreterId = string; export type InterpreterInformation = { id: InterpreterId; uri: Uri; - sysPrefix: string; }; /** diff --git a/src/test/interpreters/index.node.ts b/src/test/interpreters/index.node.ts index ec08d392408..cea88426f8b 100644 --- a/src/test/interpreters/index.node.ts +++ b/src/test/interpreters/index.node.ts @@ -3,7 +3,6 @@ import * as path from '../../platform/vscode-path/path'; import { traceError } from '../../platform/logging'; -import { PythonEnvInfo } from '../../platform/interpreter/internal/scripts/index.node'; import { ProcessService } from '../../platform/common/process/proc.node'; import { PythonEnvironment } from '../../platform/pythonEnvironments/info'; import { parsePythonVersion } from '../../platform/pythonEnvironments/info/pythonVersion.node'; @@ -25,6 +24,12 @@ const defaultShells = { }; const defaultShell = defaultShells[getOSType()]; +type ReleaseLevel = 'alpha' | 'beta' | 'candidate' | 'final'; +type PythonVersionInfo = [number, number, number, ReleaseLevel, number]; +type PythonEnvInfo = { + versionInfo: PythonVersionInfo; + exe: string; +}; const interpreterInfoCache = new Map>(); export async function getInterpreterInfo(pythonPath: Uri | undefined): Promise { @@ -57,8 +62,7 @@ export async function getInterpreterInfo(pythonPath: Uri | undefined): Promise

): Pyth displayName: `Something${rnd}`, id: Uri.file(`somePath${rnd}`).path, uri: Uri.file(`somePath${rnd}`), - sysPrefix: `someSysPrefix${rnd}`, ...(info || {}) }; } diff --git a/src/webviews/extension-side/dataviewer/dataViewerDependencyService.node.ts b/src/webviews/extension-side/dataviewer/dataViewerDependencyService.node.ts index 05b606157eb..5748f30eefa 100644 --- a/src/webviews/extension-side/dataviewer/dataViewerDependencyService.node.ts +++ b/src/webviews/extension-side/dataviewer/dataViewerDependencyService.node.ts @@ -11,12 +11,6 @@ import { InterpreterDataViewerDependencyImplementation } from './interpreterData import { KernelDataViewerDependencyImplementation } from './kernelDataViewerDependencyImplementation'; import { IDataViewerDependencyService } from './types'; -// TypeScript will narrow the type to PythonEnvironment in any block guarded by a call to isPythonEnvironment -// eslint-disable-next-line @typescript-eslint/no-explicit-any -function isPythonEnvironment(env: any): env is PythonEnvironment { - return 'sysPrefix' in env && typeof env.sysPrefix === 'string'; -} - /** * Responsible for managing dependencies of a Data Viewer. */ @@ -40,10 +34,10 @@ export class DataViewerDependencyService implements IDataViewerDependencyService async checkAndInstallMissingDependencies(executionEnvironment: IKernel | PythonEnvironment): Promise { // IKernel and PythonEnvironment are only types, so I can't compare prototypes or instances of. - if (isPythonEnvironment(executionEnvironment)) { - return this.withInterpreter.checkAndInstallMissingDependencies(executionEnvironment); - } else { + if ('controller' in executionEnvironment) { return this.withKernel.checkAndInstallMissingDependencies(executionEnvironment); + } else { + return this.withInterpreter.checkAndInstallMissingDependencies(executionEnvironment); } } } diff --git a/src/webviews/extension-side/dataviewer/dataViewerDependencyService.unit.test.ts b/src/webviews/extension-side/dataviewer/dataViewerDependencyService.unit.test.ts index b8cbb87e6cd..8fd6e20b5cc 100644 --- a/src/webviews/extension-side/dataviewer/dataViewerDependencyService.unit.test.ts +++ b/src/webviews/extension-side/dataviewer/dataViewerDependencyService.unit.test.ts @@ -4,7 +4,7 @@ import { assert } from 'chai'; import { anything, instance, mock, when } from 'ts-mockito'; import { DataViewerDependencyService } from './dataViewerDependencyService'; -import { IKernel, IKernelSession } from '../../../kernels/types'; +import { IKernel, IKernelController, IKernelSession } from '../../../kernels/types'; import { Common, DataScience } from '../../../platform/common/utils/localize'; import * as helpers from '../../../kernels/helpers'; import * as sinon from 'sinon'; @@ -23,6 +23,7 @@ suite('DataViewerDependencyService (IKernel, Web)', () => { session = mock(); when(session.kernel).thenReturn(instance(mock())); kernel = mock(); + when(kernel.controller).thenReturn(instance(mock())); when(kernel.session).thenReturn(instance(session)); dependencyService = new DataViewerDependencyService(); }); diff --git a/src/webviews/extension-side/dataviewer/dataViewerDependencyServiceInterpreter.node.unit.test.ts b/src/webviews/extension-side/dataviewer/dataViewerDependencyServiceInterpreter.node.unit.test.ts index 397d5069720..7132219e865 100644 --- a/src/webviews/extension-side/dataviewer/dataViewerDependencyServiceInterpreter.node.unit.test.ts +++ b/src/webviews/extension-side/dataviewer/dataViewerDependencyServiceInterpreter.node.unit.test.ts @@ -30,8 +30,7 @@ suite('DataViewerDependencyService (PythonEnvironment, Node)', () => { interpreter = { displayName: '', id: Uri.file(path.join('users', 'python', 'bin', 'python.exe')).fsPath, - uri: Uri.file(path.join('users', 'python', 'bin', 'python.exe')), - sysPrefix: '' + uri: Uri.file(path.join('users', 'python', 'bin', 'python.exe')) }; pythonExecService = mock(); installer = mock(ProductInstaller); diff --git a/src/webviews/extension-side/dataviewer/dataViewerDependencyServiceKernel.node.unit.test.ts b/src/webviews/extension-side/dataviewer/dataViewerDependencyServiceKernel.node.unit.test.ts index ceb7e07d1ef..2ca8ec04784 100644 --- a/src/webviews/extension-side/dataviewer/dataViewerDependencyServiceKernel.node.unit.test.ts +++ b/src/webviews/extension-side/dataviewer/dataViewerDependencyServiceKernel.node.unit.test.ts @@ -4,7 +4,7 @@ import { assert } from 'chai'; import { anything, instance, mock, when } from 'ts-mockito'; import { DataViewerDependencyService } from '../../../webviews/extension-side/dataviewer/dataViewerDependencyService.node'; -import { IKernel, IKernelSession } from '../../../kernels/types'; +import { IKernel, IKernelController, IKernelSession } from '../../../kernels/types'; import { Common, DataScience } from '../../../platform/common/utils/localize'; import * as helpers from '../../../kernels/helpers'; import * as sinon from 'sinon'; @@ -35,6 +35,7 @@ suite('DataViewerDependencyService (IKernel, Node)', () => { session = mock(); when(session.kernel).thenReturn(instance(mock())); when(kernel.session).thenReturn(instance(session)); + when(kernel.controller).thenReturn(instance(mock())); dependencyService = new DataViewerDependencyService( instance(installer),