Skip to content

Commit

Permalink
Set PYDEVD_IPYTHON_COMPATIBLE_DEBUGGING in Python process (#11684)
Browse files Browse the repository at this point in the history
  • Loading branch information
DonJayamanne authored Oct 18, 2022
1 parent ecad7ae commit 0111a77
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions news/3 Code Health/11682.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Initialize the environment variable `PYDEVD_IPYTHON_COMPATIBLE_DEBUGGING` at the point of spawning the Python kernel.
8 changes: 6 additions & 2 deletions src/kernels/debuggerStartupCodeProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import { injectable } from 'inversify';
import { isPythonKernelConnection } from './helpers';
import { IKernel, IStartupCodeProvider, StartupCodePriority } from './types';
import { IKernel, isLocalConnection, IStartupCodeProvider, StartupCodePriority } from './types';

@injectable()
export class DebugStartupCodeProvider implements IStartupCodeProvider {
Expand All @@ -13,7 +13,11 @@ export class DebugStartupCodeProvider implements IStartupCodeProvider {
if (!isPythonKernelConnection(kernel.kernelConnectionMetadata)) {
return [];
}

if (isLocalConnection(kernel.kernelConnectionMetadata)) {
return [];
}
// Inject the env var only for remote kernels, for local kernels,
// this env var will be setup when spawning the kernel process.
return [
'import os as __VSCODE_os',
// Required to get pydevd to work properly in Python kernel, more info here https://github.com/microsoft/vscode-jupyter/issues/11033
Expand Down
4 changes: 3 additions & 1 deletion src/kernels/raw/launcher/kernelEnvVarsService.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ export class KernelEnvironmentVariablesService {
traceInfo(`Adding env Variable PYTHONNOUSERSITE to ${getDisplayPath(interpreter?.uri)}`);
mergedVars.PYTHONNOUSERSITE = 'True';
}

if (isPythonKernel) {
mergedVars.PYDEVD_IPYTHON_COMPATIBLE_DEBUGGING = '1';
}
return mergedVars;
}
}

0 comments on commit 0111a77

Please sign in to comment.