本文整理汇总了C#中PythonProjectNode.GetInterpreterFactory方法的典型用法代码示例。如果您正苦于以下问题:C# PythonProjectNode.GetInterpreterFactory方法的具体用法?C# PythonProjectNode.GetInterpreterFactory怎么用?C# PythonProjectNode.GetInterpreterFactory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PythonProjectNode
的用法示例。
在下文中一共展示了PythonProjectNode.GetInterpreterFactory方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddVirtualEnvironmentView
public AddVirtualEnvironmentView(
PythonProjectNode project,
IInterpreterRegistryService interpreterService,
IPythonInterpreterFactory selectInterpreter
) {
_interpreterService = interpreterService;
_project = project;
VirtualEnvBasePath = _projectHome = project.ProjectHome;
Interpreters = new ObservableCollection<InterpreterView>(InterpreterView.GetInterpreters(project.Site, project));
var selection = Interpreters.FirstOrDefault(v => v.Interpreter == selectInterpreter);
if (selection == null) {
selection = Interpreters.FirstOrDefault(v => v.Interpreter == project.GetInterpreterFactory())
?? Interpreters.LastOrDefault();
}
BaseInterpreter = selection;
_project.InterpreterFactoriesChanged += OnInterpretersChanged;
var venvName = "env";
for (int i = 1; Directory.Exists(Path.Combine(_projectHome, venvName)); ++i) {
venvName = "env" + i.ToString();
}
VirtualEnvName = venvName;
CanInstallRequirementsTxt = File.Exists(PathUtils.GetAbsoluteFilePath(_projectHome, "requirements.txt"));
WillInstallRequirementsTxt = CanInstallRequirementsTxt;
}
示例2: CreateVirtualEnvironment
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 service = model.GetService<IInterpreterRegistryService>();
return pyProj.CreateOrAddVirtualEnvironment(
service,
true,
Path.Combine(pyProj.ProjectHome, "env"),
service.FindInterpreter("Global|PythonCore|" + pythonVersion + "-32"),
Version.Parse(pythonVersion) >= new Version(3, 3)
);
});
try {
Assert.IsTrue(task.Wait(TimeSpan.FromMinutes(2.0)), "Timed out waiting for venv");
} catch (AggregateException ex) {
throw ex.InnerException;
}
var factory = task.Result;
Assert.IsTrue(uiThread.Invoke(() => factory.Configuration.Id == pyProj.GetInterpreterFactory().Configuration.Id));
return factory;
}