1.1 --- a/tools/JavaServlet/webstack_java_build.py Thu Sep 27 17:47:19 2007 +0000
1.2 +++ b/tools/JavaServlet/webstack_java_build.py Thu Sep 27 17:48:34 2007 +0000
1.3 @@ -1,4 +1,4 @@
1.4 -#!/usr/bin/env python
1.5 +#!/usr/bin/env jython
1.6
1.7 "A simple Jython-based installer for the Web applications."
1.8
1.9 @@ -75,12 +75,13 @@
1.10 def get_appname(handler):
1.11 return os.path.split(os.path.splitext(handler)[0])[1]
1.12
1.13 -def make_app(handler, appdir, webstack_home, web_xml_template_name):
1.14 +def make_app(handler, appdir, webstack_home, jython_cachedir, web_xml_template_name):
1.15
1.16 """
1.17 Make the application directory from the given 'handler', application
1.18 directory 'appdir', the 'webstack_home' where the WebStack package can be
1.19 - found, and the deployment descriptor with the given 'web_xml_template_name'.
1.20 + found, the 'jython_cachedir' where Jython classes are cached, and the
1.21 + deployment descriptor with the given 'web_xml_template_name'.
1.22 """
1.23
1.24 appname = get_appname(handler)
1.25 @@ -116,12 +117,26 @@
1.26 handler_filename = os.path.split(handler)[1]
1.27 copy_file(handler, os.path.join(appname, handler_filename))
1.28
1.29 + # Find additional Jython paths.
1.30 +
1.31 + jython_paths = []
1.32 + for path in sys.path:
1.33 + if path.startswith(jython_home) and path != os.path.join(jython_home, "Lib"):
1.34 + jython_paths.append(path)
1.35 +
1.36 + jython_path = ":".join(jython_paths)
1.37 +
1.38 + # Create the cache directory if necessary.
1.39 +
1.40 + if not os.path.exists(jython_cachedir):
1.41 + os.mkdir(jython_cachedir)
1.42 +
1.43 # Configure the deployment descriptor.
1.44
1.45 f = open(os.path.join(webstack_home, "tools", "JavaServlet", web_xml_template_name))
1.46 web_xml = f.read()
1.47 f.close()
1.48 - web_xml = web_xml % (jython_home, handler_filename)
1.49 + web_xml = web_xml % (jython_home, jython_path, jython_cachedir, handler_filename)
1.50
1.51 # Write the deployment descriptor.
1.52
1.53 @@ -141,6 +156,8 @@
1.54 print " WebStack documentation and extras have been installed."
1.55 print " eg. .../WebStack-x.y"
1.56 print " eg. /usr/share/doc/python2.4-webstack"
1.57 + print " * The location of the Jython cache directory."
1.58 + print " eg. /home/paulb/.jython-cache"
1.59 print " * The name of the deployment descriptor template."
1.60 print " eg. web.xml"
1.61 print "You can also specify some additional libraries for the application..."
1.62 @@ -149,12 +166,12 @@
1.63 sys.exit(1)
1.64
1.65 print "Making application directory..."
1.66 - make_app(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4])
1.67 + make_app(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], sys.argv[5])
1.68
1.69 - if len(sys.argv) > 5:
1.70 + if len(sys.argv) > 6:
1.71 print "Copying additional libraries..."
1.72 appname = get_appname(sys.argv[1])
1.73 - for library in sys.argv[5:]:
1.74 + for library in sys.argv[6:]:
1.75 library_dir, library_name = os.path.split(library)
1.76 library_dest = os.path.join(appname, "WEB-INF", "lib", library_name)
1.77 copy_file(library, library_dest)