-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.py
106 lines (86 loc) · 4.37 KB
/
build.py
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
##Build.py
"""
In order for buildScript to work, you need to have the following variables in your build file:
- PLUGIN_ROOT: (Required)
This lets the build script to know your plugin's root directory.
- OUTPUT_PATH: (Required)
This tells tppbuild where you want finished build tpp to be saved at. Default "./" meaning current dir where tppbuild is running from.
- PLUGIN_MAIN: (Required)
This lets tppbuild know where your main python plugin file is located so it will know which file to compile.
- PLUGIN_EXE_NAME: (Required)
This is the name of the executable file that is compiled by Pyinstaller.
- PLUGIN_EXE_ICON: (Optional)
This should be a path to a .ico file. However if png passed in, it will automatically converted to ico.
Otherwise, it will use pyinstaller's default icon.
- PLUGIN_ENTRY: (Required)
This can be either path to entry.tp or path to a python file that contains infomation about entry.
Note if you pass in a entry.tp, tppbuild will automatically validate the json. If you pass in a python file, it will
build entry.tp & validate it for you. If validation fails, tppbuild will exit.
- PLUGIN_ENTRY_INDENT: (Required)
Indent level (spaces) for generated JSON. Use 0 for only newlines, or -1 for the most compact representation. Default is 2 spaces.
- PLUGIN_VERSION: (Required)
A version string will be used as part of .tpp file.
- ADDITIONAL_FILES: (Optional)
If your plugin requires any additional files for your plugin to work, you can add them here.
- ADDITIONAL_PYINSTALLER_ARGS: (Optional)
If you have additional arguments for Pyinstaller, you can add them here. otherwise default it will use these arguments:
'--onefile', '--noconsole', '--distpath', 'dist', 'name', 'icon'
Even if you don't use all of the above variables, you still need to have the following variables in your build file
"""
from TouchPortalAPI import tppbuild
from TPPEntry import PLUGIN_NAME, PLUGIN_FOLDER
"""
PLUGIN_MAIN: This lets tppbuild know where your main python plugin file is located so it will know which file to compile.
"""
PLUGIN_MAIN = "main.py"
"""
PLUGIN_EXE_NAME: This defines what you want your plugin executable to be named. tppbuild will also use this for the .tpp file in the format:
`pluginname + "_v" + version + "_" + os_name + ".tpp"`
If left blank, the file name from PLUGIN_MAIN is used (w/out .py extension).
"""
PLUGIN_EXE_NAME = PLUGIN_NAME + "_Plugin"
"""
PLUGIN_EXE_ICON: This should be a path to a .ico file. However if png passed in, it will automatically converted to ico.
"""
PLUGIN_EXE_ICON = f"{PLUGIN_NAME}.png"
"""
PLUGIN_ENTRY: This can be either path to entry.tp or path to a python file that contains infomation about entry.
Note if you pass in a entry.tp, tppbuild will automatically validate the json. If you pass in a python file, it will
build entry.tp & validate it for you. If validation fails, tppbuild will exit.
"""
PLUGIN_ENTRY = "entry.tp" # Here we just use the same file as the plugin's main code since that contains all the definitions for entry.tp.
"""
"""
PLUGIN_ENTRY_INDENT = 2
""" This is the root folder name that will be inside of .tpp """
PLUGIN_ROOT = PLUGIN_FOLDER
""" Path to icon file used in entry.tp for category `imagepath`, if any. If left blank, TP will use a default icon. """
PLUGIN_ICON = f"{PLUGIN_NAME}.png"
""" This tells tppbuild where you want finished build tpp to be saved at. Default "./" meaning current dir where tppbuild is running from. """
OUTPUT_PATH = r"./"
""" PLUGIN_VERSION: A version string for the generated .tpp file name. This example reads the `__version__` from the example plugin's code. """
import json
import os
entry = os.path.join(os.path.split(__file__)[0], PLUGIN_ENTRY)
with open(entry, "r") as f:
PLUGIN_VERSION = str(json.load(f)['version'])
# Or just set the PLUGIN_VERSION manually.
# PLUGIN_VERSION = "1.0.0-beta1"
"""
If you have any required file(s) that your plugin needs, put them in this list.
"""
ADDITIONAL_FILES = [
"start.sh"
]
if PLUGIN_ICON:
ADDITIONAL_FILES.append("TikTokLive.png")
ADDITIONAL_TPPSDK_ARGS = []
"""
Any additional arguments to be passed to Pyinstaller. Optional.
"""
ADDITIONAL_PYINSTALLER_ARGS = [
"--log-level=WARN", "--noconsole"
]
# validateBuild()
if __name__ == "__main__":
tppbuild.runBuild()