Beispiel #1
0
        internal static IPythonInterpreterFactory CreateVirtualEnvironment(string pythonVersion, VisualStudioApp app, PythonProjectNode pyProj)
        {
            var uiThread = app.ServiceProvider.GetUIThread();
            var task     = uiThread.InvokeTask(() => {
                var model           = app.GetService <IComponentModel>(typeof(SComponentModel));
                var registryService = model.GetService <IInterpreterRegistryService>();
                var optionsService  = model.GetService <IInterpreterOptionsService>();

                return(VirtualEnv.CreateAndAddFactory(
                           app.ServiceProvider,
                           registryService,
                           optionsService,
                           pyProj,
                           null,
                           Path.Combine(pyProj.ProjectHome, "env"),
                           registryService.FindInterpreter("Global|PythonCore|" + pythonVersion + "-32"),
                           false,
                           null,
                           Version.Parse(pythonVersion) >= new Version(3, 3)
                           ));
            });

            try {
                Assert.IsTrue(task.Wait(TimeSpan.FromMinutes(2.0)), "Timed out waiting for venv");
            } catch (AggregateException ex) {
                ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
            }
            var factory = task.Result;

            Assert.IsTrue(uiThread.Invoke(() => factory.Configuration.Id == pyProj.GetInterpreterFactory().Configuration.Id));
            return(factory);
        }