How to import Python modules with Maven in a Jython project? -



How to import Python modules with Maven in a Jython project? -

i'm writing jython project create text editor. info model written exclusively in python , uses external libraries nose, jinja , ply. gui text editor uses java swing libraries. i'm trying build project maven, , found out this useful plugin, i've included in pom file so:

<plugin> <groupid>net.sf.mavenjython</groupid> <artifactid>jython-compile-maven-plugin</artifactid> <version>1.1</version> <executions> <execution> <phase>package</phase> <goals> <goal>jython</goal> </goals> </execution> </executions> <configuration> <libraries> <param>nose</param> <param>ply</param> <param>jinja</param> </libraries> </configuration> </plugin>

when mvn package project, successful build message , jar, , python modules saved in folder created maven plugin above in target/classes/lib. far good, when seek run jar, can't create python code find python libraries , error message:

java -jar target/text_editor-0.0.1-snapshot.jar exception in thread "main" traceback (most recent phone call last): file "<string>", line 2, in <module> file "<string>", line 2, in <module> file "__pyclasspath__/text_editor/main.py", line 13, in <module> file "__pyclasspath__/pymodel/pyfile.py", line 1, in <module> file "__pyclasspath__/pymodel/pyflex.py", line 1, in <module> importerror: no module named ply

error line beingness import ply.lex lex

is there left in plugin configuration? or else in pom file need add together build linkage? i'm not maven expert, might have missed seems obvious others. there other way import python modules in jython project using maven? pointers appreciated :)

found solution problem! not maven related @ all, sorted out fixing pythonpath in jar file. suspected so, thought done via maven. wrong, needs done java code in jython project. main java class should have this:

pysystemstate systemstate = py.getsystemstate();

it matter of adding path libraries downloaded maven jython plugin in target/classes/lib in systemstate, this:

//link external python libraries installed via maven plugin systemstate.path.append(new pystring("target/classes/lib"));

libraries found , things work. i'm happy.

python maven maven-plugin jython

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -