Skip to content

Commit 258c28c

Browse files
authored
Remove all other version of debugpy (microsoft#11689)
* Remove all other version of debugpy * Add news * fix linting * Fix debugpy install for py 2.7 tests
1 parent bd12464 commit 258c28c

File tree

13 files changed

+35
-116
lines changed

13 files changed

+35
-116
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ jobs:
4646
run: |
4747
python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python --no-cache-dir --implementation py --no-deps --upgrade -r requirements.txt
4848
python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python/old_ptvsd --no-cache-dir --implementation py --no-deps --upgrade 'ptvsd==4.3.2'
49-
python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python/debugpy/no_wheels --no-cache-dir --implementation py --no-deps --upgrade --pre debugpy
5049
5150
- name: Install debugpy wheels
5251
run: |
@@ -259,9 +258,8 @@ jobs:
259258
run: |
260259
python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python --no-cache-dir --implementation py --no-deps --upgrade -r requirements.txt
261260
python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python/old_ptvsd --no-cache-dir --implementation py --no-deps --upgrade 'ptvsd==4.3.2'
262-
python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python/debugpy/no_wheels --no-cache-dir --implementation py --no-deps --upgrade --pre debugpy
263-
# We need to have debugpy available in wheels/ so that tests relying on it keep passing, but we don't need install_debugpy's logic in the test phase.
264-
python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python/debugpy/wheels --no-cache-dir --implementation py --no-deps --upgrade --pre debugpy
261+
# 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.
262+
python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python --no-cache-dir --implementation py --no-deps --upgrade --pre debugpy
265263
266264
- name: Install test requirements
267265
run: python -m pip install --upgrade -r build/test-requirements.txt
@@ -272,14 +270,20 @@ jobs:
272270
python -m pip install --upgrade -r ./build/ipython-test-requirements.txt
273271
if: matrix.test-suite == 'python-unit'
274272

275-
- name: Install debugpy wheels
273+
- name: Install debugpy wheels (python 3.8)
276274
run: |
277275
python -m pip install wheel
278276
python -m pip --disable-pip-version-check install -r build/debugger-install-requirements.txt
279277
python ./pythonFiles/install_debugpy.py
280278
shell: bash
281279
if: matrix.test-suite == 'debugger' && matrix.python == 3.8
282280

281+
- name: Install debugpy (python 2.7)
282+
run: |
283+
python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python --no-cache-dir --implementation py --no-deps --upgrade --pre debugpy
284+
shell: bash
285+
if: matrix.test-suite == 'debugger' && matrix.python == 2.7
286+
283287
- name: Install functional test requirements
284288
run: |
285289
python -m pip install numpy
@@ -454,7 +458,7 @@ jobs:
454458
python -m pip install --upgrade -r build/test-requirements.txt
455459
python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python --no-cache-dir --implementation py --no-deps --upgrade -r requirements.txt
456460
python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python/old_ptvsd --no-cache-dir --implementation py --no-deps --upgrade 'ptvsd==4.3.2'
457-
python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python/debugpy/no_wheels --no-cache-dir --implementation py --no-deps --upgrade --pre debugpy
461+
python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python --no-cache-dir --implementation py --no-deps --upgrade --pre debugpy
458462
shell: bash
459463

460464
- name: pip install ipython requirements

CONTRIBUTING.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,9 @@ Steps to build the extension on your machine once you've cloned the repo:
301301
> npm ci
302302
> python3 -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python --no-cache-dir --implementation py --no-deps --upgrade -r requirements.txt
303303
> python3 -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python/old_ptvsd --no-cache-dir --implementation py --no-deps --upgrade 'ptvsd==4.3.2'
304-
> python3 -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python/debugpy/no_wheels --no-cache-dir --implementation py --no-deps --upgrade --pre debugpy
304+
# For python 3.6 and lower use this command to install the debugger
305+
> python3 -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python --no-cache-dir --implementation py --no-deps --upgrade --pre debugpy
306+
# For python 3.7 and greater use this command to install the debugger
305307
> python3 -m pip --disable-pip-version-check install -r build/debugger-install-requirements.txt
306308
> python3 ./pythonFiles/install_debugpy.py
307309
> npm run clean

build/ci/templates/steps/build.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ steps:
2121
- bash: |
2222
python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python --no-cache-dir --implementation py --no-deps --upgrade -r requirements.txt
2323
python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python/old_ptvsd --no-cache-dir --implementation py --no-deps --upgrade 'ptvsd==4.3.2'
24-
python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python/debugpy/no_wheels --no-cache-dir --implementation py --no-deps --upgrade --pre debugpy
2524
failOnStderr: true
2625
displayName: 'pip install requirements'
2726

build/ci/templates/test_phases.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ steps:
9494
python -m pip install --upgrade -r build/test-requirements.txt
9595
python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python --no-cache-dir --implementation py --no-deps --upgrade -r requirements.txt
9696
python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python/old_ptvsd --no-cache-dir --implementation py --no-deps --upgrade 'ptvsd==4.3.2'
97-
python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python/debugpy/no_wheels --no-cache-dir --implementation py --no-deps --upgrade --pre debugpy
97+
python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python --no-cache-dir --implementation py --no-deps --upgrade --pre debugpy
9898
displayName: 'pip install system test requirements'
9999
condition: and(succeeded(), eq(variables['NeedsPythonTestReqs'], 'true'))
100100
@@ -161,7 +161,7 @@ steps:
161161
# Run the pip installs in the 3 environments (windows)
162162
- script: |
163163
call activate base
164-
conda install --quiet -y --file build/ci/conda_base.yml
164+
conda install --quiet -y --file build/ci/conda_base.yml
165165
python -m pip install --upgrade -r build/conda-functional-requirements.txt
166166
call activate conda_env_1
167167
python -m pip install --upgrade -r build/conda-functional-requirements.txt

gulpfile.js

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -405,37 +405,6 @@ gulp.task('installNewDebugpy', async () => {
405405
}
406406

407407
rmrf.sync('./pythonFiles/lib/temp');
408-
409-
// Install source only version of new DEBUGPY for use with all other python versions.
410-
const args = [
411-
'-m',
412-
'pip',
413-
'--disable-pip-version-check',
414-
'install',
415-
'-t',
416-
'./pythonFiles/lib/python/debugpy/no_wheels',
417-
'--no-cache-dir',
418-
'--implementation',
419-
'py',
420-
'--no-deps',
421-
'--upgrade',
422-
'--pre',
423-
'debugpy'
424-
];
425-
const successWithoutWheels = await spawnAsync(process.env.CI_PYTHON_PATH || 'python3', args, undefined, true)
426-
.then(() => true)
427-
.catch((ex) => {
428-
console.error("Failed to install DEBUGPY using 'python3'", ex);
429-
return false;
430-
});
431-
if (!successWithoutWheels) {
432-
console.info(
433-
"Failed to install source only version of new DEBUGPY using 'python3', attempting to install using 'python'"
434-
);
435-
await spawnAsync('python', args).catch((ex) =>
436-
console.error("Failed to install source only DEBUGPY using 'python'", ex)
437-
);
438-
}
439408
});
440409

