-
Notifications
You must be signed in to change notification settings - Fork 1
/
kawariki
executable file
·70 lines (57 loc) · 2.57 KB
/
kawariki
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env python3
# Kawariki -- NW.js game compat tool
# ------------------------------------------------------------------
# Copyright (C) 2021-2022 Taeyeon Mori <taeyeon at oro dot sodimm dot me>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# ------------------------------------------------------------------
# Please note that any files handled by this tool
# are covered by their respective third-party licenses.
# Content generated in whole by the tool without being derived from
# third-party distributions shall be in the public domain under CC0.
import builtins
import sys
import pathlib
# Tag and force output to stderr to distinguish from game output
builtin_print = builtins.print
def print(*messages, **opts):
if "file" not in opts:
opts["file"] = sys.stderr
return builtin_print("[Kawariki]", *messages, **opts)
builtins.print = print
# Add lib folder to path
path = pathlib.Path(sys.argv[0]).parent.resolve()
sys.path.append(str(path / "lib"))
# Check python version
if not sys.version_info >= (3, 10):
# functools.cached_property, possibly others
# Try to provide an easily understood error message instead of failing later
# This means modules in kawariki.ui should be as backward-compatible as possible.
from kawariki.ui import create_gui, MsgType
if gui := create_gui():
gui.show_msg(MsgType.Error, "RMMV NW.js Runtime requires more recent Python",
f"Python 3.10 or later is required, but currently running:\nPython {sys.version}")
raise ImportError("Unsupported python version {}.{}.{}{}{}. At least 3.10 is required.".format(*sys.version_info))
# Run
from kawariki.app import App # type: ignore[import-not-found] # noqa: E402
from kawariki.main import main # type: ignore[import-not-found] # noqa: E402
# import-not-found - sys.path is set up above
# E402 - Needs to be after version check
app = App(path)
try:
sys.exit(main(app, sys.argv))
except Exception:
import traceback
app.show_error(traceback.format_exc())
raise