-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup_cx_freeze.py
122 lines (112 loc) · 3.1 KB
/
setup_cx_freeze.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
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# Setup file to create Windows or Mac app using cx_Freeze
# Python3 package:
# python3 -m pip install cx-Freeze
# To run it:
# - Windows: in PowerShell, type
# python3 setup_cx_freeze.py bdist_msi
# The result is a .msi file in directory dist
# - Mac: in Terminal, for just the .app application, type
# python3 setup_cx_freeze.py bdist_mac
# or for the application in a dmg disk image:
# python3 setup_cx_freeze.py bdist_dmg
import sys, os
from cx_Freeze import setup, Executable
def create_plist(properties):
"""Create a temporary plist file from a dict of properties."""
# see create_plist in cx_Freeze/macdist.py
import plistlib
path = "/tmp/vpl-teacher-tools-cxf-Info.plist"
with open(path, "wb") as f:
plistlib.dump(properties, f)
return path
__version__ = "0.1.0"
build_exe = {
"packages": [
"os",
"json",
"websockets.legacy",
],
"include_files": [],
"excludes": [
"curses",
"lib2to3",
"numpy",
"wx",
"xmlrpc",
],
}
bdist_msi = {
"all_users": True,
"initial_target_dir": r"[ProgramFilesFolder]\VPLTeacherTools",
"data": {
"Shortcut": [
(
"DesktopShortcut",
"DesktopFolder",
"VPL3 Teacher Tools",
"TARGETDIR",
"[TARGETDIR]launch_tk.exe",
None,
None,
None,
None,
None,
None,
"TARGETDIR",
),
(
"StartupShortcut",
"ProgramMenuFolder",
"VPL3 Teacher Tools",
"TARGETDIR",
"[TARGETDIR]launch_tk.exe",
None,
None,
None,
None,
None,
None,
"TARGETDIR",
),
]
}
}
launcher = "launch_tk.py"
base = None
options = {
"build_exe": build_exe,
"bdist_msi": bdist_msi,
}
setup_options = {
"name": "VPL3TeacherTools",
"description": "VPL3 Teacher Tools built with cx_Freeze",
"version": __version__,
"options": options,
}
executable_options = {}
if sys.platform == "win32":
base = "Win32GUI"
build_exe["include_msvcr"] = False
# the end-user should download and install
# https://aka.ms/vs/16/release/vc_redist.x64.exe
elif sys.platform == "darwin":
launcher = "launch_objc.py"
info_plist_filename = create_plist({
"CFBundleIdentifier": "ch.epfl.mobots.vpl3server",
"CFBundleVersion": "0.1",
"CFBundleName": "VPL3 Server",
"CFBundleIconFile": "icon.icns",
"CFBundleDevelopmentRegion": "English",
"CFBundleIdentifier": "VPL3 Server",
"NSHumanReadableCopyright":
"2019-2021, École polytechnique fédérale de Lausanne (EPFL)",
})
options["bdist_mac"] = {
"bundle_name": "VPL3Server-cxf",
"custom_info_plist": info_plist_filename,
}
executable_options["base"] = base
setup(
**setup_options,
executables=[Executable(launcher, **executable_options)],
)