# Path: py2app/util.py
# def makedirs(path):
#     path = fsencoding(path)
#     if not os.path.exists(path):
#         os.makedirs(path)
# 
# def mergecopy(src, dest):
#     return macholib.util.mergecopy(src, dest)
# 
# def mergetree(src, dst, condition=None, copyfn=mergecopy):
#     """Recursively merge a directory tree using mergecopy()."""
#     return macholib.util.mergetree(src, dst, condition=condition, copyfn=copyfn)
# 
# def skipscm(ofn):
#     ofn = fsencoding(ofn)
#     fn = os.path.basename(ofn)
#     if fn in SCMDIRS:
#         return False
#     return True
# 
# def make_exec(path):
#     mask = os.umask(0)
#     os.umask(mask)
#     os.chmod(path, os.stat(path).st_mode | (0111 & ~mask))


import os
import plistlib
import shutil
import py2app.apptemplate
    import sys
from pkg_resources import resource_filename
from py2app.util import makedirs, mergecopy, mergetree, skipscm, make_exec
# XXX - plugins, prefpane, etc?

def create_appbundle(destdir, name, extension='.app', module=py2app.apptemplate,
        platform='MacOS', copy=mergecopy, mergetree=mergetree,
        condition=skipscm, plist={}):
    kw = module.plist_template.infoPlistDict(
        plist.get('CFBundleExecutable', name), plist)

# Path: py2app/util.py
# def makedirs(path):
#     path = fsencoding(path)
#     if not os.path.exists(path):
#         os.makedirs(path)
# 
# def mergecopy(src, dest):
#     return macholib.util.mergecopy(src, dest)
# 
# def mergetree(src, dst, condition=None, copyfn=mergecopy):
#     """Recursively merge a directory tree using mergecopy()."""
#     return macholib.util.mergetree(src, dst, condition=condition, copyfn=copyfn)
# 
# def skipscm(ofn):
#     ofn = fsencoding(ofn)
#     fn = os.path.basename(ofn)
#     if fn in SCMDIRS:
#         return False
#     return True
# 
# def make_exec(path):
#     mask = os.umask(0)
#     os.umask(mask)
#     os.chmod(path, os.stat(path).st_mode | (0111 & ~mask))


# Path: py2app/create_appbundle.py
import os
import plistlib
import shutil
import py2app.apptemplate
    import sys
from pkg_resources import resource_filename
from py2app.util import makedirs, mergecopy, mergetree, skipscm, make_exec

# XXX - plugins, prefpane, etc?

def create_appbundle(destdir, name, extension='.app', module=py2app.apptemplate,
        platform='MacOS', copy=mergecopy, mergetree=mergetree,
        condition=skipscm, plist={}):
    kw = module.plist_template.infoPlistDict(
        plist.get('CFBundleExecutable', name), plist)

    app = os.path.join(destdir, kw['CFBundleName'] + extension)