Skip to content

Make videos on the computer you already own. FreeVideo runs MiniMax H3 in as little as 8 GB of VRAM and 16 GB of RAM, and adapts its acceleration path to your hardware.

Installers: prune Qt bundle payloads, dedupe data and recompress for Windows and Linux

Bowen Xue67b54a20ab1d
diff --git a/MANIFEST.in b/MANIFEST.in
index 4ff0468..2309e5f 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -16,6 +16,8 @@ include scripts/bootstrap_linux.sh scripts/build_windows.py scripts/windows_app.
include scripts/build_macos.py scripts/macos_app.py scripts/verify_macos_build.py
include scripts/scan_windows_release.py
include scripts/build_launcher_notices.py
+include scripts/prune_qt_bundle.py scripts/deduplicate_bundle_data.py scripts/pyi_rth_bundle_data.py
+include scripts/verify_dmg_conversion.py
prune docs
include docs/LoRA.md docs/LoRA.zh-CN.md
prune tests
diff --git a/scripts/build_linux.py b/scripts/build_linux.py
index b1988c2..5d4e4ba 100644
--- a/scripts/build_linux.py
+++ b/scripts/build_linux.py
@@ -27,6 +27,8 @@ from freevideo_engine.launcher_update import LINUX_CHANNEL, RELEASE_ASSETS, buil
from freevideo_engine.release_notes import markdown
from scripts.build_launcher_notices import collect as collect_notices
from scripts.build_windows import build_info, bundle_data_args, stamp_source
+from scripts.prune_qt_bundle import prune_qt_bundle, write_prune_report
+from scripts.deduplicate_bundle_data import deduplicate_bundle_data, write_data_report
APP_ID = 'org.flashml.FreeVideo'
NAME = RELEASE_ASSETS[LINUX_CHANNEL][0]
@@ -224,13 +226,19 @@ def main():
str(ROOT / 'scripts/linux_app.py')]
subprocess.run(command, cwd=ROOT, check=True)
dist = out / 'dist' / 'FreeVideo'
+ write_prune_report(out, prune_qt_bundle(dist))
bundled = bundle_libraries(dist / '_internal', args.libraries.resolve() if args.libraries else None)
folder = appdir(out, dist, ROOT / 'freevideo_engine/assets/icon.png')
+ # copytree expands hardlinks: deduplicate the final AppDir, after copying.
+ write_data_report(out, deduplicate_bundle_data(folder))
release = out / 'release'
release.mkdir()
executable = release / NAME
env = dict(os.environ, ARCH='x86_64', APPIMAGE_EXTRACT_AND_RUN='1')
- subprocess.run([str(appimagetool), '--no-appstream', '--runtime-file', str(runtime), str(folder), str(executable)],
+ subprocess.run([str(appimagetool), '--no-appstream', '--runtime-file', str(runtime), '--comp', 'zstd',
+ '--mksquashfs-opt=-b', '--mksquashfs-opt=1M',
+ '--mksquashfs-opt=-Xcompression-level', '--mksquashfs-opt=19',
+ str(folder), str(executable)],
cwd=out, env=env, check=True)
digest = hashlib.sha256(executable.read_bytes()).hexdigest()
(release / 'SHA256SUMS.txt').write_text(digest + ' ' + NAME + '\n', encoding='utf-8')
diff --git a/scripts/build_windows.py b/scripts/build_windows.py
index 59e20ed..bfb5d6f 100644
--- a/scripts/build_windows.py
+++ b/scripts/build_windows.py
@@ -16,6 +16,8 @@ from freevideo_engine.desktop_runtime import check_launcher_dependencies, packag
from freevideo_engine.launcher_update import REPOSITORY, CHANNEL, TRACKS
from freevideo_engine.release_notes import catalog, markdown
from scripts.build_launcher_notices import collect as collect_notices
+from scripts.prune_qt_bundle import prune_qt_bundle, write_prune_report
+from scripts.deduplicate_bundle_data import deduplicate_bundle_data, write_data_report
def release_track():
@@ -96,6 +98,50 @@ VSVersionInfo(
return path
+def build_pyinstaller(command, out, *, onefolder):
+ # Windows onefile has no tree to prune after EXE: use exactly the same
+ # globs on Analysis TOCs before PyInstaller writes its compressed archive.
+ # Generate the usual spec so all bootloader/version/manifest defaults stay
+ # those of the pinned PyInstaller, then insert only our build-time filter.
+ options, i = [], 3
+ while i < len(command):
+ option = command[i]
+ if option in ('--distpath', '--workpath'):
+ i += 2
+ continue
+ if option != '--noconfirm':
+ options.append(option)
+ i += 1
+ if not onefolder:
+ options += ['--runtime-hook', str(ROOT / 'scripts/pyi_rth_bundle_data.py')]
+ subprocess.run([sys.executable, '-m', 'PyInstaller.utils.cliutils.makespec', *options], cwd=ROOT, check=True)
+ spec = out / 'FreeVideo.spec'
+ if not onefolder:
+ injection = f'''
+import sys
+sys.path.insert(0, {str(ROOT)!r})
+from scripts.prune_qt_bundle import prune_qt_toc, write_prune_report
+from scripts.deduplicate_bundle_data import deduplicate_toc, write_data_report
+a.binaries, removed_binaries = prune_qt_toc(a.binaries)
+a.datas, removed_data = prune_qt_toc(a.datas)
+write_prune_report({str(out)!r}, dict(files=removed_binaries['files'] + removed_data['files'],
+ bytes=removed_binaries['bytes'] + removed_data['bytes']))
+a.datas, deduplicated = deduplicate_toc(a.datas, {str(out)!r})
+write_data_report({str(out)!r}, deduplicated)
+'''
+ text = spec.read_text(encoding='utf-8')
+ if text.count('pyz = PYZ(') != 1:
+ raise ValueError('Unexpected PyInstaller spec layout')
+ spec.write_text(text.replace('pyz = PYZ(', injection + '\npyz = PYZ('), encoding='utf-8')
+ subprocess.run([sys.executable, '-m', 'PyInstaller', '--noconfirm',
+ '--distpath', str(out / 'dist'), '--workpath', str(out / 'build'), str(spec)],
+ cwd=ROOT, check=True)
+ if onefolder:
+ dist = out / 'dist/FreeVideo'
+ write_prune_report(out, prune_qt_bundle(dist))
+ write_data_report(out, deduplicate_bundle_data(dist))
+
+
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--out', type=Path, required=True)
@@ -142,7 +188,7 @@ def main():
'--exclude-module', 'torch', '--exclude-module', 'triton', '--exclude-module', 'numpy',
'--exclude-module', 'transformers', '--exclude-module', 'tkinter',
str(ROOT / 'scripts/windows_app.py')]
- subprocess.run(command, cwd=ROOT, check=True)
+ build_pyinstaller(command, out, onefolder=args.onefolder)
executable = out / 'dist' / ('FreeVideo/FreeVideo.exe' if args.onefolder else 'FreeVideo.exe')
digest = hashlib.sha256(executable.read_bytes()).hexdigest()
(executable.parent / 'SHA256SUMS.txt').write_text(digest + ' FreeVideo.exe\n', encoding='utf-8')
diff --git a/scripts/deduplicate_bundle_data.py b/scripts/deduplicate_bundle_data.py
new file mode 100644
index 0000000..8445522
--- /dev/null
+++ b/scripts/deduplicate_bundle_data.py
@@ -0,0 +1,66 @@
+"""Keep both frozen-resource and engine-source paths with one stored payload."""
+import json
+import os
+from pathlib import Path
+
+from scripts.prune_qt_bundle import checked_path
+
+LINK_MANIFEST = '_freevideo-data-links.json'
+
+
+def deduplicate_bundle_data(dist, *, symbolic=False):
+ """Only replace byte-identical regular files; symlinks stay inside dist."""
+ dist = Path(dist).resolve(strict=True)
+ rows = []
+ for source_root in sorted(dist.rglob('engine-source')):
+ if not source_root.is_dir() or source_root.is_symlink():
+ continue
+ internal = source_root.parent
+ for source in sorted(source_root.rglob('*')):
+ if source.is_symlink() or not source.is_file():
+ continue
+ target = internal / source.relative_to(source_root)
+ if target.is_symlink() or not target.is_file():
+ continue
+ checked_path(source, dist)
+ checked_path(target, dist)
+ if source.samefile(target) or source.read_bytes() != target.read_bytes():
+ continue
+ size = target.stat().st_size
+ temporary = target.with_name(target.name + '.dedup-link')
+ if symbolic:
+ temporary.symlink_to(os.path.relpath(source, target.parent))
+ else:
+ os.link(source, temporary)
+ temporary.replace(target)
+ rows.append(dict(path=target.relative_to(dist).as_posix(),
+ source=source.relative_to(dist).as_posix(), bytes=size))
+ return dict(files=rows, bytes=sum(row['bytes'] for row in rows))
+
+
+def deduplicate_toc(entries, out):
+ """Onefile stores one copy; its packaging hook restores hardlink aliases.
+
+ Do this only for a onefile extraction, which is owned and writable. An
+ installed onedir tree must be complete before a normal user launches it.
+ """
+ sources = {name.replace('\\', '/'): source for name, source, kind in entries if kind == 'DATA'}
+ kept, rows = [], []
+ for entry in entries:
+ name, source, kind = entry
+ name = name.replace('\\', '/')
+ canonical = 'engine-source/' + name
+ if (kind == 'DATA' and not name.startswith('engine-source/') and canonical in sources
+ and Path(source).read_bytes() == Path(sources[canonical]).read_bytes()):
+ rows.append(dict(path=name, source=canonical, bytes=Path(source).stat().st_size))
+ else:
+ kept.append(entry)
+ manifest = Path(out) / LINK_MANIFEST
+ manifest.write_text(json.dumps(rows, indent=2) + '\n', encoding='utf-8')
+ kept.append((LINK_MANIFEST, str(manifest), 'DATA'))
+ return kept, dict(files=rows, bytes=sum(row['bytes'] for row in rows))
+
+
+def write_data_report(out, result):
+ (Path(out) / 'data-deduplicated.json').write_text(json.dumps(result, indent=2) + '\n', encoding='utf-8')
+ print('Data dedup: %d files, %d bytes' % (len(result['files']), result['bytes']), flush=True)
diff --git a/scripts/prune_qt_bundle.py b/scripts/prune_qt_bundle.py
new file mode 100644
index 0000000..39dc71d
--- /dev/null
+++ b/scripts/prune_qt_bundle.py
@@ -0,0 +1,102 @@
+"""Build-only Qt exclusions for the software-rendered, Basic-style launcher."""
+from fnmatch import fnmatchcase
+import json
+import os
+from pathlib import Path, PurePosixPath
+import shutil
+
+
+UNUSED_STYLES = ('FluentWinUI3', 'Fusion', 'Imagine', 'Material', 'Universal',
+ 'Windows', 'macOS', 'iOS')
+UNUSED_MODULES = ('QtQuick/Dialogs', 'QtWayland/Compositor', 'QtTest', 'Qt/labs',
+ 'QtQuick/Particles', 'QtQuick/VectorImage', 'QtQuick/Effects',
+ 'QtQuick/Timeline', 'QtQuick/Timeline/BlendTrees', 'QtQuick/Pdf', 'QtPdf',
+ 'QtQuick/LocalStorage', 'QtQml/XmlListModel', 'QtQuick/VirtualKeyboard')
+UNUSED_LIBRARIES = (
+ 'Labs*', 'QuickControls2FluentWinUI3StyleImpl', 'QuickControls2Fusion*',
+ 'QuickControls2Imagine*', 'QuickControls2Material*', 'QuickControls2Universal*',
+ 'QuickControls2WindowsStyleImpl', 'QuickControls2MacOSStyleImpl', 'QuickControls2IOSStyleImpl',
+ 'QuickDialogs2*', 'WaylandCompositor*', 'Test', 'QuickTest', 'QuickParticles',
+ 'QuickVectorImage*', 'QuickEffects', 'QuickTimeline*', 'Pdf*', 'Sql',
+ 'QmlLocalStorage', 'QmlXmlListModel', 'VirtualKeyboard*',
+)
+# Relative to PySide6, across Windows wheels, Unix wheels and macOS frameworks.
+# Keep Controls/Basic, Controls/impl, Templates, QtQuick, Layouts, Widgets and
+# Wayland *client* plugins. No broad "Qt*" or platform-plugin exclusions.
+QT_PRUNE_GLOBS = (
+ 'opengl32sw.dll', 'Qt/opengl32sw.dll', 'translations', 'Qt/translations',
+ *(f'{prefix}qml/QtQuick/Controls/{style}' for prefix in ('', 'Qt/') for style in UNUSED_STYLES),
+ *(f'{prefix}qml/{module}' for prefix in ('', 'Qt/') for module in UNUSED_MODULES),
+ *(f'{prefix}plugins/{plugin}' for prefix in ('', 'Qt/')
+ for plugin in ('qmltooling', 'platforms/qdirect2d.dll', 'sqldrivers', 'virtualkeyboard')),
+ *(f'Qt6{library}.dll' for library in UNUSED_LIBRARIES),
+ *(f'Qt/lib/libQt6{library}.so*' for library in UNUSED_LIBRARIES),
+ *(f'Qt/lib/Qt{library}.framework' for library in UNUSED_LIBRARIES),
+ *(f'Qt/lib/libQt6{library}*.dylib' for library in UNUSED_LIBRARIES),
+ 'QtTest*.pyd', 'QtTest*.so', 'QtSql*.pyd', 'QtSql*.so',
+ 'QtPdf*.pyd', 'QtPdf*.so',
+)
+
+
+def should_prune(name):
+ """The same matcher serves emitted bundles and PyInstaller onefile TOCs."""
+ parts = PurePosixPath(str(name).replace('\\', '/')).parts
+ if 'PySide6' not in parts:
+ return False
+ relative = '/'.join(parts[parts.index('PySide6') + 1:])
+ return any(fnmatchcase(relative, pattern) or fnmatchcase(relative, pattern + '/*')
+ for pattern in QT_PRUNE_GLOBS)
+
+
+def checked_path(path, dist):
+ if not path.resolve().is_relative_to(dist) or path == dist:
+ raise ValueError('Bundle path escapes dist: ' + str(path))
+
+
+def prune_qt_bundle(dist):
+ """Remove only explicit Qt globs; return every removed entry and real bytes."""
+ dist = Path(dist).resolve(strict=True)
+ selected, rows = [], []
+ for folder, dirs, files in os.walk(dist, followlinks=False):
+ for name in sorted(dirs + files):
+ path = Path(folder) / name
+ if should_prune(path.relative_to(dist)):
+ checked_path(path, dist)
+ selected.append(path)
+ if name in dirs:
+ dirs.remove(name)
+ # Validate all descendants before making any change. Never follow directory links.
+ for path in selected:
+ entries = [path]
+ if path.is_dir() and not path.is_symlink():
+ entries += list(path.rglob('*'))
+ for entry in entries:
+ checked_path(entry, dist)
+ if entry.is_file() or entry.is_symlink():
+ rows.append(dict(path=entry.relative_to(dist).as_posix(),
+ bytes=0 if entry.is_symlink() else entry.stat().st_size))
+ for path in selected:
+ if path.is_dir() and not path.is_symlink():
+ shutil.rmtree(path)
+ else:
+ path.unlink()
+ return dict(files=sorted(rows, key=lambda row: row['path']),
+ bytes=sum(row['bytes'] for row in rows))
+
+
+def prune_qt_toc(entries):
+ """Onefile has no emitted tree: filter after Analysis, before its CArchive."""
+ kept, rows = [], []
+ for entry in entries:
+ name, source, kind = entry
+ if should_prune(name):
+ size = Path(source).stat().st_size if kind != 'SYMLINK' else 0
+ rows.append(dict(path=name, bytes=size))
+ else:
+ kept.append(entry)
+ return kept, dict(files=rows, bytes=sum(row['bytes'] for row in rows))
+
+
+def write_prune_report(out, result):
+ (Path(out) / 'qt-pruned.json').write_text(json.dumps(result, indent=2) + '\n', encoding='utf-8')
+ print('Qt prune: %d files, %d bytes' % (len(result['files']), result['bytes']), flush=True)
diff --git a/scripts/pyi_rth_bundle_data.py b/scripts/pyi_rth_bundle_data.py
new file mode 100644
index 0000000..daf21f4
--- /dev/null
+++ b/scripts/pyi_rth_bundle_data.py
@@ -0,0 +1,27 @@
+"""Restore data aliases in an owned PyInstaller onefile extraction on Windows."""
+
+
+def restore_data_links(bundle):
+ import json
+ import os
+ from pathlib import Path
+ import shutil
+
+ bundle = Path(bundle).resolve()
+ rows = json.loads((bundle / '_freevideo-data-links.json').read_text(encoding='utf-8'))
+ for row in rows:
+ source, target = bundle / row['source'], bundle / row['path']
+ if not source.resolve().is_relative_to(bundle) or not target.resolve().is_relative_to(bundle):
+ raise ValueError('Data alias escapes the extracted bundle')
+ target.parent.mkdir(parents=True, exist_ok=True)
+ try:
+ os.link(source, target)
+ except OSError:
+ # FAT/exFAT or a policy forbidding hardlinks must still launch. The
+ # archive contains only one copy even if extraction needs a copy.
+ shutil.copyfile(source, target)
+
+
+if __name__ == '__main__':
+ import sys
+ restore_data_links(sys._MEIPASS)
diff --git a/scripts/verify_dmg_conversion.py b/scripts/verify_dmg_conversion.py
new file mode 100644
index 0000000..e32cfdd
--- /dev/null
+++ b/scripts/verify_dmg_conversion.py
@@ -0,0 +1,68 @@
+"""Verify both disk images, mounted signatures and every payload file after convert."""
+import argparse
+import json
+from pathlib import Path
+import subprocess
+import sys
+
+sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
+from scripts.verify_macos_build import snapshot
+
+
+def verify_conversion(original, converted, out, *, command_runner=None):
+ """Mac commands are injectable so failure/cleanup checks run on Linux."""
+ run = command_runner or subprocess.run
+ out = Path(out).resolve()
+ out.mkdir(parents=True, exist_ok=False)
+ mounted, commands, manifests = [], [], []
+ result = dict(success=False)
+
+ def command(args):
+ commands.append(args)
+ return run(args, check=True, capture_output=True, text=True, timeout=180)
+
+ try:
+ for label, image in (('original', original), ('converted', converted)):
+ command(['/usr/bin/hdiutil', 'verify', str(image)])
+ mount = out / (label + '.noindex')
+ mount.mkdir()
+ command(['/usr/bin/hdiutil', 'attach', '-readonly', '-nobrowse', '-noautoopen',
+ '-mountpoint', str(mount), str(image)])
+ mounted.append(mount)
+ command(['/usr/bin/codesign', '--verify', '--deep', '--strict', str(mount / 'FreeVideo.app')])
+ manifest = snapshot(mount)
+ (out / (label + '-files.json')).write_text(json.dumps(manifest, indent=2) + '\n', encoding='utf-8')
+ manifests.append(manifest)
+ differences = [name for name in sorted(set(manifests[0]) | set(manifests[1]))
+ if manifests[0].get(name) != manifests[1].get(name)]
+ if differences:
+ result['differences'] = differences
+ raise ValueError('Converted DMG payload differs from original')
+ result.update(success=True, files=sum(row['kind'] == 'file' for row in manifests[0].values()),
+ images_verified=True, mounted_signatures_verified=True, payload_sha256_equal=True)
+ except Exception as error:
+ result['error'] = str(error)
+ finally:
+ for mount in reversed(mounted):
+ try:
+ command(['/usr/bin/hdiutil', 'detach', str(mount)])
+ except Exception as error:
+ result.update(success=False, detach_error=str(error))
+ result['commands'] = commands
+ (out / 'result.json').write_text(json.dumps(result, indent=2) + '\n', encoding='utf-8')
+ return result
+
+
+def main():
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument('--build', type=Path, required=True)
+ parser.add_argument('--out', type=Path, required=True)
+ args = parser.parse_args()
+ build = json.loads((args.build / 'build-result.json').read_text(encoding='utf-8'))
+ result = verify_conversion(build['original_dmg'], build['dmg'], args.out)
+ print(json.dumps({key: value for key, value in result.items() if key != 'commands'}))
+ raise SystemExit(not result['success'])
+
+
+if __name__ == '__main__':
+ main()