-
Notifications
You must be signed in to change notification settings - Fork 54
/
build-cxfreeze.py
36 lines (33 loc) · 1.06 KB
/
build-cxfreeze.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
import os
import sys
cwd = os.path.abspath(os.getcwd())
cmd = r'cd %s ; "%s" cx_setup.py build_exe' % \
(os.path.join(".", "package", "cxfreeze"),
sys.executable)
if sys.platform.startswith("win"):
cmd = cmd.replace(";", "&")
result = os.system(cmd)
os.chdir(cwd)
if result:
print("Unsuccessful command <%s>" % cmd)
sys.exit(result)
else:
import shutil
import glob
# create the dist directory
dist = os.path.join(cwd, "dist")
if not os.path.exists(dist):
os.mkdir(dist)
# move the frozen installer
installer = glob.glob(os.path.join(".", "package", "cxfreeze","pymca*.exe"))
if not len(installer):
print("Could not generate installer")
sys.exit(1)
source = installer[0]
target = os.path.join(dist, os.path.basename(source))
if os.path.exists(target):
os.remove(target)
shutil.move(source, target)
# cleanup
os.remove(os.path.join(".", "package", "cxfreeze","nsisscript.nsi"))
shutil.rmtree(os.path.join(".", "package", "cxfreeze","build"))