-
-
Notifications
You must be signed in to change notification settings - Fork 388
/
picard.spec
179 lines (154 loc) · 5.67 KB
/
picard.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
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
# -*- mode: python -*-
import glob
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("build", "locale", locale[1], "LC_MESSAGES", locale[0] + ".mo"),
os.path.join("locale", locale[1], "LC_MESSAGES")))
return data_files
block_cipher = None
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', '.')]
data_files.append((os.path.join('resources', 'win10', '*'), '.'))
if 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')
a = Analysis(['tagger.py'],
pathex=['picard'],
binaries=binaries,
datas=data_files,
hiddenimports=[],
hookspath=[],
runtime_hooks=runtime_hooks,
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
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:
exe = EXE(pyz,
a.scripts,
exclude_binaries=True,
# 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)
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.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 supported_formats
for extensions, name in supported_formats():
info_plist['CFBundleDocumentTypes'].append({
'CFBundleTypeExtensions': [ext[1:] for ext in extensions],
'CFBundleTypeRole': 'Editor',
})
app = BUNDLE(coll,
name='{} {}.app'.format(PICARD_ORG_NAME, PICARD_APP_NAME),
icon='picard.icns',
bundle_identifier=None,
info_plist=info_plist
)