Back to index

python3.2  3.2.2
Classes | Functions | Variables
bundlebuilder Namespace Reference

Classes

class  BundleBuilderError
class  Defaults
class  BundleBuilder
class  AppBuilder

Functions

def getPycData
def isFramework
def findPackageContents
def writePyc
def copy
def copytodir
def makedirs
def symlink
def pathjoin
def usage
def main
def buildapp

Variables

list __all__ = ["BundleBuilder", "BundleBuilderError", "AppBuilder", "buildapp"]
string PYC_EXT = ".pyc"
tuple MAGIC = imp.get_magic()
string USE_ZIPIMPORT = "zipimport"
string SITE_PY
string ZIP_ARCHIVE = "Modules.zip"
string EXT_LOADER
list MAYMISS_MODULES
string STRIP_EXEC = "/usr/bin/strip"
string BOOTSTRAP_SCRIPT
string ARGV_EMULATOR
list PYTHONFRAMEWORKGOODIES
tuple LIB = os.path.join(sys.prefix, "lib", "python" + sys.version[:3])
tuple SITE_PACKAGES = os.path.join(LIB, "site-packages")
list SUFFIXES = [_suf for _suf, _mode, _tp in imp.get_suffixes()]
tuple identifierRE = re.compile(r"[_a-zA-z][_a-zA-Z0-9]*$")
string cmdline_doc

Function Documentation

def bundlebuilder.buildapp (   kwargs)

Definition at line 928 of file bundlebuilder.py.

00928 
00929 def buildapp(**kwargs):
00930     builder = AppBuilder(**kwargs)
00931     main(builder)
00932 

Here is the call graph for this function:

def bundlebuilder.copy (   src,
  dst,
  mkdirs = 0 
)
Copy a file or a directory.

Definition at line 748 of file bundlebuilder.py.

00748 
00749 def copy(src, dst, mkdirs=0):
00750     """Copy a file or a directory."""
00751     if mkdirs:
00752         makedirs(os.path.dirname(dst))
00753     if os.path.isdir(src):
00754         shutil.copytree(src, dst, symlinks=1)
00755     else:
00756         shutil.copy2(src, dst)

Here is the call graph for this function:

def bundlebuilder.copytodir (   src,
  dstdir 
)
Copy a file or a directory to an existing directory.

Definition at line 757 of file bundlebuilder.py.

00757 
00758 def copytodir(src, dstdir):
00759     """Copy a file or a directory to an existing directory."""
00760     dst = pathjoin(dstdir, os.path.basename(src))
00761     copy(src, dst)

Here is the call graph for this function:

def bundlebuilder.findPackageContents (   name,
  searchpath = None 
)

Definition at line 723 of file bundlebuilder.py.

00723 
00724 def findPackageContents(name, searchpath=None):
00725     head = name.split(".")[-1]
00726     if identifierRE.match(head) is None:
00727         return {}
00728     try:
00729         fp, path, (ext, mode, tp) = imp.find_module(head, searchpath)
00730     except ImportError:
00731         return {}
00732     modules = {name: None}
00733     if tp == imp.PKG_DIRECTORY and path:
00734         files = os.listdir(path)
00735         for sub in files:
00736             sub, ext = os.path.splitext(sub)
00737             fullname = name + "." + sub
00738             if sub != "__init__" and fullname not in modules:
00739                 modules.update(findPackageContents(fullname, [path]))
00740     return modules

Here is the caller graph for this function:

def bundlebuilder.getPycData (   fullname,
  code,
  ispkg 
)

Definition at line 248 of file bundlebuilder.py.

00248 
00249     def getPycData(fullname, code, ispkg):
00250         if ispkg:
00251             fullname += ".__init__"
00252         path = fullname.replace(".", os.sep) + PYC_EXT
00253         return path, MAGIC + '\0\0\0\0' + marshal.dumps(code)
00254 
00255 #
00256 # Extension modules can't be in the modules zip archive, so a placeholder
00257 # is added instead, that loads the extension from a specified location.
#

Here is the caller graph for this function:

Definition at line 340 of file bundlebuilder.py.

00340 
00341 def isFramework():
00342     return sys.exec_prefix.find("Python.framework") > 0
00343 

def bundlebuilder.main (   builder = None)

Definition at line 838 of file bundlebuilder.py.

