在PyDev Eclipse项目文件中使用环境变量 [英] Use environment variable in PyDev Eclipse project file

查看:166
本文介绍了在PyDev Eclipse项目文件中使用环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Eclipse 3.6.1与PyDev 1.6.4开发Google App Engine网站。在我的项目中 .pydevproject 我想根据环境变量设置Google App Engine SDK的路径,因为我在桌面和笔记本电脑上开发(路径略有不同) ),我打算将这个文件检查到源代码管理中,其他环境可能会有所不同。在下面的XML中,我想用从环境变量读取的值替换 / home / jesse 。现在,我将很高兴只使用当前的主目录。

I am using Eclipse 3.6.1 with PyDev 1.6.4 for developing a Google App Engine site. In my projects .pydevproject I want to set the path to the Google App Engine SDK based off an environment variable since I develop on my desktop and laptop (where the paths are slightly different) and I plan to check this file into source control and others environment may be different. In the XML below, I want to replace /home/jesse with the value read from an environment variable. For now I would be happy just using the current home directory.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?eclipse-pydev version="1.0"?>
<pydev_project>
  <pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Python 2.5</pydev_property>
  <pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.5</pydev_property>
  <pydev_variables_property name="org.python.pydev.PROJECT_VARIABLE_SUBSTITUTION">
    <key>GOOGLE_APP_ENGINE</key>
    <value>/home/jesse/projects/google_appengine</value>
  </pydev_variables_property>
  <pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
    <path>/app_html5rest</path>
  </pydev_pathproperty>
  <pydev_pathproperty name="org.python.pydev.PROJECT_EXTERNAL_SOURCE_PATH">
    <path>${GOOGLE_APP_ENGINE}</path>
    <path>${GOOGLE_APP_ENGINE}/lib/django</path>
    <path>${GOOGLE_APP_ENGINE}/lib/webob</path>
    <path>${GOOGLE_APP_ENGINE}/lib/yaml/lib</path>
  </pydev_pathproperty>
</pydev_project>

我尝试过:


  • $ {HOME}

  • $ {env.HOME}

  • $ HOME

Google还没有提出任何建议?

Google has not turned up much, any suggestions?

推荐答案

其实,现在你可以做的是使用字符串替换,然后将其设置在您正在使用的解释器(在窗口>首选项> pydev>解释器 - python>字符串替换变量) - 这样你可以有不同的变量每个解释器。 ..哪个IMO比在全球范围内更好。

Actually, right now what you can do is use a string substitution there and then set it in the interpreter you're using (In window > preferences > pydev > interpreter - python > string substitution variables) -- that way you can have different variables per interpreter... which IMO is better than having it globally.

一个很好的例子是将一个解释器编译为64位,另一个为32,并且可以配置pythonpath该项目根据所使用的解释器而有所不同 - 因此,您可以在一个文件夹中编译64个文件,在另一个文件夹中编译32个。

A nice example of that would be having an interpreter compiled for 64 bits and another for 32 and could configure the pythonpath for the project differently depending on the interpreter being used -- so, you could have dlls compiled for 64 in one folder and for 32 in another.

这篇关于在PyDev Eclipse项目文件中使用环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