How to use the py2app.build_app function in py2app

To help you get started, we’ve selected a few py2app examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ilastik / ilastik / setup_mac.py View on Github external
include_meta_repo = True
    sys.argv.remove('--include-meta-repo')

# This hack allows us to run custom code before/after the py2app command executes.
# http://www.niteoweb.com/blog/setuptools-run-custom-code-during-install
import os
import shutil

import ilastik
ilastik_meta_repo = os.path.abspath( os.path.split(ilastik.__file__)[0] + '/../..')
assert os.path.exists(ilastik_meta_repo + '/ilastik')
assert os.path.exists(ilastik_meta_repo + '/lazyflow')
assert os.path.exists(ilastik_meta_repo + '/volumina')

import py2app.build_app
class custom_py2app(py2app.build_app.py2app):
    __dist_dir = os.path.split( os.path.abspath(__file__) )[0] + '/dist'
    __destination_libpython_dir = __dist_dir + '/ilastik.app/Contents/Resources/lib/python2.7'
    __replace_modules = ['ilastik', 'volumina', 'lazyflow']

    def run(self):
        """
        The normal py2app run() function copies the ilastik, volumina, and 
        lazyflow modules in the .app without the enclosing repo directory.
        
        This function deletes those modules from the app (after saving the drtile.so binary), 
        copies the ENTIRE repo directory for each module, and then creates a symlink to the 
        inner module directory so that the final .app doesn't know the difference.
        
        Just to be clear, our usual py2app command (including our recipes) 
        produces a lib/python2.7 directory that looks like this:
github Marginal / EDMarketConnector / setup.py View on Github external
# OSX paths
SPARKLE = '/Library/Frameworks/Sparkle.framework'

# Patch py2app recipe enumerator to skip the sip recipe since it's too enthusiastic - we'll list additional Qt modules explicitly
if sys.platform=='darwin':
    from py2app import recipes
    import py2app.build_app
    def iterRecipes(module=recipes):
        for name in dir(module):
            if name.startswith('_') or name=='sip':
                continue
            check = getattr(getattr(module, name), 'check', None)
            if check is not None:
                yield (name, check)
    py2app.build_app.iterRecipes = iterRecipes


APP = 'EDMarketConnector.py'
APPCMD = 'EDMC.py'
SHORTVERSION = ''.join(VERSION.split('.')[:3])
PLUGINS = [ 'plugins/coriolis.py', 'plugins/eddb.py', 'plugins/eddn.py', 'plugins/edsm.py', 'plugins/edsy.py', 'plugins/inara.py' ]

if sys.platform=='darwin':
    OPTIONS =  { 'py2app':
                 {'dist_dir': dist_dir,
                  'optimize': 2,
                  'packages': [ 'requests', 'keyring.backends' ],
                  'frameworks': [ 'Sparkle.framework' ],
                  'excludes': [ 'distutils', 'iniparse', '_markerlib', 'PIL', 'pkg_resources', 'simplejson', 'unittest' ],
                  'iconfile': '%s.icns' % APPNAME,
                  'include_plugins': [('plugins', x) for x in PLUGINS],
github metachris / py2app / py2app / script_py2applet.py View on Github external
def get_cmd_options():
    options = set()
    for option in build_app.py2app.user_options:
        opt_long, opt_short = option[:2]
        if opt_long.endswith('=') and opt_short:
            options.add('-' + opt_short)
    return options
github ilastik / ilastik / setup_mac.py View on Github external
ilastik@ -> ilastik-meta/ilastik/ilastik
        lazyflow@ -> ilastik-meta/lazyflow/lazyflow
        volumina@ -> ilastik-meta/volumina/volumina
        site-packages.zip
        ...etc...            

        Hence, the ilastik, lazyflow, and volumina modules are present via symlinks,
        so the .app doesn't know the difference.
        
        Also, this function removes any dylibs in the dylib_forced_removal list from the final distribution.
        """
        # Remove modules/repos from an earlier build (if any)
        self.remove_repos()
        
        # Run the normal py2app command
        py2app.build_app.py2app.run(self)

        if include_meta_repo:
            # Save drtile.so first!
            shutil.move( self.__destination_libpython_dir + '/lazyflow/drtile/drtile.so', self.__dist_dir )
            
            # Copy repos and create symlinks to modules
            self.install_repos()
            
            # Replace drtile.so
            shutil.move( self.__dist_dir + '/drtile.so', self.__destination_libpython_dir + '/ilastik-meta/lazyflow/lazyflow/drtile/drtile.so' )

        # Remove excluded dylibs.
        # (The py2app exclude_dylib feature doesn't work if macholib can't find the dylib.)
        for dylib in dylib_forced_removal:
            dylib_path = self.__dist_dir + '/ilastik.app/Contents/Frameworks/' + dylib
            try:
github vaexio / vaex / py2app.py View on Github external
def run(self):
			py2app.build_app.py2app.run(self)
			#libQtWebKit.4.dylib
			#libQtNetwork.4.dylib
			if 0:
				libs = [line.strip() for line in """
				libLLVM-3.3.dylib
				libQtGui.4.dylib
				libQtCore.4.dylib
				libQtOpenGL.4.dylib
				libcrypto.1.0.0.dylib
				libssl.1.0.0.dylib
				libpng15.15.dylib
				libfreetype.6.dylib
				libjpeg.8.dylib
				libhdf5_hl.9.dylib
				libhdf5.9.dylib
				""".strip().splitlines()]
github metachris / py2app / py2app / script_py2applet.py View on Github external
def get_option_map():
    optmap = {}
    for option in build_app.py2app.user_options:
        opt_long, opt_short = option[:2]
        if opt_short:
            optmap['-' + opt_short] = opt_long.rstrip('=')
    return optmap
github vaexio / vaex / py2app.py View on Github external
print("Applying macholib patch...")
		import macholib.dyld
		import macholib.MachOGraph
		dyld_find_1_7 = macholib.dyld.dyld_find
		def dyld_find(name, loader=None, **kwargs):
			#print("~"*60 + "calling alternate dyld_find")
			if loader is not None:
				kwargs['loader_path'] = loader
			return dyld_find_1_7(name, **kwargs)
		macholib.MachOGraph.dyld_find = dyld_find
#full_name = vaex.__full_name__
cmdclass = {}

if has_py2app and sys.argv[1] == "py2app":
	import vaex.ui
	class my_py2app(py2app.build_app.py2app):
		"""hooks in post script to add in missing libraries and zip the content"""
		def run(self):
			py2app.build_app.py2app.run(self)
			#libQtWebKit.4.dylib
			#libQtNetwork.4.dylib
			if 0:
				libs = [line.strip() for line in """
				libLLVM-3.3.dylib
				libQtGui.4.dylib
				libQtCore.4.dylib
				libQtOpenGL.4.dylib
				libcrypto.1.0.0.dylib
				libssl.1.0.0.dylib
				libpng15.15.dylib
				libfreetype.6.dylib
				libjpeg.8.dylib