00838 
00839 def main(builder=None):
00840     if builder is None:
00841         builder = AppBuilder(verbosity=1)
00842 
00843     shortopts = "b:n:r:f:e:m:c:p:lx:i:hvqa"
00844     longopts = ("builddir=", "name=", "resource=", "file=", "executable=",
00845         "mainprogram=", "creator=", "nib=", "plist=", "link",
00846         "link-exec", "help", "verbose", "quiet", "argv", "standalone",
00847         "exclude=", "include=", "package=", "strip", "iconfile=",
00848         "lib=", "python=", "semi-standalone", "bundle-id=", "destroot=")
00849 
00850     try:
00851         options, args = getopt.getopt(sys.argv[1:], shortopts, longopts)
00852     except getopt.error:
00853         usage()
00854 
00855     for opt, arg in options:
00856         if opt in ('-b', '--builddir'):
00857             builder.builddir = arg
00858         elif opt in ('-n', '--name'):
00859             builder.name = arg
00860         elif opt in ('-r', '--resource'):
00861             builder.resources.append(os.path.normpath(arg))
00862         elif opt in ('-f', '--file'):
00863             srcdst = arg.split(':')
00864             if len(srcdst) != 2:
00865                 usage("-f or --file argument must be two paths, "
00866                       "separated by a colon")
00867             builder.files.append(srcdst)
00868         elif opt in ('-e', '--executable'):
00869             builder.executable = arg
00870         elif opt in ('-m', '--mainprogram'):
00871             builder.mainprogram = arg
00872         elif opt in ('-a', '--argv'):
00873             builder.argv_emulation = 1
00874         elif opt in ('-c', '--creator'):
00875             builder.creator = arg
00876         elif opt == '--bundle-id':
00877             builder.bundle_id = arg
00878         elif opt == '--iconfile':
00879             builder.iconfile = arg
00880         elif opt == "--lib":
00881             builder.libs.append(os.path.normpath(arg))
00882         elif opt == "--nib":
00883             builder.nibname = arg
00884         elif opt in ('-p', '--plist'):
00885             builder.plist = Plist.fromFile(arg)
00886         elif opt in ('-l', '--link'):
00887             builder.symlink = 1
00888         elif opt == '--link-exec':
00889             builder.symlink_exec = 1
00890         elif opt in ('-h', '--help'):
00891             usage()
00892         elif opt in ('-v', '--verbose'):
00893             builder.verbosity += 1
00894         elif opt in ('-q', '--quiet'):
00895             builder.verbosity -= 1
00896         elif opt == '--standalone':
00897             builder.standalone = 1
00898         elif opt == '--semi-standalone':
00899             builder.semi_standalone = 1
00900         elif opt == '--python':
00901             builder.python = arg
00902         elif opt in ('-x', '--exclude'):
00903             builder.excludeModules.append(arg)
00904         elif opt in ('-i', '--include'):
00905             builder.includeModules.append(arg)
00906         elif opt == '--package':
00907             builder.includePackages.append(arg)
00908         elif opt == '--strip':
00909             builder.strip = 1
00910         elif opt == '--destroot':
00911             builder.destroot = arg
00912 
00913     if len(args) != 1:
00914         usage("Must specify one command ('build', 'report' or 'help')")
00915     command = args[0]
00916 
00917     if command == "build":
00918         builder.setup()
00919         builder.build()
00920     elif command == "report":
00921         builder.setup()
00922         builder.report()
00923     elif command == "help":
00924         usage()
00925     else:
00926         usage("Unknown command '%s'" % command)
00927 

Here is the call graph for this function:

Here is the caller graph for this function:

def bundlebuilder.makedirs (   dir)
Make all directories leading up to 'dir' including the leaf
directory. Don't moan if any path element already exists.

Definition at line 762 of file bundlebuilder.py.

00762 
00763 def makedirs(dir):
00764     """Make all directories leading up to 'dir' including the leaf
00765     directory. Don't moan if any path element already exists."""
00766     try:
00767         os.makedirs(dir)
00768     except OSError as why:
00769         if why.errno != errno.EEXIST:
00770             raise

Here is the call graph for this function:

Here is the caller graph for this function:

def bundlebuilder.pathjoin (   args)
Safe wrapper for os.path.join: asserts that all but the first
argument are relative paths.

Definition at line 779 of file bundlebuilder.py.

00779 
00780 def pathjoin(*args):
00781     """Safe wrapper for os.path.join: asserts that all but the first
00782     argument are relative paths."""
00783     for seg in args[1:]:
00784         assert seg[0] != "/"
00785     return os.path.join(*args)
00786 

Here is the caller graph for this function:

def bundlebuilder.symlink (   src,
  dst,
  mkdirs = 0 
)
Copy a file or a directory.

Definition at line 771 of file bundlebuilder.py.

00771 
00772 def symlink(src, dst, mkdirs=0):
00773     """Copy a file or a directory."""
00774     if not os.path.exists(src):
00775         raise IOError("No such file or directory: '%s'" % src)
00776     if mkdirs:
00777         makedirs(os.path.dirname(dst))
00778     os.symlink(os.path.abspath(src), dst)

Here is the call graph for this function:

def bundlebuilder.usage (   msg = None)

Definition at line 832 of file bundlebuilder.py.

