-
-
Notifications
You must be signed in to change notification settings - Fork 460
Expand file tree
/
Copy pathpicard.spec
More file actions
252 lines (221 loc) · 7.25 KB
/
picard.spec
File metadata and controls
252 lines (221 loc) · 7.25 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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
# -*- mode: python -*-
import glob
from importlib import import_module
import os
import platform
import sys
sys.path.insert(0, '.')
from picard import (
PICARD_APP_ID,
PICARD_APP_NAME,
PICARD_DISPLAY_NAME,
PICARD_ORG_NAME,
PICARD_VERSION,
__version__,
)
def _picard_get_locale_files():
locales = []
path_domain = {
'po': 'picard',
os.path.join('po', 'attributes'): 'picard-attributes',
os.path.join('po', 'constants'): 'picard-constants',
os.path.join('po', 'countries'): 'picard-countries',
}
for path, domain in path_domain.items():
for filepath in glob.glob(os.path.join(path, '*.po')):
filename = os.path.basename(filepath)
locale = os.path.splitext(filename)[0]
locales.append((domain, locale, filepath))
return locales
def get_locale_messages():
data_files = []
for locale in _picard_get_locale_files():
data_files.append(
(
os.path.join("picard", "locale", locale[1], "LC_MESSAGES", locale[0] + ".mo"),
os.path.join("locale", locale[1], "LC_MESSAGES"),
)
)
return data_files
def has_module(module_name):
"""Check whether the given module is available."""
try:
import_module(module_name)
return True
except ImportError:
return False
os_name = platform.system()
build_portable = bool(os.environ.get('PICARD_BUILD_PORTABLE'))
binaries = []
data_files = get_locale_messages()
fpcalc_name = 'fpcalc'
if os_name == 'Windows':
fpcalc_name = 'fpcalc.exe'
binaries += [('discid.dll', '.')]
if os.path.exists('TaskbarLib.tlb'):
binaries += [('TaskbarLib.tlb', '.')]
elif os_name == 'Darwin':
binaries += [('libdiscid.0.dylib', '.')]
if os.path.isfile(fpcalc_name):
binaries += [(fpcalc_name, '.')]
runtime_hooks = []
if os_name == 'Windows':
runtime_hooks.append('scripts/pyinstaller/win-startup-hook.py')
elif os_name == 'Darwin':
runtime_hooks.append('scripts/pyinstaller/macos-library-path-hook.py')
if build_portable:
runtime_hooks.append('scripts/pyinstaller/portable-hook.py')
hiddenimports = [
'cffi', # Needed for pygit2
'dataclasses', # Provide dataclasses support for plugins
]
if has_module('opencc'):
hiddenimports.append('opencc') # opencc module
if has_module('zstandard'):
hiddenimports.append('zstandard') # xqaf plugin
excludes = []
# If tomllib is available, tomli can be excluded
if has_module('tomllib'):
excludes.append('tomli')
a = Analysis(
['tagger.py'],
pathex=['picard'],
binaries=binaries,
datas=data_files,
hiddenimports=hiddenimports,
hookspath=None,
runtime_hooks=runtime_hooks,
excludes=excludes,
)
pyz = PYZ(a.pure, a.zipped_data)
if build_portable:
exe = EXE(
pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
name='{}-{}-{}'.format(PICARD_ORG_NAME, PICARD_APP_NAME, __version__),
debug=False,
strip=False,
upx=False,
icon='picard.ico',
version='win-version-info.txt',
console=False,
)
else:
# The main executable
exe = EXE(
pyz,
a.scripts,
exclude_binaries=True,
target_arch=os.environ.get('TARGET_ARCH', None),
# Avoid name clash between picard executable and picard module folder
name='picard' if os_name == 'Windows' else 'picard-run',
debug=False,
strip=False,
upx=False,
icon='picard.ico',
version='win-version-info.txt',
console=False,
# macOS code signing
codesign_identity=os.environ.get('CODESIGN_IDENTITY', None),
entitlements_file='./scripts/package/entitlements.plist',
)
# The picard-plugins CLI tool
a_plugins = Analysis(
['picard/plugin3/cli.py'],
pathex=['picard'],
binaries=[],
datas=[],
hiddenimports=['cffi'],
hookspath=None,
runtime_hooks=[],
excludes=excludes,
)
pyz_plugins = PYZ(a_plugins.pure, a_plugins.zipped_data)
exe_plugins = EXE(
pyz_plugins,
a_plugins.scripts,
exclude_binaries=True,
target_arch=os.environ.get('TARGET_ARCH', None),
name='picard-plugins',
debug=False,
strip=False,
upx=False,
icon='picard.ico',
version='win-version-info.txt',
console=False if os_name == 'Darwin' else True,
# macOS code signing
codesign_identity=os.environ.get('CODESIGN_IDENTITY', None),
entitlements_file='./scripts/package/entitlements.plist',
)
coll = COLLECT(
exe,
a.binaries,
a.zipfiles,
a.datas,
exe_plugins,
a_plugins.binaries,
a_plugins.zipfiles,
a_plugins.datas,
strip=False,
upx=False,
name='picard',
)
if os_name == 'Darwin':
info_plist = {
'CFBundleName': PICARD_APP_NAME,
'CFBundleDisplayName': PICARD_DISPLAY_NAME,
'CFBundleIdentifier': PICARD_APP_ID,
'CFBundleVersion': '%d.%d.%d' % PICARD_VERSION[:3],
'CFBundleShortVersionString': PICARD_VERSION.short_str(),
'LSApplicationCategoryType': 'public.app-category.music',
'LSMinimumSystemVersion': os.environ.get('MACOSX_DEPLOYMENT_TARGET', '11.0'),
'NSHighResolutionCapable': True,
'NSPrincipalClass': 'NSApplication',
'NSRequiresAquaSystemAppearance': False,
'CFBundleDocumentTypes': [
{
# Add UTIs understood by macOS
'LSItemContentTypes': [
'com.apple.m4a-audio',
'com.apple.m4v-video',
'com.apple.protected-mpeg-4-audio',
'com.microsoft.advanced-systems-format',
'com.microsoft.waveform-audio',
'com.microsoft.windows-media-wm',
'com.microsoft.windows-media-wma',
'com.microsoft.windows-media-wmv',
'org.xiph.flac',
'public.aac-audio',
'public.ac3-audio',
'public.aifc-audio',
'public.aiff-audio',
'public.enhanced-ac3-audio',
'public.folder',
'public.midi-audio',
'public.mp3',
'public.mpeg-4',
'public.mpeg-4-audio',
],
'CFBundleTypeRole': 'Editor',
}
],
}
# Add additional supported file types by extension
from picard.formats import DEFAULT_FORMATS
for format in DEFAULT_FORMATS:
info_plist['CFBundleDocumentTypes'].append(
{
'CFBundleTypeExtensions': [ext[1:] for ext in format.EXTENSIONS],
'CFBundleTypeRole': 'Editor',
}
)
app = BUNDLE(
coll,
name='{} {}.app'.format(PICARD_ORG_NAME, PICARD_APP_NAME),
icon='picard.icns',
bundle_identifier=PICARD_APP_ID,
info_plist=info_plist,
)