|
|
|
@ -11,9 +11,8 @@ from pathlib import Path |
|
|
|
|
from openpilot.common.basedir import BASEDIR |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ENTRYPOINT = 'main' |
|
|
|
|
EXTS = ['.png', '.py'] |
|
|
|
|
INTERPRETER = '/usr/bin/env python3' |
|
|
|
|
EXTS = ['.py', '.png'] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def copy(src, dest, follow_symlinks=False): |
|
|
|
@ -22,9 +21,10 @@ def copy(src, dest, follow_symlinks=False): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
|
|
|
parser = ArgumentParser(prog='pack-raylib.py', description='Package a raylib UI into a portable executable.', epilog='comma.ai') |
|
|
|
|
parser = ArgumentParser(prog='pack-raylib.py', description="package openpilot's raylib code into a portable executable", epilog='comma.ai') |
|
|
|
|
parser.add_argument('-e', '--entrypoint', help="function to call in module, default is 'main'", default='main') |
|
|
|
|
parser.add_argument('-o', '--output', help='output file') |
|
|
|
|
parser.add_argument('module') |
|
|
|
|
parser.add_argument('module', help="the module to target, e.g. 'openpilot.system.ui.spinner'") |
|
|
|
|
args = parser.parse_args() |
|
|
|
|
|
|
|
|
|
if not args.output: |
|
|
|
@ -36,13 +36,13 @@ if __name__ == '__main__': |
|
|
|
|
print(f'{args.module} not found, typo?') |
|
|
|
|
sys.exit(1) |
|
|
|
|
|
|
|
|
|
if not hasattr(mod, ENTRYPOINT): |
|
|
|
|
print(f'{args.module} does not have a {ENTRYPOINT}() function') |
|
|
|
|
if not hasattr(mod, args.entrypoint): |
|
|
|
|
print(f'{args.module} does not have a {args.entrypoint}() function, typo?') |
|
|
|
|
sys.exit(1) |
|
|
|
|
|
|
|
|
|
with tempfile.TemporaryDirectory() as tmp: |
|
|
|
|
shutil.copytree(BASEDIR + '/openpilot', tmp, symlinks=False, dirs_exist_ok=True, copy_function=copy) |
|
|
|
|
entry = f'{args.module}:{ENTRYPOINT}' |
|
|
|
|
entry = f'{args.module}:{args.entrypoint}' |
|
|
|
|
zipapp.create_archive(tmp, target=args.output, interpreter=INTERPRETER, main=entry) |
|
|
|
|
|
|
|
|
|
print(f'created executable {Path(args.output).resolve()}') |
|
|
|
|