/// <summary> /// Installs virtualenv. If pip is not installed, the returned task will /// succeed but error text will be passed to the redirector. /// </summary> public static Task <bool> Install(IServiceProvider provider, IPythonInterpreterFactory factory) { var ui = new VsPackageManagerUI(provider); var interpreterOpts = provider.GetComponentModel().GetService <IInterpreterOptionsService>(); var pm = interpreterOpts?.GetPackageManagers(factory).FirstOrDefault(p => p.UniqueKey == "pip"); if (factory.Configuration.Version < new Version(2, 5)) { ui.OnErrorTextReceived(null, "Python versions earlier than 2.5 are not supported by PTVS.\n"); throw new OperationCanceledException(); } else if (pm == null) { ui.OnErrorTextReceived(null, Strings.PackageManagementNotSupported_Package.FormatUI("virtualenv")); throw new OperationCanceledException(); } else if (factory.Configuration.Version == new Version(2, 5)) { return(pm.InstallAsync(PackageSpec.FromArguments("https://go.microsoft.com/fwlink/?LinkID=317970"), ui, CancellationToken.None)); } else { return(pm.InstallAsync(PackageSpec.FromArguments("https://go.microsoft.com/fwlink/?LinkID=317969"), ui, CancellationToken.None)); } }
/// <summary> /// Installs virtualenv. If pip is not installed, the returned task will /// succeed but error text will be passed to the redirector. /// </summary> public static Task<bool> Install(IServiceProvider provider, IPythonInterpreterFactory factory) { var ui = new VsPackageManagerUI(provider); if (factory.Configuration.Version < new Version(2, 5)) { ui.OnErrorTextReceived(null, "Python versions earlier than 2.5 are not supported by PTVS.\n"); throw new OperationCanceledException(); } else if (factory.PackageManager == null) { ui.OnErrorTextReceived(null, Strings.PackageManagementNotSupported_Package.FormatUI("virtualenv")); throw new OperationCanceledException(); } else if (factory.Configuration.Version == new Version(2, 5)) { return factory.PackageManager.InstallAsync(PackageSpec.FromArguments("https://go.microsoft.com/fwlink/?LinkID=317970"), ui, CancellationToken.None); } else { return factory.PackageManager.InstallAsync(PackageSpec.FromArguments("https://go.microsoft.com/fwlink/?LinkID=317969"), ui, CancellationToken.None); } }
/// <summary> /// Installs virtualenv. If pip is not installed, the returned task will /// succeed but error text will be passed to the redirector. /// </summary> public static Task <bool> Install(IServiceProvider provider, IPythonInterpreterFactory factory) { var ui = new VsPackageManagerUI(provider); if (factory.Configuration.Version < new Version(2, 5)) { ui.OnErrorTextReceived("Python versions earlier than 2.5 are not supported by PTVS.\n"); throw new OperationCanceledException(); } else if (factory.PackageManager == null) { ui.OnErrorTextReceived(Strings.PackageManagementNotSupported_Package.FormatUI("virtualenv")); throw new OperationCanceledException(); } else if (factory.Configuration.Version == new Version(2, 5)) { return(factory.PackageManager.InstallAsync(PackageSpec.FromArguments("https://go.microsoft.com/fwlink/?LinkID=317970"), ui, CancellationToken.None)); } else { return(factory.PackageManager.InstallAsync(PackageSpec.FromArguments("https://go.microsoft.com/fwlink/?LinkID=317969"), ui, CancellationToken.None)); } }