Ejemplo n.º 1
0
def build_windows_pkg():
    print('building demo NSIS installer')
    root_path = os.getcwd()

    print('removing old build directories')
    build_path = os.path.join(root_path, 'build')
    dist_path = os.path.join(root_path, 'dist')

    if os.path.exists(build_path):
        shutil.rmtree(build_path)

    if os.path.exists(dist_path):
        shutil.rmtree(dist_path)

    print('freezing images')
    freeze_images()

    print('calling build_ui.py')
    system('cd {0} && python build_ui.py'.format(UNDERSCORE_NAME))

    print('calling setup.py py2exe')
    system('python setup.py py2exe')

    # FIXME: doesn't work yet
    #if os.path.exists('X:\\sign.bat'):
    #    sign_py2exe('dist\\{0}.exe'.format(UNDERSCORE_NAME))

    print('creating NSIS script from template')
    nsis_template_path = os.path.join(root_path, 'build_data', 'windows', 'nsis', '{0}_installer.nsi.template'.format(UNDERSCORE_NAME))
    nsis_path = os.path.join(dist_path, 'nsis', '{0}_installer.nsi'.format(UNDERSCORE_NAME))
    specialize_template(nsis_template_path, nsis_path,
                        {'<<DEMO_DOT_VERSION>>': DEMO_VERSION,
                         '<<DEMO_UNDERSCORE_VERSION>>': DEMO_VERSION.replace('.', '_')})

    print('building NSIS installer')
    system('"C:\\Program Files\\NSIS\\makensis.exe" dist\\nsis\\{0}_installer.nsi'.format(UNDERSCORE_NAME))
    installer = '{0}_windows_{1}.exe'.format(UNDERSCORE_NAME, DEMO_VERSION.replace('.', '_'))

    if os.path.exists(installer):
        os.unlink(installer)

    shutil.move(os.path.join(dist_path, 'nsis', installer), root_path)

    if os.path.exists('X:\\sign.bat'):
        system('X:\\sign.bat ' + installer)
Ejemplo n.º 2
0
def build_macosx_pkg():
    print('building demo disk image')
    root_path = os.getcwd()

    print('removing old build directories')
    build_path = os.path.join(root_path, 'build')
    dist_path = os.path.join(root_path, 'dist')

    if os.path.exists(build_path):
        shutil.rmtree(build_path)

    if os.path.exists(dist_path):
        shutil.rmtree(dist_path)

    print('freezing images')
    freeze_images()

    print('calling build_ui.py')
    system('cd {0}; python build_ui.py'.format(UNDERSCORE_NAME))

    print('calling setup.py py2app build')
    system('python setup.py py2app build')

    print('copying build data')
    build_data_path = os.path.join(root_path, 'build_data', 'macosx', '*')
    resources_path = os.path.join(dist_path, '{0}.app'.format(CAMEL_CASE_NAME), 'Contents', 'Resources')
    system('cp -R {0} "{1}"'.format(build_data_path, resources_path))

    print('patching __boot__.py')
    boot_path = os.path.join(resources_path, '__boot__.py')
    boot_prefix = 'import os\nimport sys\nos.environ["RESOURCEPATH"] = os.path.dirname(os.path.realpath(__file__))\n'

    with open(boot_path, 'rb') as f:
        boot = f.read()

    with open(boot_path, 'wb') as f:
        f.write(boot_prefix + boot)

    print('building disk image')
    dmg_name = '{0}_macos_{1}.dmg'.format(UNDERSCORE_NAME, DEMO_VERSION.replace('.', '_'))

    if os.path.exists(dmg_name):
        os.remove(dmg_name)

    system('hdiutil create -fs HFS+ -volname "{0}-{1}" -srcfolder dist {2}'
           .format(CAMEL_CASE_NAME.replace(' ', '-'), DEMO_VERSION, dmg_name))