自动化 PyDev 解释器设置

发布于 2024-10-12 04:53:52 字数 141 浏览 8 评论 0原文

我有一个场景,我希望能够自动设置在 PyDev 中使用的各种 Python 解释器。这些解释器具有特殊的环境变量、强制内置函数和定义的库。有没有办法通过 .ini 文件或通过 PyDev / Jython API 以编程方式为 PyDev 定义 Python 解释器?

I have a scenario where I want to be able automate the setting up of various Python interpreters for use in PyDev. These interpreters have special environment variables, forced built-ins and libraries defined. Is there a way through perhaps an .ini file or through the PyDev / Jython API to programmatically define Python interpreters for PyDev?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

染墨丶若流云 2024-10-19 04:53:53

在 Java API 中,它是这样的:

IInterpreterManager manager = PydevPlugin.getPythonInterpreterManager(true);
manager.setInfos(exesList, interpreterNamesToRestore, monitor);

exesList 是 org.python.pydev.ui.pythonpathconf.InterpreterInfo 的列表,而 interpreterNamesToRestore 是已更改的解释器的列表(即:应该恢复 pythonpath)。

您可能可以从 Jython 执行此操作,但 PyDev 没有提供您可以执行此操作的钩子(即:它只提供用于设置编辑器的钩子),因此,现在最好的解决方案是创建一个简单的 eclipse 插件有一个 EarlyStartup 来执行您想要的配置(应该很简单)。

In the Java API it's something as:

IInterpreterManager manager = PydevPlugin.getPythonInterpreterManager(true);
manager.setInfos(exesList, interpreterNamesToRestore, monitor);

The exesList is a list of org.python.pydev.ui.pythonpathconf.InterpreterInfo and the interpreterNamesToRestore a list of the interpreters that were changed (i.e.: should have the pythonpath restored).

You could probably do this from Jython, but PyDev provides no hooks where you'd be able to do that (i.e.: it only provides hooks for setting up an editor), so, the best solution right now would be creating a simple eclipse plugin that had an earlyStartup to do the configuration you want (should be straightforward).

墨小沫ゞ 2024-10-19 04:53:53

不久前,我对 Eclipse 插件互相争斗并破坏了“原始”设置感到沮丧,所以我四处挖掘并发现了这些漂亮的花絮:

Eclipse 运行时选项(用于运行否则会被捕获的内容的 cli 选项-UI 功能。

运行 Eclipse 的更新因此

,如果您仔细阅读一下运行时选项,您会发现..

eclipse.pluginCustomization {-pluginCustomization}
the file system location of a properties file containing default settings for 
plug-in preferences. These default settings override default settings 
specified in the primary feature. Relative paths are interpreted relative 
to the current working directory for Eclipse itself.

这可能会做您想要的事情。

I had this same question a while back after getting frustrated with Eclipse plug-ins fighting each other and ruining otherwise 'pristine' setups so I dug around and found these nifty tidbits:

Eclipse run-time options (cli options for running what would otherwise be captive-UI features.

Running Eclipse's update manager from the CLI

So, if you read through the run-time options a bit, you'll come across..

eclipse.pluginCustomization {-pluginCustomization}
the file system location of a properties file containing default settings for 
plug-in preferences. These default settings override default settings 
specified in the primary feature. Relative paths are interpreted relative 
to the current working directory for Eclipse itself.

Which will probably do what you want.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文