-
Notifications
You must be signed in to change notification settings - Fork 53
/
ndrive.spec
118 lines (99 loc) · 2.8 KB
/
ndrive.spec
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
# -*- mode: python -*-
import io
import os
import os.path
from pathlib import Path
import re
import sys
def get_version(init_file):
"""Find the current version."""
with io.open(init_file, encoding="utf-8") as handler:
for line in handler.readlines():
if line.startswith("__version__"):
return re.findall(r"\"(.+)\"", line)[0]
cwd = os.getcwd()
tools = os.path.join(cwd, "tools")
nxdrive = os.path.join(cwd, "nxdrive")
data = os.path.join(nxdrive, "data")
icon = {
"darwin": os.path.join(tools, "osx", "app_icon.icns"),
"linux": os.path.join(tools, "linux", "app_icon.png"),
"win32": os.path.join(tools, "windows", "app_icon.ico"),
}[sys.platform]
excludes = [
# https://github.com/pyinstaller/pyinstaller/wiki/Recipe-remove-tkinter-tcl
"FixTk",
"tcl",
"tk",
"_tkinter",
"tkinter",
"Tkinter",
# Misc
"PIL",
"ipdb",
"lib2to3",
"numpy",
"pydev",
"scipy",
"yappi",
]
data = [(data, "data")]
migrations = Path(nxdrive, "dao", "migrations")
hiddenimports = [
migration.relative_to(cwd).with_suffix("").as_posix().replace("/", ".")
for migration in migrations.glob("**/[0-9]*.py")
]
version = get_version(os.path.join(nxdrive, "__init__.py"))
properties_rc = None
if sys.platform == "win32":
# Set executable properties
properties_tpl = tools + "\\windows\\properties_tpl.rc"
properties_rc = tools + "\\windows\\properties.rc"
if os.path.isfile(properties_rc):
os.remove(properties_rc)
version_tuple = tuple(map(int, version.split(".") + [0] * (3 - version.count("."))))
with open(properties_tpl, encoding="utf-8") as tpl, open(
properties_rc, "w", encoding="utf-8"
) as out:
content = tpl.read().format(version=version, version_tuple=version_tuple)
print(content)
out.write(content)
# Missing modules when packaged
hiddenimports.append("win32timezone")
a = Analysis(
[os.path.join(nxdrive, "__main__.py")],
datas=data,
excludes=excludes,
hiddenimports=hiddenimports,
)
pyz = PYZ(a.pure, a.zipped_data)
exe = EXE(
pyz,
a.scripts,
exclude_binaries=True,
name="ndrive",
console=False,
debug=False,
strip=False,
upx=False,
icon=icon,
version=properties_rc,
)
coll = COLLECT(exe, a.binaries, a.zipfiles, a.datas, name="ndrive")
info_plist = {
"CFBundleName": "NuxeoDrive",
"CFBundleShortVersionString": version,
"CFBundleURLTypes": {
"CFBundleURLName": "org.nuxeo.nxdrive.direct-edit",
"CFBundleTypeRole": "Editor",
"CFBundleURLSchemes": ["nxdrive"],
},
"LSUIElement": True, # Implies LSBackgroundOnly, no icon in the Dock
}
app = BUNDLE(
coll,
name="Nuxeo Drive.app",
icon=icon,
info_plist=info_plist,
bundle_identifier="org.nuxeo.drive",
)