From: David N. <dn...@hd...> - 2008-12-09 20:23:14
|
Thanks, Philip, for your suggestion. The import process now seems a lot more like boiling water than a nuclear power plant! --David Philip Jenvey wrote: > > On Dec 3, 2008, at 9:31 AM, David Niergarth wrote: > >> Hello, >> >> I need some basic help understanding how best to manage Jython scripts >> that need access to lots of jar files (CLASSPATH, sys.path, registry). >> I'm using Debian Lenny with Jython 2.2.1 on java1.6.0_0 (installed as >> the standard packages). >> >> I'm using Jython to script Jasper Reports (an open-source Java reporting >> library), which has a lot of dependencies (it's /lib subdirectory >> contains 45 jar files). >> >> To get things working, I have added the full paths to all 45 jar files >> to my CLASSPATH environment variable (2,690 characters). It also works >> if I add the jar paths to the registry's python.path property and unset >> CLASSPATH (or jython -Dpython.path=/long/path1:/long/path2:..., although >> that's pretty unwieldy). > > > If you can get away with it, lazily load the jar paths -- which'll be > particularly easy when they're all in the same directory. What I mean by > that is: just before you need them, have Python code to the dirty work > of globbing them into sys.path (which is where the -Dpython.path paths > end up). > > for jar in glob.glob(os.path.join(my_jasper_path, '*.jar')): > sys.path.append(jar) > > -- > Philip Jenvey |