Skip to content

Commit 6314e70

Browse files
karthiknadigKartik Rajdependabot[bot]joyceerhlkimadeline
authored
Merge release back into main (microsoft#16763)
* Fix 'Cannot read property 'resolveEnv' of undefined' error (microsoft#16677) * Cherry pick fixes into release (microsoft#16686) * Bump actions/setup-node from 2.1.5 to 2.2.0 (microsoft#16592) Bumps [actions/setup-node](https://github.com/actions/setup-node) from 2.1.5 to 2.2.0. - [Release notes](https://github.com/actions/setup-node/releases) - [Commits](actions/setup-node@v2.1.5...v2.2.0) --- updated-dependencies: - dependency-name: actions/setup-node dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Add support for starting TensorBoard session with a remote log directory via URL (microsoft#16477) * Add support for remote logdirs * Add missing keys * Fix typo * Bump isort from 5.8.0 to 5.9.2 (microsoft#16636) Bumps [isort](https://github.com/pycqa/isort) from 5.8.0 to 5.9.2. - [Release notes](https://github.com/pycqa/isort/releases) - [Changelog](https://github.com/PyCQA/isort/blob/main/CHANGELOG.md) - [Commits](PyCQA/isort@5.8.0...5.9.2) --- updated-dependencies: - dependency-name: isort dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Make getInterpreters() API faster for subsequent calls (microsoft#16674) * Change the way auto-selection works (microsoft#16644) * New comparison logic * Add experiment group * Register and call it * Add service registry tests * Add interpreter selector unit tests * Add comparison unit tests * Add intepreter selector test * News file * Adjust comments * Reuse getSortName * Add new auto-selection logic * Add tests for getEnvTypeHeuristic * Move persistent store initialization back out * Update tests Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Joyce Er <joyceerhuiling@gmail.com> Co-authored-by: Kartik Raj <karraj@microsoft.com> Co-authored-by: Kim-Adeline Miguel <51720070+kimadeline@users.noreply.github.com> * Change version for release (microsoft#16722) * Ensure we block on autoselection when no interpreter is explictly set by user (microsoft#16723) * Ensure we block on autoselection when no interpreter is explictly set by user * Added tests * News entry * Update change log for release. (microsoft#16731) * Fix autoselection when opening a python file directly (microsoft#16733) * Fix autoselection when opening a python file directly * Update changelog * Add tests * Ignore cache when querying for interpreters during auto-selection (microsoft#16734) * Ignore cache when getting envs for autoselection * Don't call autoSelectInterpreter twice * Update debugger via point release (microsoft#16746) * Update version * Update change log * Update wheels to 3.9 (microsoft#16745) * Clean up Co-authored-by: Kartik Raj <karraj@microsoft.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Joyce Er <joyceerhuiling@gmail.com> Co-authored-by: Kim-Adeline Miguel <51720070+kimadeline@users.noreply.github.com>
1 parent e87f429 commit 6314e70

14 files changed

Lines changed: 256 additions & 68 deletions

File tree

CHANGELOG.md

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,72 @@
11
# Changelog
22

3-
## 2021.7.0-rc (12 July 2021)
3+
## 2021.7.1 (21 July 2021)
44

55
### Enhancements
66

7+
1. Update `debugpy` to the latest version.
8+
9+
### Thanks
10+
11+
Thanks to the following projects which we fully rely on to provide some of
12+
our features:
13+
14+
- [debugpy](https://pypi.org/project/debugpy/)
15+
- [isort](https://pypi.org/project/isort/)
16+
- [jedi](https://pypi.org/project/jedi/)
17+
and [parso](https://pypi.org/project/parso/)
18+
- [jedi-language-server](https://pypi.org/project/jedi-language-server/)
19+
- [Microsoft Python Language Server](https://github.com/microsoft/python-language-server)
20+
- [Pylance](https://github.com/microsoft/pylance-release)
21+
- [exuberant ctags](http://ctags.sourceforge.net/) (user-installed)
22+
- [rope](https://pypi.org/project/rope/) (user-installed)
23+
24+
Also thanks to the various projects we provide integrations with which help
25+
make this extension useful:
26+
27+
- Debugging support:
28+
[Django](https://pypi.org/project/Django/),
29+
[Flask](https://pypi.org/project/Flask/),
30+
[gevent](https://pypi.org/project/gevent/),
31+
[Jinja](https://pypi.org/project/Jinja/),
32+
[Pyramid](https://pypi.org/project/pyramid/),
33+
[PySpark](https://pypi.org/project/pyspark/),
34+
[Scrapy](https://pypi.org/project/Scrapy/),
35+
[Watson](https://pypi.org/project/Watson/)
36+
- Formatting:
37+
[autopep8](https://pypi.org/project/autopep8/),
38+
[black](https://pypi.org/project/black/),
39+
[yapf](https://pypi.org/project/yapf/)
40+
- Interpreter support:
41+
[conda](https://conda.io/),
42+
[direnv](https://direnv.net/),
43+
[pipenv](https://pypi.org/project/pipenv/),
44+
[pyenv](https://github.com/pyenv/pyenv),
45+
[venv](https://docs.python.org/3/library/venv.html#module-venv),
46+
[virtualenv](https://pypi.org/project/virtualenv/)
47+
- Linting:
48+
[bandit](https://pypi.org/project/bandit/),
49+
[flake8](https://pypi.org/project/flake8/),
50+
[mypy](https://pypi.org/project/mypy/),
51+
[prospector](https://pypi.org/project/prospector/),
52+
[pylint](https://pypi.org/project/pylint/),
53+
[pydocstyle](https://pypi.org/project/pydocstyle/),
54+
[pylama](https://pypi.org/project/pylama/)
55+
- Testing:
56+
[nose](https://pypi.org/project/nose/),
57+
[pytest](https://pypi.org/project/pytest/),
58+
[unittest](https://docs.python.org/3/library/unittest.html#module-unittest)
59+
60+
And finally thanks to the [Python](https://www.python.org/) development team and
61+
community for creating a fantastic programming language and community to be a
62+
part of!
63+
64+
## 2021.7.0 (20 July 2021)
65+
66+
### Enhancements
67+
68+
1. Support starting a TensorBoard session with a remote URL hosting log files.
69+
([#16461](https://github.com/Microsoft/vscode-python/issues/16461))
770
1. Sort environments in the selection quickpick by assumed usefulness.
871
([#16520](https://github.com/Microsoft/vscode-python/issues/16520))
972

@@ -24,6 +87,10 @@
2487
([#16607](https://github.com/Microsoft/vscode-python/issues/16607))
2588
1. The Jupyter Notebook extension will install any missing dependencies using Poetry or Pipenv if those are the selected environments. (thanks [Anthony Shaw](https://github.com/tonybaloney))
2689
([#16615](https://github.com/Microsoft/vscode-python/issues/16615))
90+
1. Ensure we block on autoselection when no interpreter is explictly set by user.
91+
([#16723](https://github.com/Microsoft/vscode-python/issues/16723))
92+
1. Fix autoselection when opening a python file directly.
93+
([#16733](https://github.com/Microsoft/vscode-python/issues/16733))
2794

2895
### Thanks
2996

news/1 Enhancements/16461.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/client/activation/activationManager.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ export class ExtensionActivationManager implements IExtensionActivationManager {
6161
Promise.all(this.singleActivationServices.map((item) => item.activate())),
6262
this.activateWorkspace(this.activeResourceService.getActiveResource()),
6363
]);
64-
await this.autoSelection.autoSelectInterpreter(undefined);
6564
}
6665

6766
@traceDecorators.error('Failed to activate a workspace')

src/client/common/configSettings.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -679,18 +679,13 @@ export class PythonSettings implements IPythonSettings {
679679
const autoSelectedPythonInterpreter = this.interpreterAutoSelectionService.getAutoSelectedInterpreter(
680680
this.workspaceRoot,
681681
);
682-
if (inExperiment) {
683-
if (autoSelectedPythonInterpreter && this.workspaceRoot) {
684-
this.pythonPath = autoSelectedPythonInterpreter.path;
682+
if (autoSelectedPythonInterpreter) {
683+
this.pythonPath = autoSelectedPythonInterpreter.path;
684+
if (this.workspaceRoot) {
685685
this.interpreterAutoSelectionService
686686
.setWorkspaceInterpreter(this.workspaceRoot, autoSelectedPythonInterpreter)
687687
.ignoreErrors();
688688
}
689-
} else if (autoSelectedPythonInterpreter && this.workspaceRoot) {
690-
this.pythonPath = autoSelectedPythonInterpreter.path;
691-
this.interpreterAutoSelectionService
692-
.setWorkspaceInterpreter(this.workspaceRoot, autoSelectedPythonInterpreter)
693-
.ignoreErrors();
694689
}
695690
}
696691
if (inExperiment && this.pythonPath === DEFAULT_INTERPRETER_SETTING) {
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
'use strict';
5+
6+
import { inject, injectable } from 'inversify';
7+
import { IWorkspaceService } from './application/types';
8+
import { DeprecatePythonPath } from './experiments/groups';
9+
import { IExperimentService, IInterpreterPathProxyService, IInterpreterPathService, Resource } from './types';
10+
import { SystemVariables } from './variables/systemVariables';
11+
12+
@injectable()
13+
export class InterpreterPathProxyService implements IInterpreterPathProxyService {
14+
constructor(
15+
@inject(IInterpreterPathService) private readonly interpreterPathService: IInterpreterPathService,
16+
@inject(IExperimentService) private readonly experiment: IExperimentService,
17+
@inject(IWorkspaceService) private readonly workspace: IWorkspaceService,
18+
) {}
19+
20+
public get(resource: Resource): string {
21+
const systemVariables = new SystemVariables(
22+
undefined,
23+
this.workspace.getWorkspaceFolder(resource)?.uri.fsPath,
24+
this.workspace,
25+
);
26+
const pythonSettings = this.workspace.getConfiguration('python', resource);
27+
return systemVariables.resolveAny(
28+
this.experiment.inExperimentSync(DeprecatePythonPath.experiment)
29+
? this.interpreterPathService.get(resource)
30+
: pythonSettings.get<string>('pythonPath'),
31+
)!;
32+
}
33+
}

src/client/common/serviceRegistry.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
IToolExecutionPath,
2121
IsWindows,
2222
ToolExecutionPath,
23+
IInterpreterPathProxyService,
2324
} from './types';
2425
import { IServiceManager } from '../ioc/types';
2526
import { JupyterExtensionDependencyManager } from '../jupyter/jupyterExtensionDependencyManager';
@@ -118,11 +119,16 @@ import { IMultiStepInputFactory, MultiStepInputFactory } from './utils/multiStep
118119
import { Random } from './utils/random';
119120
import { JupyterNotInstalledNotificationHelper } from '../jupyter/jupyterNotInstalledNotificationHelper';
120121
import { IJupyterNotInstalledNotificationHelper } from '../jupyter/types';
122+
import { InterpreterPathProxyService } from './interpreterPathProxyService';
121123

122124
export function registerTypes(serviceManager: IServiceManager): void {
123125
serviceManager.addSingletonInstance<boolean>(IsWindows, IS_WINDOWS);
124126

125127
serviceManager.addSingleton<IActiveResourceService>(IActiveResourceService, ActiveResourceService);
128+
serviceManager.addSingleton<IInterpreterPathProxyService>(
129+
IInterpreterPathProxyService,
130+
InterpreterPathProxyService,
131+
);
126132
serviceManager.addSingleton<IInterpreterPathService>(IInterpreterPathService, InterpreterPathService);
127133
serviceManager.addSingleton<IExtensions>(IExtensions, Extensions);
128134
serviceManager.addSingleton<IRandom>(IRandom, Random);

src/client/common/types.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,14 @@ export interface IInterpreterPathService {
557557
copyOldInterpreterStorageValuesToNew(resource: Uri | undefined): Promise<void>;
558558
}
559559

560+
/**
561+
* Interface used to access current Interpreter Path
562+
*/
563+
export const IInterpreterPathProxyService = Symbol('IInterpreterPathProxyService');
564+
export interface IInterpreterPathProxyService {
565+
get(resource: Resource): string;
566+
}
567+
560568
export type DefaultLSType = LanguageServerType.Jedi | LanguageServerType.JediLSP | LanguageServerType.Node;
561569

562570
/**

src/client/interpreter/autoSelection/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ export class InterpreterAutoSelectionService implements IInterpreterAutoSelectio
260260
* As such, we can sort interpreters based on what it returns.
261261
*/
262262
private async autoselectInterpreterWithLocators(resource: Resource): Promise<void> {
263-
const interpreters = await this.interpreterService.getInterpreters(resource);
263+
const interpreters = await this.interpreterService.getInterpreters(resource, { ignoreCache: true });
264264
const workspaceUri = this.interpreterHelper.getActiveWorkspaceUri(resource);
265265

266266
// When auto-selecting an intepreter for a workspace, we either want to return a local one

src/client/interpreter/display/index.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ import { Disposable, OutputChannel, StatusBarAlignment, StatusBarItem, Uri } fro
33
import { IApplicationShell, IWorkspaceService } from '../../common/application/types';
44
import { STANDARD_OUTPUT_CHANNEL } from '../../common/constants';
55
import '../../common/extensions';
6-
import { IConfigurationService, IDisposableRegistry, IOutputChannel, IPathUtils, Resource } from '../../common/types';
6+
import {
7+
IDisposableRegistry,
8+
IInterpreterPathProxyService,
9+
IOutputChannel,
10+
IPathUtils,
11+
Resource,
12+
} from '../../common/types';
713
import { Interpreters } from '../../common/utils/localize';
814
import { IServiceContainer } from '../../ioc/types';
915
import { PythonEnvironment } from '../../pythonEnvironments/info';
@@ -22,7 +28,7 @@ export class InterpreterDisplay implements IInterpreterDisplay {
2228
private readonly workspaceService: IWorkspaceService;
2329
private readonly pathUtils: IPathUtils;
2430
private readonly interpreterService: IInterpreterService;
25-
private readonly configService: IConfigurationService;
31+
private readonly interpreterPathExpHelper: IInterpreterPathProxyService;
2632
private currentlySelectedInterpreterPath?: string;
2733
private currentlySelectedWorkspaceFolder: Resource;
2834
private readonly autoSelection: IInterpreterAutoSelectionService;
@@ -39,7 +45,9 @@ export class InterpreterDisplay implements IInterpreterDisplay {
3945

4046
const application = serviceContainer.get<IApplicationShell>(IApplicationShell);
4147
const disposableRegistry = serviceContainer.get<Disposable[]>(IDisposableRegistry);
42-
this.configService = serviceContainer.get<IConfigurationService>(IConfigurationService);
48+
this.interpreterPathExpHelper = serviceContainer.get<IInterpreterPathProxyService>(
49+
IInterpreterPathProxyService,
50+
);
4351

4452
this.statusBar = application.createStatusBarItem(StatusBarAlignment.Left, 100);
4553
this.statusBar.command = 'python.setInterpreter';
@@ -75,7 +83,7 @@ export class InterpreterDisplay implements IInterpreterDisplay {
7583
}
7684
}
7785
private async updateDisplay(workspaceFolder?: Uri) {
78-
const interpreterPath = this.configService.getSettings(workspaceFolder)?.pythonPath;
86+
const interpreterPath = this.interpreterPathExpHelper.get(workspaceFolder);
7987
if (!interpreterPath || interpreterPath === 'python') {
8088
await this.autoSelection.autoSelectInterpreter(workspaceFolder); // Block on this only if no interpreter selected.
8189
}

src/test/activation/activationManager.unit.test.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -456,25 +456,16 @@ suite('Activation Manager', () => {
456456
.setup((s) => s.activate())
457457
.returns(() => Promise.resolve())
458458
.verifiable(typemoq.Times.once());
459-
autoSelection
460-
.setup((a) => a.autoSelectInterpreter(undefined))
461-
.returns(() => Promise.resolve())
462-
.verifiable(typemoq.Times.once());
463459
when(activeResourceService.getActiveResource()).thenReturn(resource);
464460
await managerTest.activate();
465461
assert.ok(initialize.calledOnce);
466462
assert.ok(activateWorkspace.calledOnce);
467463
singleActivationService.verifyAll();
468-
autoSelection.verifyAll();
469464
});
470465

471466
test('Throws error if execution fails', async () => {
472467
singleActivationService
473468
.setup((s) => s.activate())
474-
.returns(() => Promise.resolve())
475-
.verifiable(typemoq.Times.once());
476-
autoSelection
477-
.setup((a) => a.autoSelectInterpreter(undefined))
478469
.returns(() => Promise.reject(new Error('Kaboom')))
479470
.verifiable(typemoq.Times.once());
480471
when(activeResourceService.getActiveResource()).thenReturn(resource);

0 commit comments

Comments
 (0)