Use environment variable in PyDev Eclipse project file
Asked Answered
B

1

9

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?

Barreto answered 26/1, 2011 at 0:55 Comment(0)
L
7

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.

Letitialetizia answered 28/1, 2011 at 11:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.