diff --git a/extensions/positron-python/.github/ISSUE_TEMPLATE/config.yml b/extensions/positron-python/.github/ISSUE_TEMPLATE/config.yml index eaacc33b8d8d..c966f6bde856 100644 --- a/extensions/positron-python/.github/ISSUE_TEMPLATE/config.yml +++ b/extensions/positron-python/.github/ISSUE_TEMPLATE/config.yml @@ -9,9 +9,9 @@ contact_links: - name: 'Jupyter' url: https://github.com/microsoft/vscode-jupyter/issues about: 'For issues relating to the Jupyter extension (including the interactive window)' - - name: 'Debugpy' - url: https://github.com/microsoft/debugpy/issues - about: 'For issues relating to the debugpy debugger' + - name: 'Python Debugger' + url: https://github.com/microsoft/vscode-python-debugger/issues + about: 'For issues relating to the Python debugger' - name: Help/Support url: https://github.com/microsoft/vscode-python/discussions/categories/q-a about: 'Having trouble with the extension? Need help getting something to work?' diff --git a/extensions/positron-python/.github/actions/build-vsix/action.yml b/extensions/positron-python/.github/actions/build-vsix/action.yml index 830263bea2cd..03279fa5fbdd 100644 --- a/extensions/positron-python/.github/actions/build-vsix/action.yml +++ b/extensions/positron-python/.github/actions/build-vsix/action.yml @@ -40,7 +40,7 @@ runs: run: python -m pip install wheel nox shell: bash - - name: Install Python Extension dependencies (jedi, debugpy, etc.) + - name: Install Python Extension dependencies (jedi, etc.) run: nox --session install_python_libs shell: bash diff --git a/extensions/positron-python/.github/actions/smoke-tests/action.yml b/extensions/positron-python/.github/actions/smoke-tests/action.yml index 7eaa2483942a..cc2912115176 100644 --- a/extensions/positron-python/.github/actions/smoke-tests/action.yml +++ b/extensions/positron-python/.github/actions/smoke-tests/action.yml @@ -39,7 +39,6 @@ runs: - name: pip install system test requirements run: | python -m pip install --upgrade -r build/test-requirements.txt - python -m pip --disable-pip-version-check install -t ./python_files/lib/python --implementation py --no-deps --upgrade --pre debugpy shell: bash # Bits from the VSIX are reused by smokeTest.ts to speed things up. diff --git a/extensions/positron-python/.github/workflows/build.yml b/extensions/positron-python/.github/workflows/build.yml index 07090766ef72..4e696f17c428 100644 --- a/extensions/positron-python/.github/workflows/build.yml +++ b/extensions/positron-python/.github/workflows/build.yml @@ -94,7 +94,6 @@ jobs: - name: Install other Python requirements run: | - python -m pip --disable-pip-version-check install -t ./python_files/lib/python --no-cache-dir --implementation py --no-deps --upgrade --pre debugpy python -m pip install --upgrade -r build/test-requirements.txt - name: Run Pyright @@ -192,7 +191,7 @@ jobs: - name: Install build pre-requisite run: python -m pip install wheel nox - - name: Install Python Extension dependencies (jedi, debugpy, etc.) + - name: Install Python Extension dependencies (jedi, etc.) run: nox --session install_python_libs - name: Install test requirements diff --git a/extensions/positron-python/.github/workflows/pr-check.yml b/extensions/positron-python/.github/workflows/pr-check.yml index 11e7de5c61f9..6455ba0fa6cc 100644 --- a/extensions/positron-python/.github/workflows/pr-check.yml +++ b/extensions/positron-python/.github/workflows/pr-check.yml @@ -68,7 +68,6 @@ jobs: - name: Install other Python requirements run: | - python -m pip --disable-pip-version-check install -t ./python_files/lib/python --no-cache-dir --implementation py --no-deps --upgrade --pre debugpy python -m pip install --upgrade -r build/test-requirements.txt - name: Run Pyright @@ -180,7 +179,7 @@ jobs: - name: Install build pre-requisite run: python -m pip install wheel nox - - name: Install Python Extension dependencies (jedi, debugpy, etc.) + - name: Install Python Extension dependencies (jedi, etc.) run: nox --session install_python_libs - name: Install test requirements @@ -380,11 +379,6 @@ jobs: - name: Install Jedi requirements run: python scripts/vendor.py - - name: Install debugpy - run: | - # We need to have debugpy so that tests relying on it keep passing, but we don't need install_debugpy's logic in the test phase. - python -m pip --disable-pip-version-check install -t ./python_files/lib/python --implementation py --no-deps --upgrade --pre debugpy - - name: Install test requirements run: python -m pip install --upgrade -r build/test-requirements.txt diff --git a/extensions/positron-python/build/azure-pipeline.pre-release.yml b/extensions/positron-python/build/azure-pipeline.pre-release.yml index cf7e9ef18a28..cf8659f5c41f 100644 --- a/extensions/positron-python/build/azure-pipeline.pre-release.yml +++ b/extensions/positron-python/build/azure-pipeline.pre-release.yml @@ -54,7 +54,7 @@ extends: - script: | nox --session install_python_libs - displayName: Install debugpy, Jedi, get-pip, etc + displayName: Install Jedi, get-pip, etc - script: | python ./build/update_ext_version.py --for-publishing diff --git a/extensions/positron-python/build/azure-pipeline.stable.yml b/extensions/positron-python/build/azure-pipeline.stable.yml index 5a0701df9108..589000b9f4b3 100644 --- a/extensions/positron-python/build/azure-pipeline.stable.yml +++ b/extensions/positron-python/build/azure-pipeline.stable.yml @@ -49,7 +49,7 @@ extends: - script: | nox --session install_python_libs - displayName: Install debugpy, Jedi, get-pip, etc + displayName: Install Jedi, get-pip, etc - script: | python ./build/update_ext_version.py --release --for-publishing diff --git a/extensions/positron-python/noxfile.py b/extensions/positron-python/noxfile.py index aa6d0253c660..7eb2da93cfe3 100644 --- a/extensions/positron-python/noxfile.py +++ b/extensions/positron-python/noxfile.py @@ -32,13 +32,6 @@ def install_python_libs(session: nox.Session): session.install("packaging") - # Install debugger - session.run( - "python", - "./python_files/install_debugpy.py", - env={"PYTHONPATH": "./python_files/lib/temp"}, - ) - # Download get-pip script session.run( "python", diff --git a/extensions/positron-python/python_files/install_debugpy.py b/extensions/positron-python/python_files/install_debugpy.py deleted file mode 100644 index e38ca82230c9..000000000000 --- a/extensions/positron-python/python_files/install_debugpy.py +++ /dev/null @@ -1,66 +0,0 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. - -import io -import json -import os -import urllib.request as url_lib -import zipfile - -from packaging.version import parse as version_parser - -EXTENSION_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) -DEBUGGER_DEST = os.path.join(EXTENSION_ROOT, "python_files", "lib", "python") -DEBUGGER_PACKAGE = "debugpy" -DEBUGGER_PYTHON_ABI_VERSIONS = ("cp310",) -DEBUGGER_VERSION = "1.8.1" # can also be "latest" - - -def _contains(s, parts=()): - return any(p in s for p in parts) - - -def _get_package_data(): - json_uri = "https://pypi.org/pypi/{0}/json".format(DEBUGGER_PACKAGE) - # Response format: https://warehouse.readthedocs.io/api-reference/json/#project - # Release metadata format: https://github.com/pypa/interoperability-peps/blob/master/pep-0426-core-metadata.rst - with url_lib.urlopen(json_uri) as response: - return json.loads(response.read()) - - -def _get_debugger_wheel_urls(data, version): - return list( - r["url"] - for r in data["releases"][version] - if _contains(r["url"], DEBUGGER_PYTHON_ABI_VERSIONS) - ) - - -def _download_and_extract(root, url, version): - root = os.getcwd() if root is None or root == "." else root - print(url) - with url_lib.urlopen(url) as response: - data = response.read() - with zipfile.ZipFile(io.BytesIO(data), "r") as wheel: - for zip_info in wheel.infolist(): - # Ignore dist info since we are merging multiple wheels - if ".dist-info/" in zip_info.filename: - continue - print("\t" + zip_info.filename) - wheel.extract(zip_info.filename, root) - - -def main(root): - data = _get_package_data() - - if DEBUGGER_VERSION == "latest": - use_version = max(data["releases"].keys(), key=version_parser) - else: - use_version = DEBUGGER_VERSION - - for url in _get_debugger_wheel_urls(data, use_version): - _download_and_extract(root, url, use_version) - - -if __name__ == "__main__": - main(DEBUGGER_DEST) diff --git a/extensions/positron-python/python_files/tests/debug_adapter/__init__.py b/extensions/positron-python/python_files/tests/debug_adapter/__init__.py deleted file mode 100644 index 5b7f7a925cc0..000000000000 --- a/extensions/positron-python/python_files/tests/debug_adapter/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. diff --git a/extensions/positron-python/python_files/tests/debug_adapter/test_install_debugpy.py b/extensions/positron-python/python_files/tests/debug_adapter/test_install_debugpy.py deleted file mode 100644 index f72e1089aaab..000000000000 --- a/extensions/positron-python/python_files/tests/debug_adapter/test_install_debugpy.py +++ /dev/null @@ -1,25 +0,0 @@ -import os - - -def _check_binaries(dir_path): - expected_endswith = ( - "win_amd64.pyd", - "win32.pyd", - "darwin.so", - "x86_64-linux-gnu.so", - ) - - binaries = list(p for p in os.listdir(dir_path) if p.endswith(expected_endswith)) - - assert len(binaries) == len(expected_endswith) - - -def test_install_debugpy(tmpdir): - import install_debugpy - - install_debugpy.main(str(tmpdir)) - dir_path = os.path.join(str(tmpdir), "debugpy", "_vendored", "pydevd", "_pydevd_bundle") - _check_binaries(dir_path) - - dir_path = os.path.join(str(tmpdir), "debugpy", "_vendored", "pydevd", "_pydevd_frame_eval") - _check_binaries(dir_path) diff --git a/extensions/positron-python/src/client/api.ts b/extensions/positron-python/src/client/api.ts index 81a5f676cc22..aaaba540af23 100644 --- a/extensions/positron-python/src/client/api.ts +++ b/extensions/positron-python/src/client/api.ts @@ -12,7 +12,7 @@ import { ILanguageServerOutputChannel } from './activation/types'; import { PythonExtension } from './api/types'; import { isTestExecution, PYTHON_LANGUAGE } from './common/constants'; import { IConfigurationService, Resource } from './common/types'; -import { getDebugpyLauncherArgs, getDebugpyPackagePath } from './debugger/extension/adapter/remoteLaunchers'; +import { getDebugpyLauncherArgs } from './debugger/extension/adapter/remoteLaunchers'; import { IInterpreterService } from './interpreter/contracts'; import { IServiceContainer, IServiceManager } from './ioc/types'; import { JupyterExtensionIntegration } from './jupyter/jupyterIntegration'; @@ -22,6 +22,7 @@ import { buildEnvironmentApi } from './environmentApi'; import { ApiForPylance } from './pylanceApi'; import { getTelemetryReporter } from './telemetry'; import { TensorboardExtensionIntegration } from './tensorBoard/tensorboardIntegration'; +import { getDebugpyPath } from './debugger/pythonDebugger'; export function buildApi( ready: Promise, @@ -122,7 +123,7 @@ export function buildApi( }); }, async getDebuggerPackagePath(): Promise { - return getDebugpyPackagePath(); + return getDebugpyPath(); }, }, settings: { diff --git a/extensions/positron-python/src/client/debugger/extension/adapter/factory.ts b/extensions/positron-python/src/client/debugger/extension/adapter/factory.ts index cfc8cf91aba3..546414699971 100644 --- a/extensions/positron-python/src/client/debugger/extension/adapter/factory.ts +++ b/extensions/positron-python/src/client/debugger/extension/adapter/factory.ts @@ -15,7 +15,7 @@ import { } from 'vscode'; import { EXTENSION_ROOT_DIR } from '../../../constants'; import { IInterpreterService } from '../../../interpreter/contracts'; -import { traceLog, traceVerbose } from '../../../logging'; +import { traceError, traceLog, traceVerbose } from '../../../logging'; import { PythonEnvironment } from '../../../pythonEnvironments/info'; import { sendTelemetryEvent } from '../../../telemetry'; import { EventName } from '../../../telemetry/constants'; @@ -26,6 +26,7 @@ import { Common, Interpreters } from '../../../common/utils/localize'; import { IPersistentStateFactory } from '../../../common/types'; import { Commands } from '../../../common/constants'; import { ICommandManager } from '../../../common/application/types'; +import { getDebugpyPath } from '../../pythonDebugger'; // persistent state names, exported to make use of in testing export enum debugStateKeys { @@ -90,15 +91,12 @@ export class DebugAdapterDescriptorFactory implements IDebugAdapterDescriptorFac traceLog(`DAP Server launched with command: ${executable} ${args.join(' ')}`); return new DebugAdapterExecutable(executable, args); } - - const debuggerAdapterPathToUse = path.join( - EXTENSION_ROOT_DIR, - 'python_files', - 'lib', - 'python', - 'debugpy', - 'adapter', - ); + const debugpyPath = await getDebugpyPath(); + if (!debugpyPath) { + traceError('Could not find debugpy path.'); + throw new Error('Could not find debugpy path.'); + } + const debuggerAdapterPathToUse = path.join(debugpyPath, 'adapter'); const args = command.concat([debuggerAdapterPathToUse, ...logArgs]); traceLog(`DAP Server launched with command: ${executable} ${args.join(' ')}`); diff --git a/extensions/positron-python/src/client/debugger/extension/adapter/remoteLaunchers.ts b/extensions/positron-python/src/client/debugger/extension/adapter/remoteLaunchers.ts index 80e0289e3ad8..f68f747a8a8c 100644 --- a/extensions/positron-python/src/client/debugger/extension/adapter/remoteLaunchers.ts +++ b/extensions/positron-python/src/client/debugger/extension/adapter/remoteLaunchers.ts @@ -3,12 +3,8 @@ 'use strict'; -import * as path from 'path'; -import { EXTENSION_ROOT_DIR } from '../../../common/constants'; import '../../../common/extensions'; - -const pathToPythonLibDir = path.join(EXTENSION_ROOT_DIR, 'python_files', 'lib', 'python'); -const pathToDebugger = path.join(pathToPythonLibDir, 'debugpy'); +import { getDebugpyPath } from '../../pythonDebugger'; type RemoteDebugOptions = { host: string; @@ -16,7 +12,11 @@ type RemoteDebugOptions = { waitUntilDebuggerAttaches: boolean; }; -export function getDebugpyLauncherArgs(options: RemoteDebugOptions, debuggerPath: string = pathToDebugger) { +export async function getDebugpyLauncherArgs(options: RemoteDebugOptions, debuggerPath?: string) { + if (!debuggerPath) { + debuggerPath = await getDebugpyPath(); + } + const waitArgs = options.waitUntilDebuggerAttaches ? ['--wait-for-client'] : []; return [ debuggerPath.fileToCommandArgumentForPythonExt(), @@ -25,7 +25,3 @@ export function getDebugpyLauncherArgs(options: RemoteDebugOptions, debuggerPath ...waitArgs, ]; } - -export function getDebugpyPackagePath(): string { - return pathToDebugger; -} diff --git a/extensions/positron-python/src/client/debugger/pythonDebugger.ts b/extensions/positron-python/src/client/debugger/pythonDebugger.ts new file mode 100644 index 000000000000..3450e95f3cee --- /dev/null +++ b/extensions/positron-python/src/client/debugger/pythonDebugger.ts @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +import { extensions } from 'vscode'; + +interface IPythonDebuggerExtensionApi { + debug: { + getDebuggerPackagePath(): Promise; + }; +} + +async function activateExtension() { + const extension = extensions.getExtension('ms-python.debugpy'); + if (extension) { + if (!extension.isActive) { + await extension.activate(); + } + } + return extension; +} + +async function getPythonDebuggerExtensionAPI(): Promise { + const extension = await activateExtension(); + return extension?.exports as IPythonDebuggerExtensionApi; +} + +export async function getDebugpyPath(): Promise { + const api = await getPythonDebuggerExtensionAPI(); + return api?.debug.getDebuggerPackagePath() ?? ''; +} diff --git a/extensions/positron-python/src/client/jupyter/jupyterIntegration.ts b/extensions/positron-python/src/client/jupyter/jupyterIntegration.ts index ec030f1133f6..69583b744da9 100644 --- a/extensions/positron-python/src/client/jupyter/jupyterIntegration.ts +++ b/extensions/positron-python/src/client/jupyter/jupyterIntegration.ts @@ -11,7 +11,6 @@ import type { SemVer } from 'semver'; import { IContextKeyManager, IWorkspaceService } from '../common/application/types'; import { JUPYTER_EXTENSION_ID, PYLANCE_EXTENSION_ID } from '../common/constants'; import { GLOBAL_MEMENTO, IExtensions, IMemento, Resource } from '../common/types'; -import { getDebugpyPackagePath } from '../debugger/extension/adapter/remoteLaunchers'; import { IEnvironmentActivationService } from '../interpreter/activation/types'; import { IInterpreterQuickPickItem, IInterpreterSelector } from '../interpreter/configuration/types'; import { @@ -22,6 +21,7 @@ import { } from '../interpreter/contracts'; import { PylanceApi } from '../activation/node/pylanceApi'; import { ExtensionContextKey } from '../common/application/contextKeys'; +import { getDebugpyPath } from '../debugger/pythonDebugger'; import type { Environment } from '../api/types'; type PythonApiForJupyterExtension = { @@ -110,7 +110,7 @@ export class JupyterExtensionIntegration { this.interpreterSelector.getAllSuggestions(resource), getKnownSuggestions: (resource: Resource): IInterpreterQuickPickItem[] => this.interpreterSelector.getSuggestions(resource), - getDebuggerPath: async () => dirname(getDebugpyPackagePath()), + getDebuggerPath: async () => dirname(await getDebugpyPath()), getInterpreterPathSelectedForJupyterServer: () => this.globalState.get('INTERPRETER_PATH_SELECTED_FOR_JUPYTER_SERVER'), registerInterpreterStatusFilter: this.interpreterDisplay.registerVisibilityFilter.bind( diff --git a/extensions/positron-python/src/test/api.functional.test.ts b/extensions/positron-python/src/test/api.functional.test.ts index 851d56c00e07..eea0fb920b15 100644 --- a/extensions/positron-python/src/test/api.functional.test.ts +++ b/extensions/positron-python/src/test/api.functional.test.ts @@ -5,6 +5,7 @@ import { assert, expect } from 'chai'; import * as path from 'path'; +import * as sinon from 'sinon'; import { instance, mock, when } from 'ts-mockito'; import { buildApi } from '../client/api'; import { ConfigurationService } from '../client/common/configuration/service'; @@ -17,6 +18,7 @@ import { ServiceContainer } from '../client/ioc/container'; import { ServiceManager } from '../client/ioc/serviceManager'; import { IServiceContainer, IServiceManager } from '../client/ioc/types'; import { IDiscoveryAPI } from '../client/pythonEnvironments/base/locator'; +import * as pythonDebugger from '../client/debugger/pythonDebugger'; suite('Extension API', () => { const debuggerPath = path.join(EXTENSION_ROOT_DIR, 'python_files', 'lib', 'python', 'debugpy'); @@ -29,6 +31,7 @@ suite('Extension API', () => { let interpreterService: IInterpreterService; let discoverAPI: IDiscoveryAPI; let environmentVariablesProvider: IEnvironmentVariablesProvider; + let getDebugpyPathStub: sinon.SinonStub; setup(() => { serviceContainer = mock(ServiceContainer); @@ -47,6 +50,12 @@ suite('Extension API', () => { ); when(serviceContainer.get(IInterpreterService)).thenReturn(instance(interpreterService)); when(serviceContainer.get(IDisposableRegistry)).thenReturn([]); + getDebugpyPathStub = sinon.stub(pythonDebugger, 'getDebugpyPath'); + getDebugpyPathStub.resolves(debuggerPath); + }); + + teardown(() => { + sinon.restore(); }); test('Test debug launcher args (no-wait)', async () => { diff --git a/extensions/positron-python/src/test/debugger/extension/adapter/adapter.test.ts b/extensions/positron-python/src/test/debugger/extension/adapter/adapter.test.ts index 2f60290897af..dd0e9d560bca 100644 --- a/extensions/positron-python/src/test/debugger/extension/adapter/adapter.test.ts +++ b/extensions/positron-python/src/test/debugger/extension/adapter/adapter.test.ts @@ -70,7 +70,7 @@ suite('Debugger Integration', () => { } const [configName, scriptArgs] = tests[kind]; test(kind, async () => { - const session = fix.resolveDebugger(configName, file, scriptArgs, workspaceRoot); + const session = await fix.resolveDebugger(configName, file, scriptArgs, workspaceRoot); await session.start(); // Any debugger ops would go here. await new Promise((r) => setTimeout(r, 300)); // 0.3 seconds @@ -93,7 +93,7 @@ suite('Debugger Integration', () => { } const [configName, scriptArgs] = tests[kind]; test(kind, async () => { - const session = fix.resolveDebugger(configName, file, scriptArgs, workspaceRoot); + const session = await fix.resolveDebugger(configName, file, scriptArgs, workspaceRoot); const bp = session.addBreakpoint(file, 21); // line: "time.sleep()" await session.start(); await session.waitForBreakpoint(bp); diff --git a/extensions/positron-python/src/test/debugger/extension/adapter/factory.unit.test.ts b/extensions/positron-python/src/test/debugger/extension/adapter/factory.unit.test.ts index 172c2715b086..6204bb835479 100644 --- a/extensions/positron-python/src/test/debugger/extension/adapter/factory.unit.test.ts +++ b/extensions/positron-python/src/test/debugger/extension/adapter/factory.unit.test.ts @@ -28,6 +28,7 @@ import * as windowApis from '../../../../client/common/vscodeApis/windowApis'; import { PersistentState, PersistentStateFactory } from '../../../../client/common/persistentState'; import { ICommandManager } from '../../../../client/common/application/types'; import { CommandManager } from '../../../../client/common/application/commandManager'; +import * as pythonDebugger from '../../../../client/debugger/pythonDebugger'; use(chaiAsPromised); @@ -39,9 +40,11 @@ suite('Debugging - Adapter Factory', () => { let showErrorMessageStub: sinon.SinonStub; let readJSONSyncStub: sinon.SinonStub; let commandManager: ICommandManager; + let getDebugpyPathStub: sinon.SinonStub; const nodeExecutable = undefined; - const debugAdapterPath = path.join(EXTENSION_ROOT_DIR, 'python_files', 'lib', 'python', 'debugpy', 'adapter'); + const debugpyPath = path.join(EXTENSION_ROOT_DIR, 'python_files', 'lib', 'python', 'debugpy'); + const debugAdapterPath = path.join(debugpyPath, 'adapter'); const pythonPath = path.join('path', 'to', 'python', 'interpreter'); const interpreter = { architecture: Architecture.Unknown, @@ -75,7 +78,8 @@ suite('Debugging - Adapter Factory', () => { stateFactory = mock(PersistentStateFactory); state = mock(PersistentState) as PersistentState; commandManager = mock(CommandManager); - + getDebugpyPathStub = sinon.stub(pythonDebugger, 'getDebugpyPath'); + getDebugpyPathStub.resolves(debugpyPath); showErrorMessageStub = sinon.stub(windowApis, 'showErrorMessage'); when( diff --git a/extensions/positron-python/src/test/debugger/extension/adapter/remoteLaunchers.unit.test.ts b/extensions/positron-python/src/test/debugger/extension/adapter/remoteLaunchers.unit.test.ts index 2a75f6316a09..e8e2cbd5d15d 100644 --- a/extensions/positron-python/src/test/debugger/extension/adapter/remoteLaunchers.unit.test.ts +++ b/extensions/positron-python/src/test/debugger/extension/adapter/remoteLaunchers.unit.test.ts @@ -5,7 +5,6 @@ import { expect } from 'chai'; import * as path from 'path'; -import { EXTENSION_ROOT_DIR } from '../../../../client/common/constants'; import '../../../../client/common/extensions'; import * as launchers from '../../../../client/debugger/extension/adapter/remoteLaunchers'; @@ -24,7 +23,7 @@ suite('External debugpy Debugger Launcher', () => { ].forEach((testParams) => { suite(testParams.testName, async () => { test('Test remote debug launcher args (and do not wait for debugger to attach)', async () => { - const args = launchers.getDebugpyLauncherArgs( + const args = await launchers.getDebugpyLauncherArgs( { host: 'something', port: 1234, @@ -36,7 +35,7 @@ suite('External debugpy Debugger Launcher', () => { expect(args).to.be.deep.equal(expectedArgs); }); test('Test remote debug launcher args (and wait for debugger to attach)', async () => { - const args = launchers.getDebugpyLauncherArgs( + const args = await launchers.getDebugpyLauncherArgs( { host: 'something', port: 1234, @@ -50,12 +49,3 @@ suite('External debugpy Debugger Launcher', () => { }); }); }); - -suite('Path To Debugger Package', () => { - const pathToPythonLibDir = path.join(EXTENSION_ROOT_DIR, 'python_files', 'lib', 'python'); - test('Path to debugpy debugger package', () => { - const actual = launchers.getDebugpyPackagePath(); - const expected = path.join(pathToPythonLibDir, 'debugpy'); - expect(actual).to.be.deep.equal(expected); - }); -}); diff --git a/extensions/positron-python/src/test/debugger/utils.ts b/extensions/positron-python/src/test/debugger/utils.ts index 4a41489940b8..749adb359597 100644 --- a/extensions/positron-python/src/test/debugger/utils.ts +++ b/extensions/positron-python/src/test/debugger/utils.ts @@ -277,12 +277,12 @@ class DebuggerSession { } export class DebuggerFixture extends PythonFixture { - public resolveDebugger( + public async resolveDebugger( configName: string, file: string, scriptArgs: string[], wsRoot?: vscode.WorkspaceFolder, - ): DebuggerSession { + ): Promise { const config = getConfig(configName); let proc: Proc | undefined; if (config.request === 'launch') { @@ -292,7 +292,7 @@ export class DebuggerFixture extends PythonFixture { // XXX set the file in the current vscode editor? } else if (config.request === 'attach') { if (config.port) { - proc = this.runDebugger(config.port, file, ...scriptArgs); + proc = await this.runDebugger(config.port, file, ...scriptArgs); if (wsRoot && config.name === 'attach to a local port') { config.pathMappings.localRoot = wsRoot.uri.fsPath; } @@ -352,8 +352,8 @@ export class DebuggerFixture extends PythonFixture { } } - public runDebugger(port: number, filename: string, ...scriptArgs: string[]) { - const args = getDebugpyLauncherArgs({ + public async runDebugger(port: number, filename: string, ...scriptArgs: string[]) { + const args = await getDebugpyLauncherArgs({ host: 'localhost', port: port, // This causes problems if we set it to true. diff --git a/extensions/positron-python/src/test/pythonFiles/dummy.py b/extensions/positron-python/src/test/pythonFiles/dummy.py new file mode 100644 index 000000000000..10f13768abe0 --- /dev/null +++ b/extensions/positron-python/src/test/pythonFiles/dummy.py @@ -0,0 +1 @@ +#dummy file to be opened by Test VS Code instance, so that Python Configuration (workspace configuration will be initialized) \ No newline at end of file