From e9e7b97c48ad5f8e322d049b8310637b20cf1ae3 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 16 Aug 2022 23:39:36 +0530 Subject: [PATCH] And we have frozen builds working with kitty-tool --- bypy/init_env.py | 9 +++++++++ bypy/linux/__main__.py | 4 +++- bypy/macos/__main__.py | 5 +++++ setup.py | 5 +++-- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/bypy/init_env.py b/bypy/init_env.py index 1678d90bc..16bbf9103 100644 --- a/bypy/init_env.py +++ b/bypy/init_env.py @@ -77,6 +77,15 @@ def run_tests(kitty_exe): raise SystemExit('Checking of kitty build failed') +def build_frozen_tools(kitty_exe): + cmd = SETUP_CMD + ['--prefix', os.path.dirname(kitty_exe)] + ['build-frozen-tools'] + if run(*cmd, cwd=build_frozen_launcher.writeable_src_dir) != 0: + print('Building of frozen kitty-tool failed', file=sys.stderr) + os.chdir(KITTY_DIR) + run_shell() + raise SystemExit('Building of kitty-tool launcher failed') + + def sanitize_source_folder(path: str) -> None: for q in walk(path): if os.path.splitext(q)[1] not in ('.py', '.glsl', '.ttf', '.otf'): diff --git a/bypy/linux/__main__.py b/bypy/linux/__main__.py index 52bc7783c..819f3ae0c 100644 --- a/bypy/linux/__main__.py +++ b/bypy/linux/__main__.py @@ -238,10 +238,12 @@ def main(): files = find_binaries(env) fix_permissions(files) add_ca_certs(env) + kitty_exe = os.path.join(env.base, 'bin', 'kitty') + iv['build_frozen_tools'](kitty_exe) if not args.dont_strip: strip_binaries(files) if not args.skip_tests: - iv['run_tests'](os.path.join(env.base, 'bin', 'kitty')) + iv['run_tests'](kitty_exe) create_tarfile(env, args.compression_level) diff --git a/bypy/macos/__main__.py b/bypy/macos/__main__.py index 4b6c4bc01..c42f09d27 100644 --- a/bypy/macos/__main__.py +++ b/bypy/macos/__main__.py @@ -171,6 +171,7 @@ class Freeze(object): self.add_misc_libraries() self.freeze_python() self.add_ca_certs() + self.build_frozen_tools() if not self.dont_strip: self.strip_files() if not self.skip_tests: @@ -378,6 +379,10 @@ class Freeze(object): if f.endswith('.so') or f.endswith('.dylib'): self.fix_dependencies_in_lib(f) + @flush + def build_frozen_tools(self): + iv['build_frozen_tools'](join(self.contents_dir, 'MacOS', 'kitty')) + @flush def add_site_packages(self): print('\nAdding site-packages') diff --git a/setup.py b/setup.py index e41913d34..b54011300 100755 --- a/setup.py +++ b/setup.py @@ -1483,6 +1483,7 @@ def option_parser() -> argparse.ArgumentParser: # {{{ 'macos-freeze', 'build-launcher', 'build-frozen-launcher', + 'build-frozen-tools', 'clean', 'export-ci-bundles', 'build-dep', @@ -1689,7 +1690,8 @@ def main() -> None: init_env_from_args(args, False) bundle_type = ('macos' if is_macos else 'linux') + '-freeze' build_launcher(args, launcher_dir=os.path.join(args.prefix, 'bin'), bundle_type=bundle_type) - build_kitty_tool(args, launcher_dir=os.path.join(args.prefix, 'bin')) + elif args.action == 'build-frozen-tools': + build_kitty_tool(args, launcher_dir=args.prefix) elif args.action == 'linux-package': build(args, native_optimizations=False) package(args, bundle_type='linux-package') @@ -1699,7 +1701,6 @@ def main() -> None: elif args.action == 'macos-freeze': init_env_from_args(args, native_optimizations=False) build_launcher(args, launcher_dir=launcher_dir) - build_kitty_tool(args, launcher_dir=launcher_dir) build(args, native_optimizations=False, call_init=False) package(args, bundle_type='macos-freeze') elif args.action == 'kitty.app':