# Jython issue 1090 # # The prerequisite is the jar-source folder import os, sys, zipfile SRC = 'jar-source' JAR = 'jartest.jar' LIB = 'mylib' def tree_compile(srcname, jarname, libpath): with zipfile.PyZipFile(jarname, 'w') as jar: for base, subs, files in os.walk(srcname): print "compiling", base, '->', libpath, ':' jar.writepy(base, libpath) for name in os.walk(SRC): print name # Compile the source to $py.class files in the jar. tree_compile(SRC, JAR, LIB) with zipfile.ZipFile(JAR, 'r') as jar2: jar2.printdir() # Test import from jar sys.path.append(JAR + '/' + LIB) import tell import tell2 #import sub import sub.tell3