Use environment variable in PyDev Eclipse project file

核能气质少年 提交于 2019-12-04 20:16:03

问题


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>

I have tried:

  • ${HOME}
  • ${env.HOME}
  • $HOME

Google has not turned up much, any suggestions?


回答1:


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.

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.



来源:https://stackoverflow.com/questions/4800512/use-environment-variable-in-pydev-eclipse-project-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!