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 |
@@ -3,6 +3,8 | |||
|
3 | 3 | import zipfile |
|
4 | 4 | import sys |
|
5 | 5 | import shutil |
|
6 | import tempfile | |
|
7 | import subprocess | |
|
6 | 8 | import os |
|
7 | 9 | import pathlib |
|
8 | 10 | |
@@ -11,9 +13,9 | |||
|
11 | 13 | |
|
12 | 14 | sourcedir = "isometric-park-fna/bin/Release" |
|
13 | 15 | |
|
16 | ||
|
14 | 17 | def make_windows(suffix="new"): |
|
15 |
new_name = windows_template[:-9] + "-" + suffix |
|
|
16 | ||
|
18 | new_name = windows_template[:-9] + "-" + suffix | |
|
17 | 19 | # shutil.rmtree(new_name) |
|
18 | 20 | shutil.copytree(windows_template, new_name) |
|
19 | 21 | |
@@ -41,6 +43,7 | |||
|
41 | 43 | source = pathlib.Path(dirpath) / file |
|
42 | 44 | f.write(source) |
|
43 | 45 | |
|
46 | ||
|
44 | 47 | def make_macos(suffix="new"): |
|
45 | 48 | |
|
46 | 49 | new_name = macos_template[:-4] + "-" + suffix + ".app" + "/" |
@@ -64,6 +67,24 | |||
|
64 | 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 | 88 | def main(): |
|
68 | 89 | if len(sys.argv) > 1: |
|
69 | 90 | command = sys.argv[1] |
@@ -78,10 +99,14 | |||
|
78 | 99 | make_windows(sys.argv[2]) |
|
79 | 100 | else: |
|
80 | 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 | 107 | else: |
|
82 | 108 | pass |
|
83 | 109 | |
|
84 | 110 | |
|
85 | ||
|
86 | 111 | if __name__ == '__main__': |
|
87 | 112 | main() |
You need to be logged in to leave comments.
Login now