-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmyBay.spec
More file actions
199 lines (180 loc) · 5 KB
/
Copy pathmyBay.spec
File metadata and controls
199 lines (180 loc) · 5 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
199
# -*- mode: python ; coding: utf-8 -*-
"""
PyInstaller spec file for myBay
Build with:
pyinstaller myBay.spec
This creates a desktop build in dist/.
On macOS it also creates a .app bundle.
"""
import os
import sys
from pathlib import Path
from PyInstaller.utils.hooks import collect_all
# Get the project root
project_root = Path(SPECPATH)
block_cipher = None
# Bundle default data files.
import customtkinter
ctk_path = Path(customtkinter.__path__[0])
datas = [
# Include HTML templates
('server/templates', 'server/templates'),
# CustomTkinter assets (themes, JSON files)
(str(ctk_path), 'customtkinter'),
]
# Collect entire packages that PyInstaller struggles with
extra_datas = []
extra_binaries = []
extra_hiddenimports = []
for pkg in ['uvicorn', 'fastapi', 'starlette', 'httpx', 'anyio', 'dotenv', 'multipart']:
try:
d, b, h = collect_all(pkg)
extra_datas.extend(d)
extra_binaries.extend(b)
extra_hiddenimports.extend(h)
except Exception:
pass
datas.extend(extra_datas)
# Optional: include local secrets/state only when explicitly requested.
# Default is OFF for safer production/distribution builds.
bundle_local_state = os.environ.get('BUNDLE_LOCAL_STATE', '0') == '1'
if bundle_local_state:
env_file = project_root / '.env'
if env_file.exists():
datas.append((str(env_file), '.'))
ebay_config_file = project_root / '.ebay_config.json'
if ebay_config_file.exists():
datas.append((str(ebay_config_file), '.'))
db_file = project_root / 'mybay.db'
if db_file.exists():
datas.append((str(db_file), '.'))
# Optional: bundle ngrok binary for turnkey desktop installs.
# Default is OFF for safer production/distribution builds.
bundle_ngrok = os.environ.get('BUNDLE_NGROK', '0') == '1'
if bundle_ngrok:
ngrok_candidates = [
project_root / 'ngrok',
project_root / 'bin' / 'ngrok',
Path('/opt/homebrew/bin/ngrok'),
Path('/usr/local/bin/ngrok'),
]
for ngrok_candidate in ngrok_candidates:
if ngrok_candidate.exists():
datas.append((str(ngrok_candidate), '.'))
break
# Collect all Python files
a = Analysis(
['run.py'],
pathex=[str(project_root)],
binaries=extra_binaries,
datas=datas,
hiddenimports=[
# Core modules
'core.paths',
'core.vision',
'core.assistant',
'core.image_utils',
'core.qr_code',
'core.watcher',
'core.integration',
'core.ngrok',
'core.turbo',
'core.retry',
'core.presets',
# Data modules
'data.database',
# GUI modules
'gui.app',
'gui.admin_view',
'gui.wizard',
# Server modules
'server.main',
# eBay modules
'ebay.auth',
'ebay.config',
'ebay.images',
'ebay.taxonomy',
'ebay.inventory',
'ebay.pricing',
# Dependencies
'customtkinter',
'darkdetect',
'PIL',
'PIL.Image',
'httpx',
'fastapi',
'starlette',
'uvicorn',
'dotenv',
'watchdog',
'watchdog.observers',
'qrcode',
'qrcode.image.pil',
'sqlite3',
'json',
'xml.etree.ElementTree',
] + extra_hiddenimports,
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[
'matplotlib',
'numpy.testing',
'scipy',
'pandas',
'IPython',
'jupyter',
],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=True, # Extract .pyc files so COLLECT picks them up
)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
exe = EXE(
pyz,
a.scripts,
[],
exclude_binaries=True,
name='myBay',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=False, # No terminal window
disable_windowed_traceback=False,
argv_emulation=(sys.platform == 'darwin'), # macOS app behavior
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
coll = COLLECT(
exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
upx_exclude=[],
name='myBay',
)
# Create macOS app bundle only on macOS builds.
if sys.platform == 'darwin':
app = BUNDLE(
coll,
name='myBay.app',
icon='assets/icon.icns',
bundle_identifier='com.mybay.app',
info_plist={
'CFBundleName': 'myBay',
'CFBundleDisplayName': 'myBay',
'CFBundleVersion': '1.0.0',
'CFBundleShortVersionString': '1.0.0',
'NSHighResolutionCapable': True,
'NSRequiresAquaSystemAppearance': False,
'LSMinimumSystemVersion': '10.15.0',
'CFBundleDocumentTypes': [],
'NSCameraUsageDescription': 'myBay needs camera access to take product photos.',
'NSPhotoLibraryUsageDescription': 'myBay needs photo access to select product images.',
},
)