private async Task ApplyExistingAsync() { if (SelectedProject.Node != null) { var ids = SelectedProject.InterpreterIds.Union(new string[] { SelectedInterpreter.Id }).ToArray(); SelectedProject?.Node.ChangeInterpreters(ids); } else if (SelectedProject.Workspace != null) { var factory = RegistryService.FindInterpreter(SelectedInterpreter.Id); if (factory != null) { await SelectedProject.Workspace.SetInterpreterFactoryAsync(factory); } } }
internal async Task UpdateInterpreterAsync(InterpreterView interpreterView) { if (!Dispatcher.CheckAccess()) { await Dispatcher.InvokeAsync(() => UpdateInterpreterAsync(interpreterView)); return; } try { await _ready.WaitAsync(); } catch (ObjectDisposedException) { return; } Progress.IsProgressDisplayed = true; IsAcceptEnabled = false; try { WillInstallPip = false; WillInstallVirtualEnv = false; WillRegisterGlobally = false; UseVEnv = false; UseVirtualEnv = false; IsAcceptShieldVisible = false; if (interpreterView == null) { return; } var interp = RegistryService.FindInterpreter(interpreterView.Id); Debug.Assert(interp != null); if (interp == null) { return; } RefreshCanCreateVirtualEnv(); if (await interp.HasModuleAsync("venv", OptionsService)) { WillInstallPip = false; WillInstallVirtualEnv = false; UseVEnv = true; UseVirtualEnv = false; } else if (await interp.HasModuleAsync("virtualenv", OptionsService)) { WillInstallPip = false; WillInstallVirtualEnv = false; UseVEnv = false; UseVirtualEnv = true; } else { WillInstallPip = await interp.HasModuleAsync("pip", OptionsService); WillInstallVirtualEnv = true; UseVEnv = false; UseVirtualEnv = true; } IsAcceptShieldVisible = (WillInstallPip || WillInstallVirtualEnv) && Site.GetPythonToolsService().GeneralOptions.ElevatePip; } finally { try { _ready.Release(); } catch (ObjectDisposedException) { } Progress.IsProgressDisplayed = false; RefreshCanCreateVirtualEnv(); } }