public static IEnumerable<PythonInterpreterInformation> PerformDefaultSearch() { var search = new PythonRegistrySearch(); using (var key = Registry.CurrentUser.OpenSubKey("Software\\Python")) { search.Search(key, Environment.Is64BitOperatingSystem ? InterpreterArchitecture.Unknown : InterpreterArchitecture.x86); } using (var root = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32)) using (var key = root.OpenSubKey("Software\\Python")) { search.Search(key, InterpreterArchitecture.x86); } if (Environment.Is64BitOperatingSystem) { using (var root = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64)) using (var key = root.OpenSubKey("Software\\Python")) { search.Search(key, InterpreterArchitecture.x64); } } return search.Interpreters; }
public static IEnumerable <PythonInterpreterInformation> PerformDefaultSearch() { var search = new PythonRegistrySearch(); using (var key = Registry.CurrentUser.OpenSubKey("Software\\Python")) { search.Search(key, Environment.Is64BitOperatingSystem ? InterpreterArchitecture.Unknown : InterpreterArchitecture.x86); } using (var root = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32)) using (var key = root.OpenSubKey("Software\\Python")) { search.Search(key, InterpreterArchitecture.x86); } if (Environment.Is64BitOperatingSystem) { using (var root = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64)) using (var key = root.OpenSubKey("Software\\Python")) { search.Search(key, InterpreterArchitecture.x64); } } return(search.Interpreters); }
internal void DiscoverInterpreterFactories() { if (Volatile.Read(ref _ignoreNotifications) > 0) { return; } // Discover the available interpreters... bool anyChanged = false; PythonRegistrySearch search = null; Dictionary <string, PythonInterpreterInformation> machineFactories = null; try { search = new PythonRegistrySearch(); using (var baseKey = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Default)) using (var root = baseKey.OpenSubKey(PythonPath)) { search.Search( root, Environment.Is64BitOperatingSystem ? InterpreterArchitecture.Unknown : InterpreterArchitecture.x86 ); } machineFactories = new Dictionary <string, PythonInterpreterInformation>(); using (var baseKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32)) using (var root = baseKey.OpenSubKey(PythonPath)) { search.Search( root, InterpreterArchitecture.x86 ); } if (Environment.Is64BitOperatingSystem) { using (var baseKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64)) using (var root = baseKey.OpenSubKey(PythonPath)) { search.Search( root, InterpreterArchitecture.x64 ); } } } catch (ObjectDisposedException) { // We are aborting, so silently return with no results. return; } var found = search.Interpreters .Where(i => !ExcludedVersions.Contains(i.Configuration.Version)) .ToList(); var uniqueIds = new HashSet <string>(found.Select(i => i.Configuration.Id)); // Then update our cached state with the lock held. lock (this) { foreach (var info in found) { 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(); } }
internal void DiscoverInterpreterFactories() { // Discover the available interpreters... bool anyChanged = false; var search = new PythonRegistrySearch(); using (var baseKey = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Default)) using (var root = baseKey.OpenSubKey(PythonPath)) { search.Search( root, Environment.Is64BitOperatingSystem ? InterpreterArchitecture.Unknown : InterpreterArchitecture.x86 ); } Dictionary<string, PythonInterpreterInformation> machineFactories = new Dictionary<string, PythonInterpreterInformation>(); using (var baseKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32)) using (var root = baseKey.OpenSubKey(PythonPath)) { search.Search( root, InterpreterArchitecture.x86 ); } if (Environment.Is64BitOperatingSystem) { using (var baseKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64)) using (var root = baseKey.OpenSubKey(PythonPath)) { search.Search( root, InterpreterArchitecture.x64 ); } } var found = search.Interpreters.ToList(); var uniqueIds = new HashSet<string>(found.Select(i => i.Configuration.Id)); // Then update our cached state with the lock held. lock (this) { foreach (var info in found) { 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(); } }