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(); } }
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() { // 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(); } }