private void DiscoverInterpreterFactories() { if (Volatile.Read(ref _ignoreNotifications) > 0) { return; } DiscoveryStarted?.Invoke(this, EventArgs.Empty); // Discover the available interpreters... bool anyChanged = false; List <PythonInterpreterInformation> found = null; try { // Try to find an existing root conda installation // If the future we may decide to install a private installation of conda/miniconda var globalFactories = _globalProvider.GetInterpreterFactories().ToList(); var mainCondaExePath = CondaUtils.GetLatestCondaExecutablePath(globalFactories); if (mainCondaExePath != null) { found = FindCondaEnvironments(mainCondaExePath).ToList(); } } catch (ObjectDisposedException) { // We are aborting, so silently return with no results. return; } var uniqueIds = new HashSet <string>(found.Select(i => i.Configuration.Id)); // Then update our cached state with the lock held. lock (_factories) { foreach (var info in found.MaybeEnumerate()) { PythonInterpreterInformation existingInfo; if (!_factories.TryGetValue(info.Configuration.Id, out existingInfo) || info.Configuration != existingInfo.Configuration) { _factories[info.Configuration.Id] = info; anyChanged = true; } } // Remove any factories we had before and no longer see... foreach (var unregistered in _factories.Keys.Except(uniqueIds).ToArray()) { _factories.Remove(unregistered); anyChanged = true; } } if (anyChanged) { OnInterpreterFactoriesChanged(); } }
public CPythonCondaPackageManagerProvider( [Import] CPythonInterpreterFactoryProvider globalProvider ) { _globalProvider = globalProvider; // This can be slow, if there are 2 or more global conda installations // (some conda versions have long startup time), so we only fetch it once. _latestCondaExe = new Lazy <string>(() => CondaUtils.GetLatestCondaExecutablePath(_globalProvider.GetInterpreterFactories())); }
private void FindCondaEnvironments(List <PythonInterpreterInformation> envs) { // Try to find an existing root conda installation // If the future we may decide to install a private installation of conda/miniconda var globalFactories = _globalProvider.GetInterpreterFactories().ToList(); var mainCondaExePath = CondaUtils.GetLatestCondaExecutablePath(globalFactories); if (mainCondaExePath != null) { envs.AddRange(FindCondaEnvironments(mainCondaExePath)); } }
public static CondaEnvironmentManager Create(IInterpreterRegistryService registry) { if (registry == null) { throw new ArgumentNullException(nameof(registry)); } var condaPath = CondaUtils.GetLatestCondaExecutablePath(registry.Interpreters); if (!string.IsNullOrEmpty(condaPath)) { return(new CondaEnvironmentManager(condaPath)); } return(null); }