[Python-checkins] python/dist/src/Lib/plat-mac bundlebuilder.py,1.9,1.10
jackjansen@users.sourceforge.net
jackjansen@users.sourceforge.net
Tue, 18 Feb 2003 15:29:50 -0800
Update of /cvsroot/python/python/dist/src/Lib/plat-mac
In directory sc8-pr-cvs1:/tmp/cvs-serv31090
Modified Files:
bundlebuilder.py
Log Message:
Added an argv_emulation option (command line option: --argv or -a) which
creates the sys.argv emulation wrapper for droplets. Also updates
the plist, if needed, and the includedModules (but this last is untested).
Index: bundlebuilder.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/bundlebuilder.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** bundlebuilder.py 18 Feb 2003 11:24:31 -0000 1.9
--- bundlebuilder.py 18 Feb 2003 23:29:46 -0000 1.10
***************
*** 267,270 ****
--- 267,276 ----
"""
+ ARGVEMULATOR="""\
+ import argvemulator, os
+
+ argvemulator.ArgvCollector().mainloop()
+ execfile(os.path.join(os.path.split(__file__)[0], "%(realmainprogram)s"))
+ """
class AppBuilder(BundleBuilder):
***************
*** 294,297 ****
--- 300,307 ----
# If True, build standalone app.
standalone = 0
+
+ # If True, add a real main program that emulates sys.argv before calling
+ # mainprogram
+ argv_emulation = 0
# The following attributes are only used when building a standalone app.
***************
*** 369,372 ****
--- 379,403 ----
mainprogram = os.path.basename(self.mainprogram)
self.files.append((self.mainprogram, pathjoin(resdir, mainprogram)))
+ if self.argv_emulation:
+ # Change the main program, and create the helper main program (which
+ # does argv collection and then calls the real main).
+ # Also update the included modules (if we're creating a standalone
+ # program) and the plist
+ realmainprogram = mainprogram
+ mainprogram = '__argvemulator_' + mainprogram
+ resdirpath = pathjoin(self.bundlepath, resdir)
+ mainprogrampath = pathjoin(resdirpath, mainprogram)
+ makedirs(resdirpath)
+ open(mainprogrampath, "w").write(ARGVEMULATOR % locals())
+ if self.standalone:
+ self.includeModules.append("argvemulator")
+ self.includeModules.append("os")
+ if not self.plist.has_key("CFBundleDocumentTypes"):
+ self.plist["CFBundleDocumentTypes"] = [
+ { "CFBundleTypeOSTypes" : [
+ "****",
+ "fold",
+ "disk"],
+ "CFBundleTypeRole": "Viewer"}]
# Write bootstrap script
executable = os.path.basename(self.executable)
***************
*** 620,623 ****
--- 651,655 ----
-e, --executable=FILE the executable to be used
-m, --mainprogram=FILE the Python main program
+ -a, --argv add a wrapper main program to create sys.argv
-p, --plist=FILE .plist file (default: generate one)
--nib=NAME main nib name
***************
*** 648,655 ****
builder = AppBuilder(verbosity=1)
! shortopts = "b:n:r:e:m:c:p:lx:i:hvq"
longopts = ("builddir=", "name=", "resource=", "executable=",
"mainprogram=", "creator=", "nib=", "plist=", "link",
! "link-exec", "help", "verbose", "quiet", "standalone",
"exclude=", "include=", "package=", "strip", "iconfile=")
--- 680,687 ----
builder = AppBuilder(verbosity=1)
! shortopts = "b:n:r:e:m:c:p:lx:i:hvqa"
longopts = ("builddir=", "name=", "resource=", "executable=",
"mainprogram=", "creator=", "nib=", "plist=", "link",
! "link-exec", "help", "verbose", "quiet", "argv", "standalone",
"exclude=", "include=", "package=", "strip", "iconfile=")
***************
*** 670,673 ****
--- 702,707 ----
elif opt in ('-m', '--mainprogram'):
builder.mainprogram = arg
+ elif opt in ('-a', '--argv'):
+ builder.argv_emulation = 1
elif opt in ('-c', '--creator'):
builder.creator = arg