private void EnsureActivated() { if (_activatedEnvironmentVariables == null) { var prefixPath = _factory.Configuration.GetPrefixPath(); if (_condaLocatorProvider != null && Directory.Exists(prefixPath) && CondaUtils.IsCondaEnvironment(prefixPath)) { var rootConda = _condaLocatorProvider.FindLocator()?.CondaExecutablePath; if (File.Exists(rootConda)) { var env = CondaUtils.CaptureActivationEnvironmentVariablesForPrefix(rootConda, prefixPath); _activatedEnvironmentVariables = env.Union(UnbufferedEnv).ToArray(); } else { // Normally, the root is required for this environment to have been discovered, // but it could be that the user added this as a custom environment and then // uninstalled the root. When that's the case, there is no way to activate, // so proceed without activation env variables. _activatedEnvironmentVariables = UnbufferedEnv; } } else { // Not a conda environment, no activation necessary. _activatedEnvironmentVariables = UnbufferedEnv; } } }
private async Task <KeyValuePair <string, string>[]> GetEnvironmentVariables() { var prefixPath = _factory.Configuration.GetPrefixPath(); if (_condaLocatorProvider != null && Directory.Exists(prefixPath) && CondaUtils.IsCondaEnvironment(prefixPath)) { var rootConda = _condaLocatorProvider.FindLocator()?.CondaExecutablePath; if (File.Exists(rootConda)) { var env = await CondaUtils.GetActivationEnvironmentVariablesForPrefixAsync(rootConda, prefixPath); return(env.Union(UnbufferedEnv).ToArray()); } else { // Normally, the root is required for this environment to have been discovered, // but it could be that the user added this as a custom environment and then // uninstalled the root. When that's the case, there is no way to activate, // so proceed without activation env variables. return(UnbufferedEnv); } } else { // Not a conda environment, no activation necessary. return(UnbufferedEnv); } }
private void FindCondaEnvironments(List <PythonInterpreterInformation> envs) { var mainCondaExePath = _condaLocatorProvider?.FindLocator()?.CondaExecutablePath; if (!string.IsNullOrEmpty(mainCondaExePath)) { envs.AddRange(FindCondaEnvironments(mainCondaExePath)); } }
private async Task <IReadOnlyList <PythonInterpreterInformation> > FindCondaEnvironments() { var mainCondaExePath = _condaLocatorProvider?.FindLocator()?.CondaExecutablePath; if (!string.IsNullOrEmpty(mainCondaExePath)) { return(await FindCondaEnvironments(mainCondaExePath)); } return(Enumerable.Empty <PythonInterpreterInformation>().ToList().AsReadOnly()); }