/// <summary> /// Determines whether two interpreter factories are equivalent. /// </summary> public static bool IsEqual(this IPythonInterpreterFactory x, IPythonInterpreterFactory y) { if (x == null || y == null) { return x == null && y == null; } if (x.GetType() != y.GetType()) { return false; } return x.Configuration.Equals(y.Configuration); }
/// <summary> /// Determines whether two interpreter factories are equivalent. /// </summary> public static bool IsEqual(this IPythonInterpreterFactory x, IPythonInterpreterFactory y) { if (x == null || y == null) { return(x == null && y == null); } if (x.GetType() != y.GetType()) { return(false); } return(x.Configuration.Equals(y.Configuration)); }
public IronPythonInterpreter(IPythonInterpreterFactory factory) { #if DEBUG _id = Interlocked.Increment(ref _interpreterCount); Debug.WriteLine(String.Format("IronPython Interpreter {0} created from {1}", _id, factory.GetType().FullName)); Debug.WriteLine(new StackTrace(true).ToString()); #endif AppDomain.CurrentDomain.AssemblyResolve += AssemblyResolver.Instance.CurrentDomain_AssemblyResolve; InitializeRemoteDomain(); try { LoadAssemblies(); } catch { // IronPython not installed in the GAC... } var mod = Remote.ImportBuiltinModule("__builtin__"); var newMod = new IronPythonBuiltinModule(this, mod, "__builtin__"); _modules[newMod.Name] = newMod; _factory = factory; if (_factory is PythonInterpreterFactoryWithDatabase withDb) { _typeDb = withDb.GetCurrentDatabase().CloneWithNewBuiltins(newMod); withDb.NewDatabaseAvailable += OnNewDatabaseAvailable; } LoadModules(); }
public IronPythonInterpreter(IPythonInterpreterFactory factory) { #if DEBUG _id = Interlocked.Increment(ref _interpreterCount); Debug.WriteLine(String.Format("IronPython Interpreter {0} created from {1}", _id, factory.GetType().FullName)); try { Debug.WriteLine(new StackTrace(true).ToString()); } catch (System.Security.SecurityException) { } #endif _factory = factory; AppDomain.CurrentDomain.AssemblyResolve += AssemblyResolver.Instance.CurrentDomain_AssemblyResolve; InitializeRemoteDomain(); try { LoadAssemblies(); } catch { // IronPython not installed in the GAC... } var mod = Remote.ImportBuiltinModule("__builtin__"); var newMod = new IronPythonBuiltinModule(this, mod, "__builtin__"); _modules[newMod.Name] = _builtinModule = newMod; LoadModules(); }
private async Task CheckPackagesAsync() { var uiThread = ProjectMgr.Site.GetUIThread(); uiThread.MustBeCalledFromUIThreadOrThrow(); bool prevChecked = _checkedItems; // Use _checkingItems to prevent the expanded state from // disappearing too quickly. _checkingItems = true; _checkedItems = true; if (!Directory.Exists(_factory.Configuration.LibraryPath)) { _checkingItems = false; ProjectMgr.OnPropertyChanged(this, (int)__VSHPROPID.VSHPROPID_Expandable, 0); return; } HashSet <string> lines; bool anyChanges = false; try { lines = await Pip.List(_factory).ConfigureAwait(true); } catch (NoInterpretersException) { return; } // Ensure we are back on the UI thread uiThread.MustBeCalledFromUIThread(); if (ProjectMgr == null || ProjectMgr.IsClosed) { return; } var existing = AllChildren.ToDictionary(c => c.Url); // remove the nodes which were uninstalled. foreach (var keyValue in existing) { if (!lines.Contains(keyValue.Key)) { RemoveChild(keyValue.Value); anyChanges = true; } } // remove already existing nodes so we don't add them a 2nd time lines.ExceptWith(existing.Keys); // add the new nodes foreach (var line in lines) { AddChild(new InterpretersPackageNode(ProjectMgr, line)); anyChanges = true; var packageInfo = PythonProjectNode.FindRequirementRegex.Match(line.ToLower()); if (packageInfo.Groups["name"].Success) { //Log the details of the Installation var packageDetails = new Logging.PackageInstallDetails( packageInfo.Groups["name"].Value, packageInfo.Groups["ver"].Success ? packageInfo.Groups["ver"].Value : String.Empty, _factory.GetType().Name, _factory.Configuration.Version.ToString(), _factory.Configuration.Architecture.ToString(), "Existing", //Installer if we tracked it false, //Installer was not run elevated 0); //The installation already existed ProjectMgr.Site.GetPythonToolsService().Logger.LogEvent(Logging.PythonLogEvent.PackageInstalled, packageDetails); } } _checkingItems = false; ProjectMgr.OnInvalidateItems(this); if (!prevChecked) { if (anyChanges) { ProjectMgr.OnPropertyChanged(this, (int)__VSHPROPID.VSHPROPID_Expandable, 0); } if (ProjectMgr.ParentHierarchy != null) { ExpandItem(EXPANDFLAGS.EXPF_CollapseFolder); } } if (prevChecked && anyChanges) { var withDb = _factory as IPythonInterpreterFactoryWithDatabase; if (withDb != null) { withDb.GenerateDatabase(GenerateDatabaseOptions.SkipUnchanged); } } }