00832 
00833 def usage(msg=None):
00834     if msg:
00835         print(msg)
00836     print(cmdline_doc)
00837     sys.exit(1)

Here is the caller graph for this function:

def bundlebuilder.writePyc (   code,
  path 
)

Definition at line 741 of file bundlebuilder.py.

00741 
00742 def writePyc(code, path):
00743     f = open(path, "wb")
00744     f.write(MAGIC)
00745     f.write("\0" * 4)  # don't bother about a time stamp
00746     marshal.dump(code, f)
00747     f.close()

Here is the caller graph for this function:


Variable Documentation

list bundlebuilder.__all__ = ["BundleBuilder", "BundleBuilderError", "AppBuilder", "buildapp"]

Definition at line 28 of file bundlebuilder.py.

Initial value:
00001 """\
00002 import argvemulator, os
00003 
00004 argvemulator.ArgvCollector().mainloop()
00005 execfile(os.path.join(os.path.split(__file__)[0], "%(realmainprogram)s"))
00006 """

Definition at line 321 of file bundlebuilder.py.

Initial value:
00001 """\
00002 #!%(hashbang)s
00003 
00004 import sys, os
00005 execdir = os.path.dirname(sys.argv[0])
00006 executable = os.path.join(execdir, "%(executable)s")
00007 resdir = os.path.join(os.path.dirname(execdir), "Resources")
00008 libdir = os.path.join(os.path.dirname(execdir), "Frameworks")
00009 mainprogram = os.path.join(resdir, "%(mainprogram)s")
00010 
00011 sys.argv.insert(1, mainprogram)
00012 if %(standalone)s or %(semi_standalone)s:
00013     os.environ["PYTHONPATH"] = resdir
00014     if %(standalone)s:
00015         os.environ["PYTHONHOME"] = resdir
00016 else:
00017     pypath = os.getenv("PYTHONPATH", "")
00018     if pypath:
00019         pypath = ":" + pypath
00020     os.environ["PYTHONPATH"] = resdir + pypath
00021 os.environ["PYTHONEXECUTABLE"] = executable
00022 os.environ["DYLD_LIBRARY_PATH"] = libdir
00023 os.environ["DYLD_FRAMEWORK_PATH"] = libdir
00024 os.execve(executable, sys.argv, os.environ)
00025 """

Definition at line 291 of file bundlebuilder.py.

Definition at line 787 of file bundlebuilder.py.

Initial value:
00001 """\
00002 def __load():
00003     import imp, sys, os
00004     for p in sys.path:
00005         path = os.path.join(p, "%(filename)s")
00006         if os.path.exists(path):
00007             break
00008     else:
00009         assert 0, "file not found: %(filename)s"
00010     mod = imp.load_dynamic("%(name)s", path)
00011 
00012 __load()
00013 del __load
00014 """

Definition at line 258 of file bundlebuilder.py.

tuple bundlebuilder.identifierRE = re.compile(r"[_a-zA-z][_a-zA-Z0-9]*$")

Definition at line 721 of file bundlebuilder.py.

tuple bundlebuilder.LIB = os.path.join(sys.prefix, "lib", "python" + sys.version[:3])

Definition at line 344 of file bundlebuilder.py.

tuple bundlebuilder.MAGIC = imp.get_magic()

Definition at line 234 of file bundlebuilder.py.

Initial value:
00001 ['mac', 'os2', 'nt', 'ntpath', 'dos', 'dospath',
00002     'win32api', 'ce', '_winreg', 'nturl2path', 'sitecustomize',
00003     'org.python.core', 'riscos', 'riscosenviron', 'riscospath'
00004 ]

Definition at line 273 of file bundlebuilder.py.

Definition at line 230 of file bundlebuilder.py.

Initial value:
00001 [
00002     "Python",  # the Python core library
00003     "Resources/English.lproj",
00004     "Resources/Info.plist",
00005     "Resources/version.plist",
00006 ]

Definition at line 333 of file bundlebuilder.py.

tuple bundlebuilder.SITE_PACKAGES = os.path.join(LIB, "site-packages")

Definition at line 345 of file bundlebuilder.py.

Initial value:
00001 """\
00002 import sys
00003 if not %(semi_standalone)s:
00004     del sys.path[1:]  # sys.path[0] is Contents/Resources/
00005 """

Definition at line 239 of file bundlebuilder.py.

string bundlebuilder.STRIP_EXEC = "/usr/bin/strip"

Definition at line 278 of file bundlebuilder.py.

list bundlebuilder.SUFFIXES = [_suf for _suf, _mode, _tp in imp.get_suffixes()]

Definition at line 720 of file bundlebuilder.py.

Definition at line 235 of file bundlebuilder.py.

Definition at line 246 of file bundlebuilder.py.