def __init__(self, driveAttributes): from distutils.core import setup attribs = driveAttributes freeze_options = {} ext_modules = [] script = attribs.get_script() scripts = attribs.get_scripts() name = attribs.get_name() packages = Packages(attribs.get_package_dirs()).load() # special handling for data files, except for Linux if ((sys.platform == "win32" or sys.platform == 'darwin') and 'nxdrive.data' in packages): packages.remove('nxdrive.data') package_data = attribs.get_package_data() icons_home = attribs.get_icons_home() ui5_home = attribs.get_ui5_home() win_icon = os.path.join(icons_home, attribs.get_win_icon()) png_icon = os.path.join(icons_home, attribs.get_png_icon()) osx_icon = os.path.join(icons_home, attribs.get_osx_icon()) if sys.platform == 'win32': icon = win_icon elif sys.platform == 'darwin': icon = osx_icon else: icon = png_icon # Files to include in frozen app # build_exe freeze with cx_Freeze (Windows) include_files = attribs.get_includes() # bdist_esky freeze with cx_Freeze (Windows) and py2app (OS X) # In fact this is a global setup option # TODO NXP-13810: check removed data_files from py2app and added to # global setup icon_files = data_file_dir(icons_home, 'icons', include_files).load() ui5_files = data_file_dir(ui5_home, 'ui5', include_files).load_recursive() data_files = [('icons', icon_files)] data_files.extend(ui5_files) data_files.extend(attribs.get_data_files()) old_version = None init_file = attribs.get_init_file() version = read_version(init_file) if '-dev' in version: # timestamp the dev artifacts as distutils only accepts "b" + digit timestamp = datetime.utcnow().isoformat() timestamp = timestamp.replace(":", "") timestamp = timestamp.replace(".", "") timestamp = timestamp.replace("T", "") timestamp = timestamp.replace("-", "") old_version = version # distutils imposes a max 3 levels integer version # (+ prerelease markers which are not allowed in a # msi package version). On the other hand, # msi imposes the a.b.c.0 or a.b.c.d format where # a, b, c and d are all 16 bits integers # TODO: align on latest distutils versioning month_day = timestamp[4:8] if month_day.startswith('0'): month_day = month_day[1:] version = version.replace('-dev', ".%s" % (month_day)) update_version(init_file, version) print "Updated version to " + version # Create JSON metadata file for the frozen application json_file = create_json_metadata(version, SERVER_MIN_VERSION) print "Created JSON metadata file for frozen app: " + json_file includes = [ "PyQt4", "PyQt4.QtCore", "PyQt4.QtNetwork", "PyQt4.QtGui", "atexit", # implicitly required by PyQt4 "cffi", "xattr" ] attribs.append_includes(includes) excludes = [ "ipdb", "clf", "IronPython", "pydoc", "tkinter", ] if '--freeze' in sys.argv: print "Building standalone executable..." sys.argv.remove('--freeze') from nx_cx_Freeze import setup from cx_Freeze import Executable as cx_Executable from esky.util import get_platform # build_exe does not seem to take the package_dir info into account sys.path.append(attribs.get_path_append()) executables = [cx_Executable(script)] freeze_options = dict() if sys.platform == "win32": # Windows GUI program that can be launched without a cmd # console script_w = attribs.get_win_script() if script_w is not None: scripts.append( es_Executable(script_w, icon=icon, shortcutDir="ProgramMenuFolder", shortcutName=attribs.shortcutName())) executables.append( cx_Executable(script_w, targetName=attribs.get_win_targetName(), base="Win32GUI", icon=icon, shortcutDir="ProgramMenuFolder", shortcutName=attribs.shortcutName())) freeze_options.update({'attribs': attribs}) package_data = {} esky_app_name = (attribs.get_name() + '-' + version + '.' + get_platform()) esky_dist_dir = os.path.join(OUTPUT_DIR, esky_app_name) freeze_options.update({ 'executables': executables, 'options': { "build": { "exe_command": "bdist_esky", }, "build_exe": { "includes": includes, "packages": packages + [ "nose", ], "excludes": excludes, "include_files": include_files, }, "bdist_esky": { "excludes": excludes, "enable_appdata_dir": True, "freezer_options": { "packages": packages + [ "nose", ], }, "rm_freeze_dir_after_zipping": False, }, "install": { "skip_sub_commands": "install_lib,install_scripts,install_data", }, "install_exe": { "skip_build": True, "build_dir": esky_dist_dir, }, "bdist_msi": { "add_to_path": True, "upgrade_code": attribs.get_uid(), }, }, }) # Include cffi compiled C extension under Linux if sys.platform.startswith('linux'): import xattr includeFiles = [(os.path.join(os.path.dirname(xattr.__file__), '_cffi__x7c9e2f59xb862c7dd.so'), '_cffi__x7c9e2f59xb862c7dd.so')] freeze_options['options']['bdist_esky'][ 'freezer_options'].update({"includeFiles": includeFiles}) if sys.platform == 'darwin': # Under OSX we use py2app instead of cx_Freeze because we need: # - argv_emulation=True for nxdrive:// URL scheme handling # - easy Info.plist customization import py2app # install the py2app command import xattr ext_modules = [xattr.lib.ffi.verifier.get_extension()] includes.append("_cffi__x7c9e2f59xb862c7dd") name = attribs.get_CFBundleName() py2app_options = dict( iconfile=icon, qt_plugins='imageformats', argv_emulation=False, # We use QT for URL scheme handling plist=dict( CFBundleDisplayName=attribs.get_CFBundleDisplayName(), CFBundleName=attribs.get_CFBundleName(), CFBundleIdentifier=attribs.get_CFBundleIdentifier(), LSUIElement=True, # Do not launch as a Dock application CFBundleURLTypes=[ dict( CFBundleURLName=attribs.get_CFBundleURLName(), CFBundleURLSchemes=( attribs.get_CFBundleURLSchemes()), ) ], NSServices=[ dict(NSMenuItem=dict( default=attribs.get_CFBundleDisplayName()), NSMessage=u"macRightClick", NSPortName=attribs.get_CFBundleDisplayName(), NSRequiredContext=dict(), NSSendTypes=[ u'NSStringPboardType', ], NSSendFileTypes=[u"public.item"]) ]), includes=includes, excludes=excludes, ) freeze_options = dict(app=attribs.get_app(), options=dict( py2app=py2app_options, bdist_esky=dict( enable_appdata_dir=True, create_zipfile=False, freezer_options=py2app_options, ))) setup(name=name, version=version, description=attribs.get_description(), author=attribs.get_author(), author_email=attribs.get_author_email(), url=attribs.get_url(), packages=packages, package_dir=attribs.get_package_dir(), package_data=package_data, scripts=scripts, long_description=attribs.get_long_description(), data_files=data_files, ext_modules=ext_modules, **freeze_options) if old_version is not None: update_version(init_file, old_version) print "Restored version to " + old_version
def __init__(self, driveAttributes): from distutils.core import setup attribs = driveAttributes freeze_options = {} ext_modules = [] script = attribs.get_script() scripts = attribs.get_scripts() name = attribs.get_name() packages = Packages(attribs.get_package_dirs()).load() # special handling for data files, except for Linux if ((sys.platform == "win32" or sys.platform == 'darwin') and 'nxdrive.data' in packages): packages.remove('nxdrive.data') package_data = attribs.get_package_data() icons_home = attribs.get_icons_home() ui5_home = attribs.get_ui5_home() win_icon = os.path.join(icons_home, attribs.get_win_icon()) png_icon = os.path.join(icons_home, attribs.get_png_icon()) osx_icon = os.path.join(icons_home, attribs.get_osx_icon()) if sys.platform == 'win32': icon = win_icon elif sys.platform == 'darwin': icon = osx_icon else: icon = png_icon # Files to include in frozen app # build_exe freeze with cx_Freeze (Windows) include_files = attribs.get_includes() # bdist_esky freeze with cx_Freeze (Windows) and py2app (OS X) # In fact this is a global setup option # TODO NXP-13810: check removed data_files from py2app and added to # global setup icon_files = data_file_dir(icons_home, 'icons', include_files).load() ui5_files = data_file_dir(ui5_home, 'ui5', include_files).load_recursive() data_files = [('icons', icon_files)] data_files.extend(ui5_files) data_files.extend(attribs.get_data_files()) old_version = None init_file = attribs.get_init_file() version = read_version(init_file) if '-dev' in version: # timestamp the dev artifacts as distutils only accepts "b" + digit timestamp = datetime.utcnow().isoformat() timestamp = timestamp.replace(":", "") timestamp = timestamp.replace(".", "") timestamp = timestamp.replace("T", "") timestamp = timestamp.replace("-", "") old_version = version # distutils imposes a max 3 levels integer version # (+ prerelease markers which are not allowed in a # msi package version). On the other hand, # msi imposes the a.b.c.0 or a.b.c.d format where # a, b, c and d are all 16 bits integers # TODO: align on latest distutils versioning month_day = timestamp[4:8] if month_day.startswith('0'): month_day = month_day[1:] version = version.replace('-dev', ".%s" % ( month_day)) update_version(init_file, version) print "Updated version to " + version # Create JSON metadata file for the frozen application json_file = create_json_metadata(version, SERVER_MIN_VERSION) print "Created JSON metadata file for frozen app: " + json_file includes = [ "PyQt4", "PyQt4.QtCore", "PyQt4.QtNetwork", "PyQt4.QtGui", "atexit" # implicitly required by PyQt4 ] if attribs.include_xattr_binaries(): includes.append('cffi') includes.append('xattr') attribs.append_includes(includes) excludes = [ "ipdb", "clf", "IronPython", "pydoc", "tkinter", ] if not attribs.include_xattr_binaries(): excludes.append('cffi') excludes.append('xattr') if '--freeze' in sys.argv: print "Building standalone executable..." sys.argv.remove('--freeze') from nx_cx_Freeze import setup from cx_Freeze import Executable as cx_Executable from esky.util import get_platform # build_exe does not seem to take the package_dir info into account sys.path.append(attribs.get_path_append()) executables = [cx_Executable(script)] freeze_options = dict() if sys.platform == "win32": # Windows GUI program that can be launched without a cmd # console script_w = attribs.get_win_script() if script_w is not None: scripts.append( es_Executable(script_w, icon=icon, shortcutDir="ProgramMenuFolder", shortcutName=attribs.shortcutName())) executables.append( cx_Executable(script_w, targetName=attribs.get_win_targetName(), base="Win32GUI", icon=icon, shortcutDir="ProgramMenuFolder", shortcutName=attribs.shortcutName())) freeze_options.update({'attribs': attribs}) package_data = {} esky_app_name = (attribs.get_name() + '-' + version + '.' + get_platform()) esky_dist_dir = os.path.join(OUTPUT_DIR, esky_app_name) freeze_options.update({ 'executables': executables, 'options': { "build": { "exe_command": "bdist_esky", }, "build_exe": { "includes": includes, "packages": packages + [ "nose", ], "excludes": excludes, "include_files": include_files, }, "bdist_esky": { "excludes": excludes, "enable_appdata_dir": True, "freezer_options": { "packages": packages + [ "nose", ], }, "rm_freeze_dir_after_zipping": False, }, "install": { "skip_sub_commands": "install_lib,install_scripts,install_data", }, "install_exe": { "skip_build": True, "build_dir": esky_dist_dir, }, "bdist_msi": { "add_to_path": True, "upgrade_code": attribs.get_uid(), }, }, }) # Include cffi compiled C extension under Linux if sys.platform.startswith('linux') and attribs.include_xattr_binaries(): import xattr includeFiles = [(os.path.join(os.path.dirname(xattr.__file__), '_cffi__x7c9e2f59xb862c7dd.so'), '_cffi__x7c9e2f59xb862c7dd.so')] freeze_options['options']['bdist_esky']['freezer_options'].update({ "includeFiles": includeFiles }) if sys.platform == 'darwin': # Under OSX we use py2app instead of cx_Freeze because we need: # - argv_emulation=True for nxdrive:// URL scheme handling # - easy Info.plist customization import py2app # install the py2app command if attribs.include_xattr_binaries(): import xattr ext_modules = [xattr.lib.ffi.verifier.get_extension()] includes.append("_cffi__x7c9e2f59xb862c7dd") name = attribs.get_CFBundleName() py2app_options = dict( iconfile=icon, qt_plugins='imageformats', argv_emulation=False, # We use QT for URL scheme handling plist=dict( CFBundleDisplayName=attribs.get_CFBundleDisplayName(), CFBundleName=attribs.get_CFBundleName(), CFBundleIdentifier=attribs.get_CFBundleIdentifier(), LSUIElement=True, # Do not launch as a Dock application CFBundleURLTypes=[ dict( CFBundleURLName=attribs.get_CFBundleURLName(), CFBundleURLSchemes=(attribs .get_CFBundleURLSchemes()), ) ], NSServices=[ dict( NSMenuItem=dict( default=attribs.get_CFBundleDisplayName() ), NSMessage=u"macRightClick", NSPortName=attribs.get_CFBundleDisplayName(), NSRequiredContext=dict(), NSSendTypes=[ u'NSStringPboardType', ], NSSendFileTypes=[ u"public.item" ] ) ] ), includes=includes, excludes=excludes, ) freeze_options = dict( app=attribs.get_app(), options=dict( py2app=py2app_options, bdist_esky=dict( enable_appdata_dir=True, create_zipfile=False, freezer_options=py2app_options, ) ) ) setup( name=name, version=version, description=attribs.get_description(), author=attribs.get_author(), author_email=attribs.get_author_email(), url=attribs.get_url(), packages=packages, package_dir=attribs.get_package_dir(), package_data=package_data, scripts=scripts, long_description=attribs.get_long_description(), data_files=data_files, ext_modules=ext_modules, **freeze_options ) if old_version is not None: update_version(init_file, old_version) print "Restored version to " + old_version
def __init__(self, attribs): from distutils.core import setup freeze_options = {} ext_modules = [] script = attribs.get_script() scripts = [script] name = attribs.get_name() packages = Packages(attribs.get_package_dirs()).load() package_data = attribs.get_package_data() icons_home = attribs.get_icons_home() ui5_home = attribs.get_ui5_home() if sys.platform == 'win32': icon = os.path.join(icons_home, attribs.get_win_icon()) elif sys.platform == 'darwin': icon = os.path.join(icons_home, attribs.get_osx_icon()) else: icon = os.path.join(icons_home, attribs.get_png_icon()) # Files to include in frozen app # build_exe freeze with cx_Freeze (Windows) include_files = attribs.get_includes() # bdist_esky freeze with cx_Freeze (Windows) and py2app (OS X) # In fact this is a global setup option # TODO NXP-13810: check removed data_files from py2app and added to # global setup icon_files = DataFileDir(icons_home, 'icons', include_files).load() ui5_files = DataFileDir(ui5_home, 'ui5', include_files).load_recursive() data_files = [('icons', icon_files)] data_files.extend(ui5_files) data_files.extend(attribs.get_data_files()) drive_version = get_version(attribs.get_init_file()) # Create JSON metadata file for the frozen application json_file = create_json_metadata(drive_version, SERVER_MIN_VERSION) print('Created JSON metadata file for frozen app: ' + json_file) includes = [ 'atexit', # Implicitly required by PyQt4 'js2py.pyjs', # Implicitly required by pypac ] excludes = [ 'ipdb', 'pydoc', 'yappi', ] if attribs.include_xattr_binaries(): includes.append('cffi') includes.append('xattr') else: excludes.append('cffi') excludes.append('xattr') attribs.append_includes(includes) if '--freeze' in sys.argv: print('Building standalone executable...') sys.argv.remove('--freeze') from nx_cx_Freeze import setup from cx_Freeze import Executable as cx_Executable from esky.util import get_platform # build_exe does not seem to take the package_dir info into account sys.path.insert(0, attribs.get_path_append()) try: packages.remove('nxdrive.data') except ValueError: pass executables = [cx_Executable(script)] freeze_options = dict() if sys.platform == 'win32': # Copy OpenSSL DLL data_files.append('libeay32.dll') data_files.append('ssleay32.dll') # Windows GUI program that can be launched without a cmd # console scripts.append( es_Executable( attribs.get_script(), icon=icon, shortcutDir='ProgramMenuFolder', shortcutName=attribs.shortcutName(), )) executables.append( cx_Executable( attribs.get_win_target_name(), targetName=attribs.get_win_target_name(), base='Win32GUI', icon=icon, shortcutDir='ProgramMenuFolder', shortcutName=attribs.shortcutName(), )) # Add a shortcut on the desktop executables.append( cx_Executable( attribs.get_win_target_name(), targetName=attribs.get_win_target_name(), base='Win32GUI', icon=icon, shortcutDir='DesktopFolder', shortcutName=attribs.shortcutName(), )) freeze_options.update({'attribs': attribs}) package_data = {} esky_app_name = (attribs.get_name() + '-' + drive_version + '.' + get_platform()) esky_dist_dir = os.path.join(OUTPUT_DIR, esky_app_name) freeze_options.update({ 'executables': executables, 'options': { 'build': { 'exe_command': 'bdist_esky', }, 'build_exe': { 'includes': includes, 'packages': packages, 'excludes': excludes, 'include_files': include_files, }, 'bdist_esky': { 'includes': includes, 'excludes': excludes, 'enable_appdata_dir': True, 'freezer_options': { 'packages': packages, }, 'rm_freeze_dir_after_zipping': False, }, 'install': { 'skip_sub_commands': 'install_lib,install_scripts,install_data', }, 'install_exe': { 'skip_build': True, 'build_dir': esky_dist_dir, }, 'bdist_msi': { 'add_to_path': True, 'upgrade_code': attribs.get_uid(), }, }, }) if sys.platform == 'darwin': # Under OSX we use py2app instead of cx_Freeze because we need: # - argv_emulation=True for nxdrive:// URL scheme handling # - easy Info.plist customization name = attribs.get_CFBundleName() py2app_options = { 'iconfile': icon, 'qt_plugins': 'imageformats', 'argv_emulation': False, # We use Qt for URL scheme handling 'plist': { 'CFBundleDisplayName': attribs.get_CFBundleDisplayName(), 'CFBundleName': attribs.get_CFBundleName(), 'CFBundleIdentifier': attribs.get_CFBundleIdentifier(), 'LSUIElement': True, # Do not launch as a Dock application 'CFBundleURLTypes': [{ 'CFBundleURLName': attribs.get_CFBundleURLName(), 'CFBundleURLSchemes': attribs.get_CFBundleURLSchemes(), }], 'NSServices': [{ 'NSMenuItem': { 'default': attribs.get_CFBundleDisplayName(), }, 'NSMessage': 'macRightClick', 'NSPortName': attribs.get_CFBundleDisplayName(), 'NSRequiredContext': {}, 'NSSendTypes': [ 'NSStringPboardType', ], 'NSSendFileTypes': [ 'public.item', ], }], }, 'includes': includes, 'excludes': excludes, } freeze_options = { 'app': scripts, 'options': { 'py2app': py2app_options, 'bdist_esky': { 'enable_appdata_dir': True, 'create_zipfile': False, 'freezer_options': py2app_options, } } } entry_points = {} if sys.platform == 'win32': entry_points = { 'console_scripts': ['ndrive=nxdrive.commandline:main'], 'gui_scripts': ['ndrivew=nxdrive.commandline:main'], } with warnings.catch_warnings(): # Hide Windows "Unknown distribution option: 'attribs'" warnings.simplefilter('ignore', category=UserWarning) setup(name=name, version=drive_version, description=attribs.get_description(), author=attribs.get_author(), author_email=attribs.get_author_email(), url=attribs.get_url(), packages=packages, package_dir=attribs.get_package_dir(), package_data=package_data, scripts=scripts, long_description=attribs.get_long_description(), data_files=data_files, ext_modules=ext_modules, entry_points=entry_points, platforms=['Darwin', 'Linux', 'Windows'], license=attribs.get_licence(), **freeze_options)
def __init__(self, driveAttributes): from distutils.core import setup attribs = driveAttributes freeze_options = {} script = attribs.get_script() scripts = attribs.get_scripts() name = attribs.get_name() packages = Packages(attribs.get_package_dirs()).load() # special handling for data files packages.remove('nxdrive.data') packages.remove('nxdrive.data.icons') package_data = attribs.get_package_data() icons_home = attribs.get_icons_home() alembic_home = attribs.get_alembic_home() alembic_versions_home = attribs.get_alembic_versions_home() win_icon = os.path.join(icons_home, attribs.get_win_icon()) png_icon = os.path.join(icons_home, attribs.get_png_icon()) osx_icon = os.path.join(icons_home, attribs.get_osx_icon()) if sys.platform == 'win32': icon = win_icon elif sys.platform == 'darwin': icon = osx_icon else: icon = png_icon # Files to include in frozen app: icons, alembic, alembic versions # build_exe freeze with cx_Freeze (Windows) include_files = attribs.get_includes() # bdist_esky freeze with cx_Freeze (Windows) and py2app (OS X) # In fact this is a global setup option # TODO NXP-13810: check removed data_files from py2app and added to # global setup icon_files = data_file_dir(icons_home, 'icons', include_files).load() alembic_files = data_file_dir( alembic_home, 'alembic', include_files).load() alembic_version_files = data_file_dir( alembic_versions_home, 'alembic/versions', include_files).load() data_files = [('icons', icon_files), ('alembic', alembic_files), ('alembic/versions', alembic_version_files)] data_files.extend(attribs.get_data_files()) old_version = None init_file = attribs.get_init_file() version = read_version(init_file) if '--dev' in sys.argv: # timestamp the dev artifacts for continuous integration # distutils only accepts "b" + digit sys.argv.remove('--dev') timestamp = datetime.utcnow().isoformat() timestamp = timestamp.replace(":", "") timestamp = timestamp.replace(".", "") timestamp = timestamp.replace("T", "") timestamp = timestamp.replace("-", "") old_version = version # distutils imposes a max 3 levels integer version # (+ prerelease markers which are not allowed in a # msi package version). On the other hand, # msi imposes the a.b.c.0 or a.b.c.d format where # a, b, c and d are all 16 bits integers version = version.replace('-dev', ".%s" % ( timestamp[4:8])) update_version(init_file, version) print "Updated version to " + version # Create JSON metadata file for the frozen application json_file = create_json_metadata(version, SERVER_MIN_VERSION) print "Created JSON metadata file for frozen app: " + json_file includes = [ "PyQt4", "PyQt4.QtCore", "PyQt4.QtNetwork", "PyQt4.QtGui", "atexit", # implicitly required by PyQt4 "sqlalchemy.dialects.sqlite", ] attribs.append_includes(includes) excludes = [ "ipdb", "clf", "IronPython", "pydoc", "tkinter", ] if '--freeze' in sys.argv: print "Building standalone executable..." sys.argv.remove('--freeze') from nx_cx_Freeze import setup from cx_Freeze import Executable as cx_Executable from esky.util import get_platform # build_exe does not seem to take the package_dir info into account sys.path.append(attribs.get_path_append()) executables = [cx_Executable(script)] if sys.platform == "win32": # Windows GUI program that can be launched without a cmd # console script_w = attribs.get_win_script() if script_w is not None: scripts.append( es_Executable(script_w, icon=icon, shortcutDir="ProgramMenuFolder", shortcutName=attribs.shortcutName())) executables.append( cx_Executable(script_w, targetName=attribs.get_win_targetName(), base="Win32GUI", icon=icon, shortcutDir="ProgramMenuFolder", shortcutName=attribs.shortcutName())) package_data = {} esky_app_name = (attribs.get_name() + '-' + version + '.' + get_platform()) esky_dist_dir = os.path.join(OUTPUT_DIR, esky_app_name) freeze_options = dict( executables=executables, options={ "build": { "exe_command": "bdist_esky", }, "build_exe": { "includes": includes, "packages": packages + [ "nose", ], "excludes": excludes, "include_files": include_files, }, "bdist_esky": { "excludes": excludes, "enable_appdata_dir": True, "freezer_options": { "packages": packages + [ "nose", ], }, "rm_freeze_dir_after_zipping": False, }, "install": { "skip_sub_commands": "install_lib,install_scripts,install_data", }, "install_exe": { "skip_build": True, "build_dir": esky_dist_dir, }, "bdist_msi": { "add_to_path": True, "upgrade_code": '{800B7778-1B71-11E2-9D65-A0FD6088709B}', }, }, ) if sys.platform == 'darwin': # Under OSX we use py2app instead of cx_Freeze because we need: # - argv_emulation=True for nxdrive:// URL scheme handling # - easy Info.plist customization import py2app # install the py2app command name = attribs.get_CFBundleName() py2app_options = dict( iconfile=icon, argv_emulation=False, # We use QT for URL scheme handling plist=dict( CFBundleDisplayName=attribs.get_CFBundleDisplayName(), CFBundleName=attribs.get_CFBundleName(), CFBundleIdentifier=attribs.get_CFBundleIdentifier(), LSUIElement=True, # Do not launch as a Dock application CFBundleURLTypes=[ dict( CFBundleURLName=attribs.get_CFBundleURLName(), CFBundleURLSchemes=(attribs .get_CFBundleURLSchemes()), ) ] ), includes=includes, excludes=excludes, ) freeze_options = dict( app=attribs.get_app(), options=dict( py2app=py2app_options, bdist_esky=dict( enable_appdata_dir=True, create_zipfile=False, freezer_options=py2app_options, ) ) ) setup( name=name, version=version, description=attribs.get_description(), author=attribs.get_author(), author_email=attribs.get_author_email(), url=attribs.get_url(), packages=packages, package_dir=attribs.get_package_dir(), package_data=package_data, scripts=scripts, long_description=attribs.get_long_description(), data_files=data_files, **freeze_options ) if old_version is not None: update_version(init_file, old_version) print "Restored version to " + old_version
def __init__(self, attribs): from distutils.core import setup freeze_options = {} ext_modules = [] script = attribs.get_script() scripts = [script] name = attribs.get_name() packages = Packages(attribs.get_package_dirs()).load() package_data = attribs.get_package_data() icons_home = attribs.get_icons_home() ui5_home = attribs.get_ui5_home() if sys.platform == 'win32': icon = os.path.join(icons_home, attribs.get_win_icon()) elif sys.platform == 'darwin': icon = os.path.join(icons_home, attribs.get_osx_icon()) else: icon = os.path.join(icons_home, attribs.get_png_icon()) # Files to include in frozen app # build_exe freeze with cx_Freeze (Windows) include_files = attribs.get_includes() # bdist_esky freeze with cx_Freeze (Windows) and py2app (OS X) # In fact this is a global setup option # TODO NXP-13810: check removed data_files from py2app and added to # global setup icon_files = DataFileDir(icons_home, 'icons', include_files).load() ui5_files = DataFileDir(ui5_home, 'ui5', include_files).load_recursive() data_files = [('icons', icon_files)] data_files.extend(ui5_files) data_files.extend(attribs.get_data_files()) drive_version = get_version(attribs.get_init_file()) # Create JSON metadata file for the frozen application json_file = create_json_metadata(drive_version, SERVER_MIN_VERSION) print('Created JSON metadata file for frozen app: ' + json_file) includes = [ 'atexit', # Implicitly required by PyQt4 'js2py.pyjs', # Implicitly required by pypac ] excludes = [ 'ipdb', 'pydoc', 'yappi', ] if attribs.include_xattr_binaries(): includes.append('cffi') includes.append('xattr') else: excludes.append('cffi') excludes.append('xattr') attribs.append_includes(includes) if '--freeze' in sys.argv: print('Building standalone executable...') sys.argv.remove('--freeze') from nx_cx_Freeze import setup from cx_Freeze import Executable as cx_Executable from esky.util import get_platform # build_exe does not seem to take the package_dir info into account sys.path.insert(0, attribs.get_path_append()) try: packages.remove('nxdrive.data') except ValueError: pass executables = [cx_Executable(script)] freeze_options = dict() if sys.platform == 'win32': # Copy OpenSSL DLL data_files.append('libeay32.dll') data_files.append('ssleay32.dll') # Windows GUI program that can be launched without a cmd # console scripts.append(es_Executable( attribs.get_script(), icon=icon, shortcutDir='ProgramMenuFolder', shortcutName=attribs.shortcutName(), )) executables.append(cx_Executable( attribs.get_win_target_name(), targetName=attribs.get_win_target_name(), base='Win32GUI', icon=icon, shortcutDir='ProgramMenuFolder', shortcutName=attribs.shortcutName(), )) # Add a shortcut on the desktop executables.append(cx_Executable( attribs.get_win_target_name(), targetName=attribs.get_win_target_name(), base='Win32GUI', icon=icon, shortcutDir='DesktopFolder', shortcutName=attribs.shortcutName(), )) freeze_options.update({'attribs': attribs}) package_data = {} esky_app_name = (attribs.get_name() + '-' + drive_version + '.' + get_platform()) esky_dist_dir = os.path.join(OUTPUT_DIR, esky_app_name) freeze_options.update({ 'executables': executables, 'options': { 'build': { 'exe_command': 'bdist_esky', }, 'build_exe': { 'includes': includes, 'packages': packages, 'excludes': excludes, 'include_files': include_files, }, 'bdist_esky': { 'includes': includes, 'excludes': excludes, 'enable_appdata_dir': True, 'freezer_options': { 'packages': packages, }, 'rm_freeze_dir_after_zipping': False, }, 'install': { 'skip_sub_commands': 'install_lib,install_scripts,install_data', }, 'install_exe': { 'skip_build': True, 'build_dir': esky_dist_dir, }, 'bdist_msi': { 'add_to_path': True, 'upgrade_code': attribs.get_uid(), }, }, }) if sys.platform == 'darwin': # Under OSX we use py2app instead of cx_Freeze because we need: # - argv_emulation=True for nxdrive:// URL scheme handling # - easy Info.plist customization name = attribs.get_CFBundleName() py2app_options = { 'iconfile': icon, 'qt_plugins': 'imageformats', 'argv_emulation': False, # We use Qt for URL scheme handling 'plist': { 'CFBundleDisplayName': attribs.get_CFBundleDisplayName(), 'CFBundleName': attribs.get_CFBundleName(), 'CFBundleIdentifier': attribs.get_CFBundleIdentifier(), 'LSUIElement': True, # Do not launch as a Dock application 'CFBundleURLTypes': [{ 'CFBundleURLName': attribs.get_CFBundleURLName(), 'CFBundleURLSchemes': attribs.get_CFBundleURLSchemes(), }], 'NSServices': [{ 'NSMenuItem': { 'default': attribs.get_CFBundleDisplayName(), }, 'NSMessage': 'macRightClick', 'NSPortName': attribs.get_CFBundleDisplayName(), 'NSRequiredContext': {}, 'NSSendTypes': [ 'NSStringPboardType', ], 'NSSendFileTypes': [ 'public.item', ], }], }, 'includes': includes, 'excludes': excludes, } freeze_options = { 'app': scripts, 'options': { 'py2app': py2app_options, 'bdist_esky': { 'enable_appdata_dir': True, 'create_zipfile': False, 'freezer_options': py2app_options, } } } entry_points = {} if sys.platform == 'win32': entry_points = { 'console_scripts': ['ndrive=nxdrive.commandline:main'], 'gui_scripts': ['ndrivew=nxdrive.commandline:main'], } with warnings.catch_warnings(): # Hide Windows "Unknown distribution option: 'attribs'" warnings.simplefilter('ignore', category=UserWarning) setup( name=name, version=drive_version, description=attribs.get_description(), author=attribs.get_author(), author_email=attribs.get_author_email(), url=attribs.get_url(), packages=packages, package_dir=attribs.get_package_dir(), package_data=package_data, scripts=scripts, long_description=attribs.get_long_description(), data_files=data_files, ext_modules=ext_modules, entry_points=entry_points, platforms=['Darwin', 'Linux', 'Windows'], license=attribs.get_licence(), **freeze_options )