-
Notifications
You must be signed in to change notification settings - Fork 0
/
dist.py
54 lines (47 loc) · 1.24 KB
/
dist.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
import shutil
import os
import zipfile
# CLEAN DIST IF ANY
dest_dir = "./dist"
if os.path.exists(dest_dir):
shutil.rmtree(dest_dir)
os.makedirs(dest_dir)
# CREATE DIST
src_dir = "./"
listOfFiles = os.listdir(src_dir)
for f in listOfFiles:
if f.split(".")[-1] in ("png", "ttf", "bmp", "opt", "xml"):
f = src_dir+f
print "Copying", f, "..."
shutil.copy(f, dest_dir)
if os.name == "nt":
src_dir = "./bin/Debug/"
listOfFiles = os.listdir(src_dir)
for f in listOfFiles:
if f.endswith("dll") or f.endswith("exe"):
f = src_dir+f
print "Copying", f, "..."
shutil.copy(f, dest_dir)
else:
shutil.copy("build/Map2D", dest_dir)
items_to_copy = (
("png", "buttons"),
("png", "images"),
("png", "items"),
("png", "objects"),
("txt", "language"),
)
for ext,dir in items_to_copy:
src_dir = "./%s/" % dir
dest_dir = "./dist/%s" % dir
os.makedirs(dest_dir)
listOfFiles = os.listdir(src_dir)
for f in listOfFiles:
if f.endswith(ext):
f = src_dir+f
print "Copying", f, "..."
shutil.copy(f, dest_dir)
# ZIP
if os.path.exists("dist.zip"):
os.remove("dist.zip")
shutil.make_archive("dist", 'zip', "./dist/")