441410
// Install the last stable version of old PTVSD (which includes a middle layer adapter and requires ptvsd_launcher.py)

news/2 Fixes/11686.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixes issue with importing `debupy` in interactive window.

pythonFiles/install_debugpy.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77

88

99
EXTENSION_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
10-
DEBUGGER_DEST = os.path.join(
11-
EXTENSION_ROOT, "pythonFiles", "lib", "python", "debugpy", "wheels"
12-
)
10+
DEBUGGER_DEST = os.path.join(EXTENSION_ROOT, "pythonFiles", "lib", "python")
1311
DEBUGGER_PACKAGE = "debugpy"
1412
DEBUGGER_PYTHON_VERSIONS = ("cp37",)
1513

src/client/datascience/jupyter/jupyterDebugger.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -238,20 +238,13 @@ export class JupyterDebugger implements IJupyterDebugger, ICellHashListener {
238238
* @returns {Promise<string>}
239239
* @memberof JupyterDebugger
240240
*/
241-
private async getDebuggerPath(notebook: INotebook): Promise<string> {
241+
private async getDebuggerPath(_notebook: INotebook): Promise<string> {
242242
if (this.debuggerPackage === 'ptvsd') {
243243
return path.join(EXTENSION_ROOT_DIR, 'pythonFiles', 'lib', 'python', 'old_ptvsd');
244244
}
245-
const pythonVersion = await this.getKernelPythonVersion(notebook);
246-
// The new debug adapter with wheels is only supported in 3.7
247-
// Code can be found here (src/client/debugger/extension/adapter/factory.ts).
248-
if (pythonVersion && pythonVersion.major === 3 && pythonVersion.minor === 7) {
249-
// Return debugger with wheels
250-
return path.join(EXTENSION_ROOT_DIR, 'pythonFiles', 'lib', 'python', 'debugpy', 'wheels');
251-
}
252245

253246
// We are here so this is NOT python 3.7, return debugger without wheels
254-
return path.join(EXTENSION_ROOT_DIR, 'pythonFiles', 'lib', 'python', 'debugpy', 'no_wheels');
247+
return path.join(EXTENSION_ROOT_DIR, 'pythonFiles', 'lib', 'python');
255248
}
256249
private async calculateDebuggerPathList(notebook: INotebook): Promise<string | undefined> {
257250
const extraPaths: string[] = [];
@@ -328,11 +321,6 @@ export class JupyterDebugger implements IJupyterDebugger, ICellHashListener {
328321
return notebook.execute(code, Identifiers.EmptyFileName, 0, uuid(), undefined, true);
329322
}
330323

331-
private async getKernelPythonVersion(notebook: INotebook): Promise<Version | undefined> {
332-
const execResults = await this.executeSilently(notebook, 'import sys;print(sys.version)');
333-
return this.parseVersionInfo(execResults, 'pythonVersionInfo');
334-
}
335-
336324
private async debuggerCheck(notebook: INotebook): Promise<Version | undefined> {
337325
// We don't want to actually import the debugger to check version so run
338326
// python instead. If we import an old version it's hard to get rid of on

src/client/debugger/extension/adapter/factory.ts

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -75,23 +75,17 @@ export class DebugAdapterDescriptorFactory implements IDebugAdapterDescriptorFac
7575
return new DebugAdapterExecutable(pythonPath, [configuration.debugAdapterPath, ...logArgs]);
7676
}
7777

78-
const debuggerPathToUse = path.join(EXTENSION_ROOT_DIR, 'pythonFiles', 'lib', 'python', 'debugpy');
79-
80-
if (await this.useNewDebugger(pythonPath)) {
81-
sendTelemetryEvent(EventName.DEBUG_ADAPTER_USING_WHEELS_PATH, undefined, { usingWheels: true });
82-
return new DebugAdapterExecutable(pythonPath, [
83-
path.join(debuggerPathToUse, 'wheels', 'debugpy', 'adapter'),
84-
...logArgs
85-
]);
86-
} else {
87-
sendTelemetryEvent(EventName.DEBUG_ADAPTER_USING_WHEELS_PATH, undefined, {
88-
usingWheels: false
89-
});
90-
return new DebugAdapterExecutable(pythonPath, [
91-
path.join(debuggerPathToUse, 'no_wheels', 'debugpy', 'adapter'),
92-
...logArgs
93-
]);
94-
}
78+
const debuggerAdapterPathToUse = path.join(
79+
EXTENSION_ROOT_DIR,
80+
'pythonFiles',
81+
'lib',
82+
'python',
83+
'debugpy',
84+
'adapter'
85+
);
86+
87+
sendTelemetryEvent(EventName.DEBUG_ADAPTER_USING_WHEELS_PATH, undefined, { usingWheels: true });
88+
return new DebugAdapterExecutable(pythonPath, [debuggerAdapterPathToUse, ...logArgs]);
9589
}
9690
} else {
9791
this.experimentsManager.sendTelemetryIfInExperiment(DebugAdapterNewPtvsd.control);
@@ -105,22 +99,6 @@ export class DebugAdapterDescriptorFactory implements IDebugAdapterDescriptorFac
10599
throw new Error('Debug Adapter Executable not provided');
106100
}
107101

108-
/**
109-
* Check and return whether the user should and can use the new Debugger wheels or not.
110-
*
111-
* @param {string} pythonPath Path to the python executable used to launch the Python Debug Adapter (result of `this.getPythonPath()`)
112-
* @returns {Promise<boolean>} Whether the user should and can use the new Debugger wheels or not.
113-
* @memberof DebugAdapterDescriptorFactory
114-
*/
115-
private async useNewDebugger(pythonPath: string): Promise<boolean> {
116-
const interpreterInfo = await this.interpreterService.getInterpreterDetails(pythonPath);
117-
if (!interpreterInfo || !interpreterInfo.version || !interpreterInfo.version.raw.startsWith('3.7')) {
118-
return false;
119-
}
120-
121-
return true;
122-
}
123-
124102
/**
125103
* Get the python executable used to launch the Python Debug Adapter.
126104
* In the case of `attach` scenarios, just use the workspace interpreter, else first available one.

src/client/debugger/extension/adapter/remoteLaunchers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import '../../../common/extensions';
99

1010
const pathToPythonLibDir = path.join(EXTENSION_ROOT_DIR, 'pythonFiles', 'lib', 'python');
1111
const pathToScript = path.join(EXTENSION_ROOT_DIR, 'pythonFiles', 'ptvsd_launcher.py');
12-
const pathToDebugger = path.join(pathToPythonLibDir, 'debugpy', 'no_wheels', 'debugpy');
12+
const pathToDebugger = path.join(pathToPythonLibDir, 'debugpy');
1313

1414
export type RemoteDebugOptions = {
1515
host: string;

0 commit comments

Comments
 (0)