-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpack_plugin.py
executable file
·96 lines (81 loc) · 2.92 KB
/
pack_plugin.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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
import os
import zipfile
import platform
_platform = platform.platform().lower()
is_linux = False
is_windows = False
if _platform.startswith("linux"):
_platform = "linux"
is_linux = True
elif _platform.startswith("windows"):
_platform = "windows"
is_windows = True
else:
sys.exit("Unknown platform")
# ret = os.system("python3 build_plugin.py")
# if ret != 0:
# sys.exit("Could not build...")
with open("version") as _file:
content = _file.read()
_version = content.strip()
folder_inside = "Sea5kgPython3Scripting_editorplugin_" + _version
_zip_filename = _platform + "_" + folder_inside + ".zip"
if os.path.isfile(_zip_filename):
os.remove(_zip_filename)
zf = zipfile.ZipFile(_zip_filename, 'w', zipfile.ZIP_DEFLATED)
if is_linux:
zf.write(
"bin/plugins/Sea5kg/Python3Scripting/libSea5kgPython3Scripting_editorplugin_x64.so",
folder_inside + "/bin/plugins/Sea5kg/Python3Scripting/libSea5kgPython3Scripting_editorplugin_x64.so",
)
zf.write(
"bin/plugins/Sea5kg/Python3Scripting/libSea5kgPython3Scripting_editorplugin_x64d.so",
folder_inside + "/bin/plugins/Sea5kg/Python3Scripting/libSea5kgPython3Scripting_editorplugin_x64d.so",
)
if is_windows:
zf.write(
"bin/plugins/Sea5kg/Python3Scripting/Sea5kgPython3Scripting_editorplugin_x64.dll",
folder_inside + "/bin/plugins/Sea5kg/Python3Scripting/Sea5kgPython3Scripting_editorplugin_x64.dll",
)
python_libs = [
"libcrypto-1_1.dll",
"libffi-7.dll",
"libssl-1_1.dll",
"pyshellext.dll",
"python310.dll",
"sqlite3.dll",
"tcl86t.dll",
"tk86t.dll",
]
for _pydll in python_libs:
zf.write(
"source/plugins/Sea5kg/Python3Scripting/python-bin-windows/" + _pydll,
folder_inside + "/bin/" + _pydll,
)
zf.write(
"bin/plugins/Sea5kg/Python3Scripting/Sea5kgPython3Scripting_editorplugin_x64d.dll",
folder_inside + "/bin/plugins/Sea5kg/Python3Scripting/Sea5kgPython3Scripting_editorplugin_x64d.dll",
)
# Python3Home (Lib)
rootdir = "bin/Python3Home/lib/python3.10"
for root, subdirs, files in os.walk(rootdir):
for _file in files:
_src = os.path.join(root, _file)
_dst = _src[len(rootdir)+1:]
_dst = os.path.join("bin", "plugins", "Sea5kg", "Python3Scripting", "Python3Home", "lib", "python3.10", _dst)
_dst = os.path.join(folder_inside, _dst)
print(_src, "->", _dst)
zf.write(_src, _dst)
rootdir = "Python3Scripting_examples"
for root, subdirs, files in os.walk(rootdir):
for _file in files:
_src = os.path.join(root, _file)
_dst = _src[len(rootdir)+1:]
_dst = os.path.join("bin", "plugins", "Sea5kg", "Python3Scripting", "Scripts", _dst)
_dst = os.path.join(folder_inside, _dst)
print(_src, "->", _dst)
zf.write(_src, _dst)
zf.close()