Use environment variable in PyDev Eclipse project file

I am using Eclipse 3.6.1 with PyDev 1.6.4 to develop the Google App Engine site. In my .pydevproject projects I want to set the path to the Google App Engine SDK based on an environment variable, as I am developing my desktop and laptop (where the paths are slightly different), and I plan to check this file for initial control and other environments may be different . In the XML below, I want to replace /home/jesse value read from the environment variable. For now, I would be happy to just use 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 tried:

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

Google didn’t have a lot of suggestions?

+6
eclipse pydev
source share
1 answer

In fact, now you can use string substitution and then set it in your interpreter (in the window> preferences> pydev> interpreter - python> string substitution variables) - this way you can have different variables on the interpreter ... which IMO is better than globally.

A good example of this would be an interpreter compiled for 64 bits and another for 32, and can configure the pythonpath for the project differently depending on the interpreter used - so you could compile the dll for 64 in one folder and for 32 in another.

+6
source share

All Articles