Monday, January 02, 2006

Invoking jython with ant script task

Try "import re" and it will return with a "ImportError: no module named re". The reason is that jython.jar is only bundled with a few of the standard modules. So we need to find the modules elsewhere. The magic is to pass python.path with the location of the python modules to Ant, however the only way to do this seems to be via the ANT_OPTS environment variable (e.g. export ANT_OPTS="-Dpython.path=c:/tmp/"). Be sure to link to python modules with the same version as Jython.jar (e.g. jython-2.1 should link to python2.1 modules and jython-2.2a should link to python2.2 modules).

No comments: