openpilot is an open source driver assistance system. openpilot performs the functions of Automated Lane Centering and Adaptive Cruise Control for over 200 supported car makes and models.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.3 KiB

2 months ago
#!/usr/bin/env python3
2 months ago
import importlib
import shutil
2 months ago
import sys
2 months ago
import tempfile
2 months ago
import zipapp
from argparse import ArgumentParser
2 months ago
from pathlib import Path
2 months ago
from openpilot.common.basedir import BASEDIR
2 months ago
2 months ago
ENTRYPOINT = 'main'
2 months ago
INTERPRETER = '/usr/bin/env python3'
2 months ago
EXTS = ['.py', '.png']
2 months ago
2 months ago
2 months ago
def copy(src, dest, follow_symlinks=False):
if any(src.endswith(ext) for ext in EXTS):
shutil.copy2(src, dest, follow_symlinks=follow_symlinks)
2 months ago
if __name__ == '__main__':
parser = ArgumentParser(prog='pack-raylib.py', description='Package a raylib UI into a portable executable.', epilog='comma.ai')
parser.add_argument('-o', '--output', help='output file')
2 months ago
parser.add_argument('module')
2 months ago
args = parser.parse_args()
2 months ago
2 months ago
if not args.output:
args.output = args.module
2 months ago
try:
mod = importlib.import_module(args.module)
except ModuleNotFoundError:
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')
sys.exit(1)
with tempfile.TemporaryDirectory() as tmp:
2 months ago
shutil.copytree(BASEDIR + '/openpilot', tmp, symlinks=False, dirs_exist_ok=True, copy_function=copy)
entry = f'{args.module}:{ENTRYPOINT}'
zipapp.create_archive(tmp, target=args.output, interpreter=INTERPRETER, main=entry)
2 months ago
print(f'created executable {Path(args.output).resolve()}')