Skip to content

Commit 7ee8309

Browse files
authored
Cherry pick inhertEnv and disable debug adapter experiment into release (#8129)
1 parent 48fe766 commit 7ee8309

File tree

12 files changed

+191
-88
lines changed

12 files changed

+191
-88
lines changed

experiments.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,26 +32,26 @@
3232
{
3333
"name": "DebugAdapterFactory - control",
3434
"salt": "DebugAdapterFactory",
35-
"min": 80,
36-
"max": 90
35+
"min": 0,
36+
"max": 0
3737
},
3838
{
3939
"name": "DebugAdapterFactory - experiment",
4040
"salt": "DebugAdapterFactory",
41-
"min": 10,
42-
"max": 20
41+
"min": 0,
42+
"max": 0
4343
},
4444
{
4545
"name": "PtvsdWheels37 - control",
4646
"salt": "DebugAdapterFactory",
47-
"min": 87,
48-
"max": 90
47+
"min": 0,
48+
"max": 0
4949
},
5050
{
5151
"name": "PtvsdWheels37 - experiment",
5252
"salt": "DebugAdapterFactory",
53-
"min": 10,
54-
"max": 13
53+
"min": 0,
54+
"max": 0
5555
},
5656
{
5757
"name": "LS - enabled",

news/2 Fixes/7836.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Do not use the PTVSD package version in the folder name for the wheel experiment.

package.nls.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,11 @@
121121
"Experiments.inGroup": "User belongs to experiment group '{0}'",
122122
"Interpreters.RefreshingInterpreters": "Refreshing Python Interpreters",
123123
"Interpreters.LoadingInterpreters": "Loading Python Interpreters",
124-
"Interpreters.condaInheritEnvMessage": "We noticed you're using a conda environment. If you are experiencing issues with this environment in the integrated terminal, we suggest the \"terminal.integrated.inheritEnv\" setting to be changed to false. Would you like to update this setting?",
124+
"Interpreters.condaInheritEnvMessage": "We noticed you're using a conda environment. If you are experiencing issues with this environment in the integrated terminal, we recommend that you let the Python extension change \"terminal.integrated.inheritEnv\" to false in your user settings.",
125125
"Logging.CurrentWorkingDirectory": "cwd:",
126126
"Common.doNotShowAgain": "Do not show again",
127127
"Common.reload": "Reload",
128+
"Common.moreInfo": "More Info",
128129
"OutputChannelNames.languageServer": "Python Language Server",
129130
"OutputChannelNames.python": "Python",
130131
"OutputChannelNames.pythonTest": "Python Test Log",

pythonFiles/install_ptvsd.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ def install_ptvsd():
4040
# Download only if it's a 3.7 wheel.
4141
if not wheel_info["python_version"].endswith(("37", "3.7")):
4242
continue
43-
filename = wheel_info["filename"].rpartition(".")[0] # Trim the file extension.
43+
44+
# Trim the file extension and remove the ptvsd version from the folder name.
45+
filename = wheel_info["filename"].rpartition(".")[0]
46+
filename = filename.replace(f"{version}-", "")
4447
ptvsd_path = path.join(PYTHONFILES, filename)
4548

4649
with urllib.request.urlopen(wheel_info["url"]) as wheel_response:

pythonFiles/ptvsd_folder_name.py

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@
66

77
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
88
PYTHONFILES = os.path.join(ROOT, "pythonFiles", "lib", "python")
9-
REQUIREMENTS = os.path.join(ROOT, "requirements.txt")
109

1110
sys.path.insert(0, PYTHONFILES)
1211

13-
from packaging.requirements import Requirement
1412
from packaging.tags import sys_tags
1513

1614
sys.path.remove(PYTHONFILES)
@@ -19,23 +17,9 @@
1917
def ptvsd_folder_name():
2018
"""Return the folder name for the bundled PTVSD wheel compatible with the new debug adapter."""
2119

22-
with open(REQUIREMENTS, "r", encoding="utf-8") as reqsfile:
23-
for line in reqsfile:
24-
pkgreq = Requirement(line)
25-
if pkgreq.name == "ptvsd":
26-
specs = pkgreq.specifier
27-
try:
28-
spec, = specs
29-
version = spec.version
30-
except:
31-
# Fallpack to use base PTVSD path.
32-
print(PYTHONFILES, end="")
33-
return
34-
break
35-
3620
try:
3721
for tag in sys_tags():
38-
folder_name = f"ptvsd-{version}-{tag.interpreter}-{tag.abi}-{tag.platform}"
22+
folder_name = f"ptvsd-{tag.interpreter}-{tag.abi}-{tag.platform}"
3923
folder_path = os.path.join(PYTHONFILES, folder_name)
4024
if os.path.exists(folder_path):
4125
print(folder_path, end="")

pythonFiles/tests/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,3 @@
1010
DEBUG_ADAPTER_ROOT = os.path.join(SRC_ROOT, "debug_adapter")
1111

1212
PYTHONFILES = os.path.join(SRC_ROOT, "lib", "python")
13-
REQUIREMENTS = os.path.join(PROJECT_ROOT, "requirements.txt")

pythonFiles/tests/debug_adapter/test_ptvsd_folder_name.py

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -15,64 +15,36 @@
1515
from packaging.tags import sys_tags
1616
from ptvsd_folder_name import ptvsd_folder_name
1717

18-
from .. import PYTHONFILES, REQUIREMENTS
19-
20-
21-
def open_requirements_with_ptvsd():
22-
return patch(
23-
"ptvsd_folder_name.open", mock_open(read_data="jedi==0.15.1\nptvsd==5.0.0")
24-
)
25-
26-
27-
def open_requirements_without_ptvsd():
28-
return patch("ptvsd_folder_name.open", mock_open(read_data="jedi==0.15.1\n"))
18+
from .. import PYTHONFILES
2919

3020

3121
class TestPtvsdFolderName:
3222
"""Unit tests for the script retrieving the PTVSD folder name for the PTVSD wheels experiment."""
3323

34-
def test_requirement_exists_folder_exists(self, capsys):
24+
def test_folder_exists(self, capsys):
3525
# Return the first constructed folder path as existing.
3626

3727
patcher = patch("os.path.exists")
3828
mock_exists = patcher.start()
3929
mock_exists.side_effect = lambda p: True
4030
tag = next(sys_tags())
41-
folder = "ptvsd-5.0.0-{}-{}-{}".format(tag.interpreter, tag.abi, tag.platform)
31+
folder = "ptvsd-{}-{}-{}".format(tag.interpreter, tag.abi, tag.platform)
4232

43-
with open_requirements_with_ptvsd():
44-
ptvsd_folder_name()
33+
ptvsd_folder_name()
4534

4635
patcher.stop()
4736
expected = os.path.join(PYTHONFILES, folder)
4837
captured = capsys.readouterr()
4938
assert captured.out == expected
5039

51-
def test_ptvsd_requirement_once(self):
52-
reqs = [
53-
line
54-
for line in open(REQUIREMENTS, "r", encoding="utf-8")
55-
if re.match("ptvsd==", line)
56-
]
57-
assert len(reqs) == 1
58-
59-
def test_no_ptvsd_requirement(self, capsys):
60-
with open_requirements_without_ptvsd() as p:
61-
ptvsd_folder_name()
62-
63-
expected = PYTHONFILES
64-
captured = capsys.readouterr()
65-
assert captured.out == expected
66-
6740
def test_no_wheel_folder(self, capsys):
6841
# Return none of of the constructed paths as existing,
6942
# ptvsd_folder_name() should return the path to default ptvsd.
7043
patcher = patch("os.path.exists")
7144
mock_no_exist = patcher.start()
7245
mock_no_exist.side_effect = lambda p: False
7346

74-
with open_requirements_with_ptvsd() as p:
75-
ptvsd_folder_name()
47+
ptvsd_folder_name()
7648

7749
patcher.stop()
7850
expected = PYTHONFILES

pythonFiles/tests/debug_adapter/test_ptvsd_folder_name_functional.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,15 @@
1313
import subprocess
1414

1515
from packaging.requirements import Requirement
16-
from .. import PYTHONFILES, REQUIREMENTS, SRC_ROOT
16+
from .. import PYTHONFILES, SRC_ROOT
1717

1818
ARGV = ["python", os.path.join(SRC_ROOT, "ptvsd_folder_name.py")]
19-
PREFIX = "ptvsd=="
20-
21-
with open(REQUIREMENTS, "r", encoding="utf-8") as reqsfile:
22-
for line in reqsfile:
23-
if line.startswith(PREFIX):
24-
VERSION = line[len(PREFIX) :].strip()
25-
break
2619

2720

2821
def ptvsd_paths(*platforms):
2922
paths = set()
3023
for platform in platforms:
31-
folder = "ptvsd-{}-cp37-cp37m-{}".format(VERSION, platform)
24+
folder = "ptvsd-cp37-cp37m-{}".format(platform)
3225
paths.add(os.path.join(PYTHONFILES, folder))
3326
return paths
3427

src/client/common/utils/localize.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export namespace Common {
3333
export const notNow = localize('Common.notNow', 'Not now');
3434
export const doNotShowAgain = localize('Common.doNotShowAgain', 'Do not show again');
3535
export const reload = localize('Common.reload', 'Reload');
36+
export const moreInfo = localize('Common.moreInfo', 'More Info');
3637
}
3738

3839
export namespace LanguageService {
@@ -60,7 +61,7 @@ export namespace Experiments {
6061
export namespace Interpreters {
6162
export const loading = localize('Interpreters.LoadingInterpreters', 'Loading Python Interpreters');
6263
export const refreshing = localize('Interpreters.RefreshingInterpreters', 'Refreshing Python Interpreters');
63-
export const condaInheritEnvMessage = localize('Interpreters.condaInheritEnvMessage', 'We noticed you\'re using a conda environment. If you are experiencing issues with this environment in the integrated terminal, we suggest the \"terminal.integrated.inheritEnv\" setting to be changed to false. Would you like to update this setting?');
64+
export const condaInheritEnvMessage = localize('Interpreters.condaInheritEnvMessage', 'We noticed you\'re using a conda environment. If you are experiencing issues with this environment in the integrated terminal, we recommend that you let the Python extension change \"terminal.integrated.inheritEnv\" to false in your user settings.');
6465
export const environmentPromptMessage = localize('Interpreters.environmentPromptMessage', 'We noticed a new virtual environment has been created. Do you want to select it for the workspace folder?');
6566
export const selectInterpreterTip = localize('Interpreters.selectInterpreterTip', 'Tip: you can change the Python interpreter used by the Python extension by clicking on the Python version in the status bar');
6667
}

src/client/interpreter/virtualEnvs/condaInheritEnvPrompt.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ import { ConfigurationTarget, Uri } from 'vscode';
66
import { IExtensionActivationService } from '../../activation/types';
77
import { IApplicationShell, IWorkspaceService } from '../../common/application/types';
88
import { traceDecorators, traceError } from '../../common/logger';
9-
import { IPersistentStateFactory } from '../../common/types';
10-
import { InteractiveShiftEnterBanner, Interpreters } from '../../common/utils/localize';
9+
import { IPlatformService } from '../../common/platform/types';
10+
import { IBrowserService, IPersistentStateFactory } from '../../common/types';
11+
import { Common, InteractiveShiftEnterBanner, Interpreters } from '../../common/utils/localize';
1112
import { sendTelemetryEvent } from '../../telemetry';
1213
import { EventName } from '../../telemetry/constants';
1314
import { IInterpreterService, InterpreterType } from '../contracts';
@@ -19,10 +20,12 @@ export class CondaInheritEnvPrompt implements IExtensionActivationService {
1920
constructor(
2021
@inject(IInterpreterService) private readonly interpreterService: IInterpreterService,
2122
@inject(IWorkspaceService) private readonly workspaceService: IWorkspaceService,
23+
@inject(IBrowserService) private browserService: IBrowserService,
2224
@inject(IApplicationShell) private readonly appShell: IApplicationShell,
2325
@inject(IPersistentStateFactory) private readonly persistentStateFactory: IPersistentStateFactory,
26+
@inject(IPlatformService) private readonly platformService: IPlatformService,
2427
@optional() public hasPromptBeenShownInCurrentSession: boolean = false
25-
) { }
28+
) {}
2629

2730
public async activate(resource: Uri): Promise<void> {
2831
this.initializeInBackground(resource).ignoreErrors();
@@ -43,8 +46,8 @@ export class CondaInheritEnvPrompt implements IExtensionActivationService {
4346
if (!notificationPromptEnabled.value) {
4447
return;
4548
}
46-
const prompts = [InteractiveShiftEnterBanner.bannerLabelYes(), InteractiveShiftEnterBanner.bannerLabelNo()];
47-
const telemetrySelections: ['Yes', 'No'] = ['Yes', 'No'];
49+
const prompts = [InteractiveShiftEnterBanner.bannerLabelYes(), InteractiveShiftEnterBanner.bannerLabelNo(), Common.moreInfo()];
50+
const telemetrySelections: ['Yes', 'No', 'More Info'] = ['Yes', 'No', 'More Info'];
4851
const selection = await this.appShell.showInformationMessage(Interpreters.condaInheritEnvMessage(), ...prompts);
4952
sendTelemetryEvent(EventName.CONDA_INHERIT_ENV_PROMPT, undefined, { selection: selection ? telemetrySelections[prompts.indexOf(selection)] : undefined });
5053
if (!selection) {
@@ -54,6 +57,8 @@ export class CondaInheritEnvPrompt implements IExtensionActivationService {
5457
await this.workspaceService.getConfiguration('terminal').update('integrated.inheritEnv', false, ConfigurationTarget.Global);
5558
} else if (selection === prompts[1]) {
5659
await notificationPromptEnabled.updateValue(false);
60+
} else if (selection === prompts[2]) {
61+
this.browserService.launch('https://aka.ms/AA66i8f');
5762
}
5863
}
5964

@@ -62,6 +67,9 @@ export class CondaInheritEnvPrompt implements IExtensionActivationService {
6267
if (this.hasPromptBeenShownInCurrentSession) {
6368
return false;
6469
}
70+
if (this.platformService.isWindows) {
71+
return false;
72+
}
6573
const interpreter = await this.interpreterService.getActiveInterpreter(resource);
6674
if (!interpreter || interpreter.type !== InterpreterType.Conda) {
6775
return false;

0 commit comments

Comments
 (0)