flandre/launch.py

33 lines
825 B
Python
Raw Normal View History

2025-04-12 14:18:45 +08:00
import shutil
import subprocess
2025-04-12 18:09:49 +08:00
import sys
2025-04-12 01:29:38 +08:00
from pathlib import Path
2025-04-12 15:39:56 +08:00
import click
2025-04-12 14:18:45 +08:00
2025-04-12 15:39:56 +08:00
@click.command()
@click.option('--data_folder', default=None)
@click.option('--generate_pyqt', default=True)
2025-04-12 15:54:56 +08:00
@click.option('--dev/--no-dev', default=True)
2025-04-12 15:39:56 +08:00
def main(data_folder, generate_pyqt, dev):
2025-04-12 18:09:49 +08:00
if dev:
sys.argv.append('--dev')
import flandre
from flandre.launcher import launch_from_file
from flandre.config import C
2025-04-12 14:18:45 +08:00
if (pyuic6 := shutil.which('pyuic6')) is None:
print('pyuic6 is not installed')
return
2025-04-12 15:39:56 +08:00
if generate_pyqt:
subprocess.run([pyuic6, '-o', flandre.PYQT / 'Main.py', flandre.PYQT / 'Main.ui'])
if data_folder is not None:
C.data_folder = Path(data_folder)
2025-04-12 18:09:49 +08:00
2025-04-12 15:54:56 +08:00
launch_from_file(Path(__file__).parent / 'launch.toml')
2025-04-12 14:18:45 +08:00
if __name__ == '__main__':
main()