Description:
Add source support to packager.
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
|
1 | NO CONTENT: modified file, binary diff hidden |
|
NO CONTENT: modified file, binary diff hidden |
@@ -3,6 +3,8 | |||||
|
3 | import zipfile |
|
3 | import zipfile |
|
4 | import sys |
|
4 | import sys |
|
5 | import shutil |
|
5 | import shutil |
|
|
6 | import tempfile | ||
|
|
7 | import subprocess | ||
|
6 | import os |
|
8 | import os |
|
7 | import pathlib |
|
9 | import pathlib |
|
8 |
|
10 | ||
@@ -11,9 +13,9 | |||||
|
11 |
|
13 | ||
|
12 | sourcedir = "isometric-park-fna/bin/Release" |
|
14 | sourcedir = "isometric-park-fna/bin/Release" |
|
13 |
|
15 | ||
|
|
16 | |||
|
14 | def make_windows(suffix="new"): |
|
17 | def make_windows(suffix="new"): |
|
15 |
new_name = windows_template[:-9] + "-" + suffix |
|
18 | new_name = windows_template[:-9] + "-" + suffix |
|
16 |
|
|||
|
17 | # shutil.rmtree(new_name) |
|
19 | # shutil.rmtree(new_name) |
|
18 | shutil.copytree(windows_template, new_name) |
|
20 | shutil.copytree(windows_template, new_name) |
|
19 |
|
21 | ||
@@ -41,6 +43,7 | |||||
|
41 | source = pathlib.Path(dirpath) / file |
|
43 | source = pathlib.Path(dirpath) / file |
|
42 | f.write(source) |
|
44 | f.write(source) |
|
43 |
|
45 | ||
|
|
46 | |||
|
44 | def make_macos(suffix="new"): |
|
47 | def make_macos(suffix="new"): |
|
45 |
|
48 | ||
|
46 | new_name = macos_template[:-4] + "-" + suffix + ".app" + "/" |
|
49 | new_name = macos_template[:-4] + "-" + suffix + ".app" + "/" |
@@ -64,6 +67,24 | |||||
|
64 | pathlib.Path(new_name) / "Contents" / "Resources" / "isometric-park.exe") |
|
67 | pathlib.Path(new_name) / "Contents" / "Resources" / "isometric-park.exe") |
|
65 |
|
68 | ||
|
66 |
|
69 | ||
|
|
70 | def make_source(suffix="new"): | ||
|
|
71 | |||
|
|
72 | new_name = "isometric-park-fna/bin/isometric-park-source" + "-" + suffix | ||
|
|
73 | |||
|
|
74 | with tempfile.TemporaryDirectory() as temp: | ||
|
|
75 | print(subprocess.getoutput(f"hg clone . {temp}")) | ||
|
|
76 | |||
|
|
77 | with zipfile.ZipFile(new_name + ".zip", "w", | ||
|
|
78 | #Windows doesn't natively support other formats | ||
|
|
79 | #(besides uncompressed) in my testing: | ||
|
|
80 | compression=zipfile.ZIP_DEFLATED) as f: | ||
|
|
81 | for (dirpath, _dirname, files) in os.walk(temp): | ||
|
|
82 | for file in files: | ||
|
|
83 | source = pathlib.Path(dirpath) / file | ||
|
|
84 | print(os.path.relpath(source, temp)) | ||
|
|
85 | f.write(source, os.path.relpath(source, temp) ) | ||
|
|
86 | |||
|
|
87 | |||
|
67 | def main(): |
|
88 | def main(): |
|
68 | if len(sys.argv) > 1: |
|
89 | if len(sys.argv) > 1: |
|
69 | command = sys.argv[1] |
|
90 | command = sys.argv[1] |
@@ -78,10 +99,14 | |||||
|
78 | make_windows(sys.argv[2]) |
|
99 | make_windows(sys.argv[2]) |
|
79 | else: |
|
100 | else: |
|
80 | make_windows() |
|
101 | make_windows() |
|
|
102 | elif command.lower() == "source": | ||
|
|
103 | if len(sys.argv) > 2: | ||
|
|
104 | make_source(sys.argv[2]) | ||
|
|
105 | else: | ||
|
|
106 | make_source() | ||
|
81 | else: |
|
107 | else: |
|
82 | pass |
|
108 | pass |
|
83 |
|
109 | ||
|
84 |
|
110 | ||
|
85 |
|
|||
|
86 | if __name__ == '__main__': |
|
111 | if __name__ == '__main__': |
|
87 | main() |
|
112 | main() |
You need to be logged in to leave comments.
Login now