示例#1
0
def bundle_update(c):
    """
    Bundles the frozen app for use in updates.
    Uses zip and lzma compression.
    """
    print("Preparing update bundle...")
    if sys.platform != "win32":
        print("Update bundles are only supported for Windows. Skipping...")
        return
    from bookworm import app
    from bookworm.utils import recursively_iterdir

    env = os.environ
    frozen_dir = Path(env["IAPP_FROZEN_DIRECTORY"])
    if app.get_version_info()["post"] is None:
        files_to_bundle = recursively_iterdir(frozen_dir)
    else:
        files_to_bundle = [
            frozen_dir / "Bookworm.exe",
        ]
    fname = f"{env['IAPP_DISPLAY_NAME']}-{env['IAPP_VERSION']}-{env['IAPP_ARCH']}-update.bundle"
    bundle_file = PROJECT_ROOT / "scripts" / fname
    with ZipFile(bundle_file, "w", compression=ZIP_LZMA,
                 allowZip64=False) as archive:
        for file in files_to_bundle:
            archive.write(file, file.relative_to(frozen_dir))
        archive.write(
            PROJECT_ROOT / "scripts" / "executables" / "bootstrap.exe",
            "bootstrap.exe")
    print("Done preparing update bundle.")
示例#2
0
def freeze(c):
    """Freeze the app using pyinstaller."""
    from bookworm import app

    print("Freezing the application...")
    with c.cd(str(PROJECT_ROOT / "scripts" / "builder")):
        if app.get_version_info()["pre_type"] is None:
            print(
                "The current build is a final release. Turnning on python optimizations..."
            )
            os.environ["PYTHONOPTIMIZE"] = "2"
        c.run(
            f"pyinstaller Bookworm.spec --clean -y --distpath {c['build_folder'].parent}",
            hide=True,
        )
    print("App freezed. Trying to copy system dlls.")
    copy_deps(c)
示例#3
0
def update_version_info(c):
    from bookworm import app
    from bookworm.utils import generate_sha1hash

    artifacts_folder = PROJECT_ROOT / "scripts"
    json_file = artifacts_folder / "release-info.json"
    release_type = app.get_version_info()["pre_type"] or ""
    json_info = {release_type: {"version": app.version}}
    artifacts = dict(
        installer=artifacts_folder.glob("Bookworm*setup.exe"),
        update_bundle=artifacts_folder.glob("Bookworm*update.bundle"),
    )
    for artifact_type, artifact_files in artifacts.items():
        for file in artifact_files:
            json_info[release_type][
                f"{file.name}.sha1hash"] = generate_sha1hash(file)
    json_file.write_text(json.dumps(json_info, indent=2))
    print("Updated version information")
示例#4
0
def freeze(c):
    """Freeze the app using pyinstaller."""
    from bookworm import app

    print("Freezing the application...")
    with c.cd(str(PROJECT_ROOT / "scripts" / "builder")):
        if app.get_version_info()["pre_type"] is None:
            print(
                "The current build is a final release. Turnning on python optimizations..."
            )
            os.environ["PYTHONOPTIMIZE"] = "2"
        c.run(
            f"pyinstaller Bookworm.spec --clean -y --distpath {c['build_folder'].parent}",
            hide=True,
        )
    print("App freezed.")
    print("Cleaning up junk folders from the frozen executable directory.")
    for dist_info_dir in (dinfo
                          for dinfo in c['build_folder'].glob("*.dist-info")
                          if dinfo.is_dir()):
        shutil.rmtree(os.fspath(dist_info_dir))