-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup_cross_platform.py
More file actions
198 lines (187 loc) · 4.81 KB
/
setup_cross_platform.py
File metadata and controls
198 lines (187 loc) · 4.81 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
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
import sys
import os
from cx_Freeze import setup, Executable
from PIL import Image
# Determine platform and build options
platform = sys.platform
# Common packages
common_packages = [
"serial",
"serial.tools",
"serial.tools.list_ports",
"asyncio",
"json",
"logging",
"re",
"pathlib",
"typing",
"os",
"sys",
"time",
"threading",
"queue",
"collections",
"dataclasses",
]
# Platform-specific packages
if platform.startswith("linux"):
packages = common_packages + [
"PyQt6",
"PyQt6.QtCore",
"PyQt6.QtGui",
"PyQt6.QtWidgets",
"qasync",
"core",
"core.arduino",
"core.input_mapper",
"core.xplane_connection",
"core.hid_manager",
"core.variable_store",
"core.dataref_manager",
"gui",
"gui.widgets",
"utils",
]
includes = [
"hidapi",
"requests",
"aiohttp",
"websockets",
"lxml",
"bs4",
]
base = None # Console on Linux
executable_name = "x-plane-dataref-bridge"
elif platform == "darwin": # macOS
packages = common_packages + [
"PyQt6",
"PyQt6.QtCore",
"PyQt6.QtGui",
"PyQt6.QtWidgets",
"qasync",
"core",
"core.arduino",
"core.input_mapper",
"core.xplane_connection",
"core.hid_manager",
"core.variable_store",
"core.dataref_manager",
"gui",
"gui.widgets",
"utils",
]
includes = [
"hidapi",
"requests",
"aiohttp",
"websockets",
"lxml",
"bs4",
]
base = None # Console on macOS
executable_name = "X-Plane Dataref Bridge"
else: # Windows
packages = common_packages + [
# Core packages
"serial",
"serial.tools",
"serial.tools.list_ports",
"serial.serialwin32",
"serial.win32",
"serial.serialutil",
"serial.threaded",
"serial.urlhandler",
# PyQt6 packages
"PyQt6",
"PyQt6.QtCore",
"PyQt6.QtGui",
"PyQt6.QtWidgets",
# Async packages
"qasync",
# Core application packages
"core",
"core.arduino",
"core.input_mapper",
"core.xplane_connection",
"core.hid_manager",
"core.variable_store",
"core.dataref_manager",
# GUI packages
"gui",
"gui.widgets",
# Utility packages
"utils",
]
includes = [
# Explicit includes for serial backends
"serial.serialutil",
"serial.threaded",
"serial.urlhandler.protocol_socket",
"serial.urlhandler.protocol_rfc2217",
"serial.urlhandler.protocol_loop",
"serial.urlhandler.protocol_alt",
"serial.urlhandler.protocol_cp2110",
"serial.urlhandler.protocol_hwgrep",
"serial.urlhandler.protocol_spy",
# Windows-specific serial modules
"serial.serialwin32",
"serial.win32",
"serial.tools.list_ports_windows",
# Additional modules
"requests",
"aiohttp",
"websockets",
"lxml",
"bs4",
]
base = "gui" # GUI for Windows
executable_name = "X-Plane Dataref Bridge"
# Common build options
build_exe_options = {
"packages": packages,
"includes": includes,
"excludes": ["tkinter"],
"include_files": [
("resources", "resources"),
("resources/dataref_database.json", "resources/dataref_database.json"),
],
"optimize": 0,
}
# Icon setup
icon_path = None
if os.path.exists("resources/icon.ico"):
icon_path = "resources/icon.ico"
elif os.path.exists("resources/icon.png"):
icon_path = "resources/icon.png"
# Create .icns for macOS if needed
if platform == "darwin" and os.path.exists("resources/icon.png"):
try:
from PIL import Image
img = Image.open("resources/icon.png")
# Create different sizes for .icns
sizes = [16, 32, 128, 256, 512]
for size in sizes:
resized = img.resize((size, size), Image.Resampling.LANCZOS)
resized.save(f"resources/icon_{size}x{size}.png")
icon_path = "resources/icon.icns"
except ImportError:
print("Warning: PIL not available for macOS icon creation")
icon_path = "resources/icon.png"
executables = [
Executable(
"main.py",
base=base,
target_name=executable_name,
icon=icon_path,
shortcut_name="X-Plane Dataref Bridge",
shortcut_dir="ProgramMenuFolder",
)
]
setup(
name="X-Plane Dataref Bridge",
version="1.0.0",
description="X-Plane Dataref Bridge - Connect X-Plane to Arduino Hardware",
author="X-Plane Dataref Bridge Team",
options={"build_exe": build_exe_options},
executables=executables,
)