forked from cztomczak/cefpython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake-installer.py
More file actions
93 lines (76 loc) · 2.98 KB
/
make-installer.py
File metadata and controls
93 lines (76 loc) · 2.98 KB
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
# Copyright (c) 2012-2014 The CEF Python authors. All rights reserved.
# License: New BSD License.
# Website: http://code.google.com/p/cefpython/
# Create a Windows package installer.
import sys
import os
import platform
import argparse
import re
import struct
import sysconfig
BITS = str(8 * struct.calcsize('P')) + 'bit'
assert (BITS == "32bit" or BITS == "64bit")
ISCC = r"c:\Program Files (x86)\Inno Setup 5\ISCC.exe"
if "INNO5" in os.environ:
ISCC = os.environ["INNO5"]
TEMPLATE_FILE = os.getcwd()+r"\innosetup.template"
ISS_FILE = os.getcwd()+r"\innosetup.generated"
def main():
parser = argparse.ArgumentParser(usage="%(prog)s [options]")
parser.add_argument("-v", "--version", help="cefpython version",
required=True)
args = parser.parse_args()
assert re.search(r"^\d+\.\d+$", args.version), "Invalid version string"
vars = {}
vars["PACKAGE_NAME"] = "cefpython3"
vars["APP_VERSION"] = args.version
vars["PYTHON_VERSION"] = (str(sys.version_info.major) + "."
+ str(sys.version_info.minor))
vars["PYTHON_VERSION_NODOT"] = (str(sys.version_info.major) + ""
+ str(sys.version_info.minor))
vars["PYTHON_ARCHITECTURE"] = platform.architecture()[0]
vars["BINARIES_DIR"] = os.path.realpath(
os.getcwd() + r"\..\binaries_%s" % BITS)
vars["PYD_FILE"] = (vars["BINARIES_DIR"]+r"\cefpython_py"
+ str(sys.version_info.major) + str(sys.version_info.minor)
+ ".pyd")
vars["INSTALLER_DIR"] = os.getcwd()
vars["WX_SUBPACKAGE_DIR"] = os.path.realpath(os.getcwd()+r"\..\..\wx")
vars["PLATFORM"] = sysconfig.get_platform()
if BITS == "32bit":
# We must keep compatibility, 32bit installers didn't contain
# architecture information in AppName. So make it an empty string.
vars["APP_NAME_BITS"] = ""
vars["HKEY_CURRENT_USER"] = "HKEY_CURRENT_USER"
vars["HKEY_LOCAL_MACHINE"] = "HKEY_LOCAL_MACHINE"
elif BITS == "64bit":
vars["APP_NAME_BITS"] = "64bit"
# Inno setup installer is a 32bit application. To query 64bit
# registry from within 32bit application you need to add _64
# postfix.
vars["HKEY_CURRENT_USER"] = "HKEY_CURRENT_USER_64"
vars["HKEY_LOCAL_MACHINE"] = "HKEY_LOCAL_MACHINE_64"
print("Reading template: %s" % TEMPLATE_FILE)
f = open(TEMPLATE_FILE)
template = f.read()
f.close()
f = open(ISS_FILE, "w")
f.write(template % vars)
f.close()
print("Saved: %s" % ISS_FILE)
initPyTemplate = os.getcwd()+r"\__init__.py.template"
initPyInstall = os.getcwd()+r"\__init__.py.generated"
f = open(initPyTemplate)
initPyTemplateCode = f.read()
f.close()
f = open(initPyInstall, "w")
f.write(initPyTemplateCode % vars)
f.close()
print("Saved: %s" % initPyInstall)
iscc_command = '"'+ ISCC + '" ' + ISS_FILE
print("Running ISCC: %s" % iscc_command)
exit_code = os.system(iscc_command)
sys.exit(exit_code)
if __name__ == "__main__":
main()