コード例 #1
0
def check(cmd, mf):
    m = mf.findNode('Image') or mf.findNode('PIL.Image')
    if m is None or m.filename is None:
        return None

    if mf.findNode('PIL.Image'):
        have_PIL = True
    else:
        have_PIL = False

    plugins = set()
    visited = set()
    for folder in sys.path:
        if not isinstance(folder, basestring):
            continue

        for extra in ('', 'PIL'):
            folder = os.path.realpath(os.path.join(folder, extra))
            if (not os.path.isdir(folder)) or (folder in visited):
                continue
            for fn in os.listdir(folder):
                if 'ImagePlugin' in fn:
                    print fn, fn.endswith('ImagePlugin.py')
                if not fn.endswith('ImagePlugin.py'):
                    continue

                mod, ext = os.path.splitext(fn)
                try:
                    sys.path.insert(0, folder)
                    imp_find_module(mod)
                    del sys.path[0]
                except ImportError:
                    pass
                else:
                    plugins.add(mod)
        visited.add(folder)
    s = StringIO('_recipes_pil_prescript(%r)\n' % list(plugins))
    for plugin in plugins:
        if have_PIL:
            mf.implyNodeReference(m, 'PIL.' + plugin)
        else:
            mf.implyNodeReference(m, plugin)

    mf.removeReference(m, 'FixTk')
    # Since Imaging-1.1.5, SpiderImagePlugin imports ImageTk conditionally.
    # This is not ever used unless the user is explicitly using Tk elsewhere.
    sip = mf.findNode('SpiderImagePlugin')
    if sip is not None:
        mf.removeReference(sip, 'ImageTk')

    return dict(
        prescripts=['py2app.recipes.PIL.prescript', s],
        include=
        "PIL.JpegPresets",  # Dodgy import from PIL.JpegPlugin in Pillow 2.0
        flatpackages=[os.path.dirname(m.filename)],
    )
コード例 #2
0
ファイル: __init__.py プロジェクト: glue-viz/Travis-MacGlue
def check(cmd, mf):
    m = mf.findNode('Image') or mf.findNode('PIL.Image')
    if m is None or m.filename is None:
        return None

    if mf.findNode('PIL.Image'):
        have_PIL = True
    else:
        have_PIL = False

    plugins = set()
    visited = set()
    for folder in sys.path:
        if not isinstance(folder, basestring):
            continue

        for extra in ('', 'PIL'):
            folder = os.path.realpath(os.path.join(folder, extra))
            if (not os.path.isdir(folder)) or (folder in visited):
                continue
            for fn in os.listdir(folder):
                if 'ImagePlugin' in fn:
                    print fn, fn.endswith('ImagePlugin.py')
                if not fn.endswith('ImagePlugin.py'):
                    continue

                mod, ext = os.path.splitext(fn)
                try:
                    sys.path.insert(0, folder)
                    imp_find_module(mod)
                    del sys.path[0]
                except ImportError:
                    pass
                else:
                    plugins.add(mod)
        visited.add(folder)
    s = StringIO('_recipes_pil_prescript(%r)\n' % list(plugins))
    for plugin in plugins:
        if have_PIL:
            mf.implyNodeReference(m, 'PIL.' + plugin)
        else:
            mf.implyNodeReference(m, plugin)

    mf.removeReference(m, 'FixTk')
    # Since Imaging-1.1.5, SpiderImagePlugin imports ImageTk conditionally.
    # This is not ever used unless the user is explicitly using Tk elsewhere.
    sip = mf.findNode('SpiderImagePlugin')
    if sip is not None:
        mf.removeReference(sip, 'ImageTk')

    return dict(
        prescripts = ['py2app.recipes.PIL.prescript', s],
        include = "PIL.JpegPresets", # Dodgy import from PIL.JpegPlugin in Pillow 2.0
        flatpackages = [os.path.dirname(m.filename)],
    )
コード例 #3
0
ファイル: __init__.py プロジェクト: ankitpanda/pychallengecom
def check(cmd, mf):
    m = mf.findNode('Image') or mf.findNode('PIL.Image')
    if m is None or m.filename is None:
        return None

    plugins = set()
    visited = set()
    for folder in sys.path:
        if not isinstance(folder, basestring):
            continue
        folder = os.path.realpath(folder)
        if (not os.path.isdir(folder)) or (folder in visited):
            continue
        for fn in os.listdir(folder):
            if not fn.endswith('ImagePlugin.py'):
                continue
            mod, ext = os.path.splitext(fn)
            try:
                imp_find_module(mod)
            except ImportError:
                pass
            else:
                plugins.add(mod)
        visited.add(folder)
    s = StringIO('_recipes_pil_prescript(%r)\n' % list(plugins))
    for plugin in plugins:
        mf.implyNodeReference(m, plugin)
    mf.removeReference(m, 'FixTk')
    # Since Imaging-1.1.5, SpiderImagePlugin imports ImageTk conditionally.
    # This is not ever used unless the user is explicitly using Tk elsewhere.
    sip = mf.findNode('SpiderImagePlugin')
    if sip is not None:
        mf.removeReference(sip, 'ImageTk')

    return dict(
        prescripts = ['py2app.recipes.PIL.prescript', s],
        flatpackages = [os.path.dirname(m.filename)],
    )
コード例 #4
0
ファイル: build_app.py プロジェクト: danielsmith-eu/py2app
 def get_bootstrap(self, bootstrap):
     if isinstance(bootstrap, basestring):
         if not os.path.exists(bootstrap):
             bootstrap = imp_find_module(bootstrap)[1]
     return bootstrap
コード例 #5
0
 def get_bootstrap(self, bootstrap):
     if isinstance(bootstrap, basestring):
         if not os.path.exists(bootstrap):
             bootstrap = imp_find_module(bootstrap)[1]
     return bootstrap