Exemplo n.º 1
0
def installer():
    """
    Create an installer for your app
    """
    if is_windows():
        from fbs.installer.windows import create_installer_windows
        create_installer_windows()
    elif is_mac():
        from fbs.installer.mac import create_installer_mac
        create_installer_mac()
    else:
        raise RuntimeError('Unsupported OS')
Exemplo n.º 2
0
def run_pyinstaller(extra_args=None):
    if extra_args is None:
        extra_args = []
    app_name = SETTINGS['app_name']
    cmdline = [
        'pyinstaller', '--name', app_name, '--noupx', '--log-level', 'WARN'
    ] + extra_args + [
        '--distpath',
        path('target'), '--specpath',
        path('target/PyInstaller'), '--workpath',
        path('target/PyInstaller'), SETTINGS['main_module']
    ]
    run(cmdline, check=True)
    output_dir = path('target/' + app_name + ('.app' if is_mac() else ''))
    rename(output_dir, path('target/App.app'))
Exemplo n.º 3
0
def generate_resources():
    freeze_dir = path('${freeze_dir}')
    if is_mac():
        resources_dest_dir = join(freeze_dir, 'Contents', 'Resources')
    else:
        resources_dest_dir = freeze_dir
    kwargs = {'files_to_filter': SETTINGS['resources_to_filter']}
    resource_dirs = (
        path('src/main/resources/base'),
        path('src/main/resources/' + platform.name().lower())
    )
    for dir_ in resource_dirs:
        if exists(dir_):
            copy_with_filtering(dir_, resources_dest_dir, **kwargs)
        frozen_resources_dir = dir_ + '-frozen'
        if exists(frozen_resources_dir):
            copy_with_filtering(frozen_resources_dir, freeze_dir, **kwargs)
Exemplo n.º 4
0
def run_pyinstaller(extra_args=None, debug=False):
    if extra_args is None:
        extra_args = []
    app_name = SETTINGS['app_name']
    log_level = 'DEBUG' if debug else 'WARN'
    cmdline = [
        'pyinstaller', '--name', app_name, '--noupx', '--log-level', log_level
    ] + extra_args + [
        '--distpath',
        path('target'), '--specpath',
        path('target/PyInstaller'), '--workpath',
        path('target/PyInstaller'), SETTINGS['main_module']
    ]
    if debug:
        cmdline.append('--debug')
    run(cmdline, check=True)
    output_dir = path('target/' + app_name + ('.app' if is_mac() else ''))
    rename(output_dir, path('${freeze_dir}'))
Exemplo n.º 5
0
def freeze(debug=False):
    """
    Compile your application to a standalone executable
    """
    # Import respective functions late to avoid circular import
    # fbs <-> fbs.freeze.X:
    if is_windows():
        from fbs.freeze.windows import freeze_windows
        freeze_windows(debug=debug)
    elif is_mac():
        from fbs.freeze.mac import freeze_mac
        freeze_mac(debug=debug)
    elif is_linux():
        if is_arch_linux():
            from fbs.freeze.arch import freeze_arch
            freeze_arch(debug=debug)
        else:
            from fbs.freeze.linux import freeze_linux
            freeze_linux(debug=debug)
    else:
        raise RuntimeError('Unsupported OS')
Exemplo n.º 6
0
def generate_resources():
    """
    Copy the data files from src/main/resources to the target/ directory.
    Automatically filters files mentioned in the setting resources_to_filter:
    Placeholders such as ${app_name} are automatically replaced by the
    corresponding setting in files on that list.
    """
    freeze_dir = path('${freeze_dir}')
    if is_mac():
        resources_dest_dir = join(freeze_dir, 'Contents', 'Resources')
    else:
        resources_dest_dir = freeze_dir
    kwargs = {'files_to_filter': SETTINGS['resources_to_filter']}
    resource_dirs = (path('src/main/resources/base'),
                     path('src/main/resources/' + platform.name().lower()))
    for dir_ in resource_dirs:
        if exists(dir_):
            copy_with_filtering(dir_, resources_dest_dir, **kwargs)
        frozen_resources_dir = dir_ + '-frozen'
        if exists(frozen_resources_dir):
            copy_with_filtering(frozen_resources_dir, freeze_dir, **kwargs)
Exemplo n.º 7
0
def freeze():
    """
	Compile your application to target/App.app
	"""
    # Import respective functions late to avoid circular import
    # fbs <-> fbs.freeze.X:
    if is_windows():
        from fbs.freeze.windows import freeze_windows
        freeze_windows()
    elif is_mac():
        from fbs.freeze.mac import freeze_mac
        freeze_mac()
    elif is_linux():
        if is_arch_linux():
            from fbs.freeze.arch import freeze_arch
            freeze_arch()
        else:
            from fbs.freeze.linux import freeze_linux
            freeze_linux()
    else:
        raise RuntimeError('Unsupported OS')