GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Use activated python proc to check if modules are installed (#9644) · evaperon/vscode-python@97bad7d

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • news/2 Fixes
    • 9566.md
    • 9643.md
  • pythonFiles/datascience/daemon
    • daemon_python.py
  • src
    • client
      • common
        • installer
          • productInstaller.ts
        • process
          • pythonExecutionFactory.ts
          • types.ts
      • datascience/jupyter/kernels
        • kernelService.ts
    • test
      • common/installer
        • installer.unit.test.ts
      • datascience/jupyter/kernels
        • kernelService.unit.test.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎news/2 Fixes/9566.md‎

Copy file name to clipboard
+1Lines changed: 1 addition & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Use the correct interpreter when creating the Python execution service used as a fallback by the Daemon.
Collapse file

‎news/2 Fixes/9643.md‎

Copy file name to clipboard
+1Lines changed: 1 addition & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Use an activated environment python process to check if modules are installed.
Collapse file

‎pythonFiles/datascience/daemon/daemon_python.py‎

Copy file name to clipboardExpand all lines: pythonFiles/datascience/daemon/daemon_python.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def __getitem__(self, item):
8282
self.log.debug("Ignoring non-exit method during shutdown: %s", item)
8383
raise KeyError
8484

85-
self.log.info("Execute rpc method %s", item)
85+
self.log.info("Execute rpc method %s from %s", item, sys.executable)
8686
return super().__getitem__(item)
8787

8888
def start(self):
Collapse file

‎src/client/common/installer/productInstaller.ts‎

Copy file name to clipboardExpand all lines: src/client/common/installer/productInstaller.ts
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,15 @@ export abstract class BaseInstaller {
7878
return true;
7979
}
8080
// User may have customized the module name or provided the fully qualified path.
81-
const pythonPath = isResource(resource) ? undefined : resource.path;
81+
const interpreter = isResource(resource) ? undefined : resource;
8282
const uri = isResource(resource) ? resource : undefined;
8383
const executableName = this.getExecutableNameFromSettings(product, uri);
8484

8585
const isModule = this.isExecutableAModule(product, uri);
8686
if (isModule) {
87-
const pythonProcess = await this.serviceContainer.get<IPythonExecutionFactory>(IPythonExecutionFactory).create({ resource: uri, pythonPath });
87+
const pythonProcess = await this.serviceContainer
88+
.get<IPythonExecutionFactory>(IPythonExecutionFactory)
89+
.createActivatedEnvironment({ resource: uri, interpreter, allowEnvironmentFetchExceptions: true });
8890
return pythonProcess.isModuleInstalled(executableName);
8991
} else {
9092
const process = await this.serviceContainer.get<IProcessServiceFactory>(IProcessServiceFactory).create(uri);
Collapse file

‎src/client/common/process/pythonExecutionFactory.ts‎

Copy file name to clipboardExpand all lines: src/client/common/process/pythonExecutionFactory.ts
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,15 @@ export class PythonExecutionFactory implements IPythonExecutionFactory {
6363
const disposables = this.serviceContainer.get<IDisposableRegistry>(IDisposableRegistry);
6464
const interpreterService = this.serviceContainer.get<IInterpreterService>(IInterpreterService);
6565
const logger = this.serviceContainer.get<IProcessLogger>(IProcessLogger);
66+
67+
const interpreter = await interpreterService.getInterpreterDetails(pythonPath);
6668
const activatedProcPromise = this.createActivatedEnvironment({
6769
allowEnvironmentFetchExceptions: true,
68-
pythonPath: pythonPath,
70+
interpreter: interpreter,
6971
resource: options.resource,
7072
bypassCondaExecution: true
7173
});
72-
7374
// No daemon support in Python 2.7.
74-
const interpreter = await interpreterService.getInterpreterDetails(pythonPath);
7575
if (interpreter?.version && interpreter.version.major < 3) {
7676
return activatedProcPromise!;
7777
}
@@ -90,7 +90,7 @@ export class PythonExecutionFactory implements IPythonExecutionFactory {
9090
return daemon;
9191
};
9292

93-
// Ensure we do not create muliple daemon pools for the same python interpreter.
93+
// Ensure we do not create multiple daemon pools for the same python interpreter.
9494
let promise = this.daemonsPerPythonService.get(daemonPoolKey);
9595
if (!promise) {
9696
promise = start();
Collapse file

‎src/client/common/process/types.ts‎

Copy file name to clipboardExpand all lines: src/client/common/process/types.ts
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ export type DaemonExecutionFactoryCreationOptions = ExecutionFactoryCreationOpti
9999
};
100100
export type ExecutionFactoryCreateWithEnvironmentOptions = {
101101
resource?: Uri;
102-
pythonPath?: string;
103102
interpreter?: PythonInterpreter;
104103
allowEnvironmentFetchExceptions?: boolean;
105104
/**
Collapse file

‎src/client/datascience/jupyter/kernels/kernelService.ts‎

Copy file name to clipboardExpand all lines: src/client/datascience/jupyter/kernels/kernelService.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ export class KernelService {
227227
throw new Error('Interpreter does not have a display name');
228228
}
229229

230-
const execServicePromise = this.execFactory.create({ pythonPath: interpreter.path });
230+
const execServicePromise = this.execFactory.createActivatedEnvironment({ interpreter, allowEnvironmentFetchExceptions: true, bypassCondaExecution: true });
231231
// Swallow errors if we get out of here and not resolve this.
232232
execServicePromise.ignoreErrors();
233233
const name = this.generateKernelNameForIntepreter(interpreter);
Collapse file

‎src/test/common/installer/installer.unit.test.ts‎

Copy file name to clipboardExpand all lines: src/test/common/installer/installer.unit.test.ts
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ suite('Module Installer only', () => {
476476
const pythonExecutionFactory = TypeMoq.Mock.ofType<IPythonExecutionFactory>();
477477
const pythonExecutionService = TypeMoq.Mock.ofType<IPythonExecutionService>();
478478
serviceContainer.setup(c => c.get(TypeMoq.It.isValue(IPythonExecutionFactory))).returns(() => pythonExecutionFactory.object);
479-
pythonExecutionFactory.setup(p => p.create(TypeMoq.It.isAny())).returns(() => Promise.resolve(pythonExecutionService.object));
479+
pythonExecutionFactory.setup(p => p.createActivatedEnvironment(TypeMoq.It.isAny())).returns(() => Promise.resolve(pythonExecutionService.object));
480480
pythonExecutionService
481481
// tslint:disable-next-line: no-any
482482
.setup(p => (p as any).then)
@@ -496,7 +496,7 @@ suite('Module Installer only', () => {
496496
const pythonExecutionFactory = TypeMoq.Mock.ofType<IPythonExecutionFactory>();
497497
const pythonExecutionService = TypeMoq.Mock.ofType<IPythonExecutionService>();
498498
serviceContainer.setup(c => c.get(TypeMoq.It.isValue(IPythonExecutionFactory))).returns(() => pythonExecutionFactory.object);
499-
pythonExecutionFactory.setup(p => p.create(TypeMoq.It.isAny())).returns(() => Promise.resolve(pythonExecutionService.object));
499+
pythonExecutionFactory.setup(p => p.createActivatedEnvironment(TypeMoq.It.isAny())).returns(() => Promise.resolve(pythonExecutionService.object));
500500
pythonExecutionService
501501
// tslint:disable-next-line: no-any
502502
.setup(p => (p as any).then)
Collapse file

‎src/test/datascience/jupyter/kernels/kernelService.unit.test.ts‎

Copy file name to clipboardExpand all lines: src/test/datascience/jupyter/kernels/kernelService.unit.test.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ suite('Data Science - KernelService', () => {
5151
execService = mock(PythonExecutionService);
5252
installer = mock(ProductInstaller);
5353
jupyterInterpreterExecutionService = mock(JupyterCommandFinderInterpreterExecutionService);
54-
when(execFactory.create(anything())).thenResolve(instance(execService));
54+
when(execFactory.createActivatedEnvironment(anything())).thenResolve(instance(execService));
5555
// tslint:disable-next-line: no-any
5656
(instance(execService) as any).then = undefined;
5757

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.