Repository navigation
Expand file tree
/
Copy pathMapHide.spec
More file actions
107 lines (94 loc) · 3.63 KB
/
Copy pathMapHide.spec
File metadata and controls
107 lines (94 loc) · 3.63 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
# -*- mode: python ; coding: utf-8 -*-
# One-dir build. A one-file build (single self-extracting .exe) is a common
# antivirus false-positive trigger, so MapHide ships as a folder instead:
# dist/MapHide/MapHide.exe plus dist/MapHide/_internal/.
import os
import re
import sys
sys.path.insert(0, SPECPATH)
from maphide.version import CHANNEL_FILE, CHANNEL_GITHUB, CHANNELS, VERSION
from tools.version_resource import version_resource
# Which kind of build this is: the GitHub download unless MAPHIDE_CHANNEL
# names another. The app reads it from channel.txt in the bundle.
CHANNEL = os.environ.get('MAPHIDE_CHANNEL', CHANNEL_GITHUB)
if CHANNEL not in CHANNELS:
raise SystemExit(f"MAPHIDE_CHANNEL must be one of {', '.join(CHANNELS)}, not {CHANNEL!r}")
os.makedirs(workpath, exist_ok=True)
channel_file = os.path.join(workpath, CHANNEL_FILE)
with open(channel_file, 'w', encoding='utf-8') as file:
file.write(CHANNEL)
a = Analysis(
['map_hider.py'],
pathex=[],
binaries=[],
datas=[
('MapHide.ico', '.'),
('assets', 'assets'),
('maphide/qt/*.qml', 'maphide/qt'),
(channel_file, '.'),
],
hiddenimports=[],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
# PIL: used only by tools/make_assets.py and the tests, never by the app.
# PySide6.QtOpenGL: the window never imports it, and leaving it out keeps
# 8 MB out of the download.
excludes=['tkinter', 'PIL', 'PySide6.QtOpenGL'],
noarchive=False,
# -OO on the bundled bytecode: drops asserts and docstrings for a small size
# win. MapHide uses no asserts and reads none of its own docstrings at runtime.
optimize=2,
)
# PySide6's packaging hooks bring in all of Qt Quick: about 160 MB. These are
# the parts this window never loads - other control styles, dialogs, 3D,
# PDF, a software OpenGL fallback, Qt's own OpenSSL, and translations for an
# English-only window. Leaving out something it does load only shows when the
# window opens, which is what `MapHide.exe --selftest` checks in the build.
UNUSED = re.compile(
r"opengl32sw|QuickControls2|QuickDialogs2|QuickTemplates2"
r"|QuickNativeStyle|Qt6Labs|Qt6Test|Qt6QuickTest|Qt6Sql|QuickVectorImage|ShapesDesignHelpers"
r"|QmlXmlListModel|QmlLocalStorage|QuickTimeline|QuickLayouts|QmlDesignSupport|QmlNetwork"
r"|Qt6QmlCore|Qt6Pdf|VirtualKeyboard|Quick3D|QuickParticles|QuickWidgets|Qt6Svg"
r"|libcrypto-3-x64|libssl-3-x64|PySide6/translations/"
r"|qml/(Qt/|QtTest|QtNetwork|QtCore|QtQuick/(Controls|Dialogs|Layouts|LocalStorage"
r"|NativeStyle|Particles|Pdf|Scene2D|Scene3D|Templates|Timeline|VectorImage|VirtualKeyboard|tooling))"
r"|plugins/(qmltooling|tls|networkinformation|generic|iconengines)"
# WebP for the map box and ICO for the window icon; PNG is built in.
r"|imageformats/(?!qwebp|qico)|platforms/(?!qwindows)",
re.IGNORECASE,
)
def used(entry):
return not UNUSED.search(entry[0].replace(os.sep, '/'))
a.binaries = [entry for entry in a.binaries if used(entry)]
a.datas = [entry for entry in a.datas if used(entry)]
pyz = PYZ(a.pure)
exe = EXE(
pyz,
a.scripts,
[],
exclude_binaries=True,
name='MapHide',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=False,
console=False,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
icon=['MapHide.ico'],
# The exe's file properties, generated from maphide/version.py.
version=version_resource(VERSION),
)
coll = COLLECT(
exe,
a.binaries,
a.datas,
strip=False,
upx=False,
upx_exclude=[],
name='MapHide',
)