Skip to content

Commit

Permalink
tools/installer: switch to upstream PyInstaller (#851)
Browse files Browse the repository at this point in the history
* tools/installer: switch to upstream PyInstaller

Exclude GStreamer plugins via corresponding hook configuration
option that was introduced in PyInstaller 5.4. Switch to upstream
PyInstaller release instead of using private fork.

* formatter: auto-format exaile.spec file

Include exaile.spec file in auto-formatting and formatting check
via black auto-formatter.
  • Loading branch information
rokm committed Feb 23, 2023
1 parent 4b699ef commit cbafae0
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 93 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,10 @@ lint_errors:
sanitycheck: lint_errors test

format:
$(BLACK) -S *.py plugins/ xl/ xlgui/ tests/
$(BLACK) -S *.py plugins/ xl/ xlgui/ tests/ tools/installer/exaile.spec

check_format:
$(BLACK) --check --diff -S *.py plugins/ xl/ xlgui/ tests/
$(BLACK) --check --diff -S *.py plugins/ xl/ xlgui/ tests/ tools/installer/exaile.spec

desktop_files: builddir
msgfmt --desktop --template=data/exaile.desktop.in -d po -o build/exaile.desktop
Expand Down
177 changes: 87 additions & 90 deletions tools/installer/exaile.spec
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ import sys
from PyInstaller.utils.hooks import collect_submodules

if sys.platform == 'win32':
afile = '_inst/usr/lib/exaile/exaile_win.py'
entry_point_script = '_inst/usr/lib/exaile/exaile_win.py'
elif sys.platform == 'darwin':
afile = '_inst/usr/lib/exaile/exaile_osx.py'
entry_point_script = '_inst/usr/lib/exaile/exaile_osx.py'
else:
afile = '_inst/usr/lib/exaile/exaile.py'
entry_point_script = '_inst/usr/lib/exaile/exaile.py'

block_cipher = None

hiddenimports = collect_submodules('xl') + \
collect_submodules('xlgui') + \
collect_submodules('keyboard') + \
collect_submodules('feedparser') + \
collect_submodules('musicbrainzngs') + \
collect_submodules('mutagen') + \
collect_submodules('pylast')
hiddenimports = (
collect_submodules('xl')
+ collect_submodules('xlgui')
+ collect_submodules('keyboard')
+ collect_submodules('feedparser')
+ collect_submodules('musicbrainzngs')
+ collect_submodules('mutagen')
+ collect_submodules('pylast')
)

binaries = []

Expand All @@ -27,87 +27,84 @@ binaries = []
# packaging's subpackages.
hiddenimports += collect_submodules('packaging')

datas =[
('_inst/usr/share/exaile/data', 'data'),
('_inst/usr/share/exaile/plugins', 'plugins'),
('_inst/usr/share/locale', 'share/locale')
datas = [
('_inst/usr/share/exaile/data', 'data'),
('_inst/usr/share/exaile/plugins', 'plugins'),
('_inst/usr/share/locale', 'share/locale'),
]

gst_exclude_plugins = [
'aom',
'assrender',
'cacasink',
'daala',
'dvdread',
'dvdsub',
'faac',
'mxf',
'openal',
'openexr',
'opengl',
'openh264',
'opencv',
'resindvd',
'rtmp*',
'schro',
'video*',
'vpx',
'wasapi', # Generally buggy, e.g. https://github.com/exaile/exaile/issues/532
'webp',
'webrtc*',
'x264',
'x265',
'xvimage',
'zbar',
]

# requires https://github.com/pyinstaller/pyinstaller/pull/3608
def assemble_hook(analysis):
# filter out gstreamer plugins we don't want
to_remove = [
'gstaom',
'gstassrender',
'gstcacasink',
'gstdaala',
'gstdvdread',
'gstdvdsub',
'gstfaac',
'gstmxf',
'gstopenal',
'gstopenexr',
'gstopengl',
'gstopenh264',
'gstopencv',
'gstresindvd',
'gstrtmp',
'gstschro',
'gstvideo',
'gstvpx',
'gstwasapi', # Generally buggy, e.g. https://github.com/exaile/exaile/issues/532
'gstwebp',
'gstwebrtc',
'gstx264',
'gstx265',
'gstxvimage',
'gstzbar',
]

def _exclude(b):
for r in to_remove:
if r in b and 'libgstvideo-1' not in b:
print("Excluding", b)
return True
return False

analysis.binaries = [
b for b in analysis.binaries if not _exclude(b[0])
]
a = Analysis(
[entry_point_script],
pathex=['_inst/usr/lib/exaile'],
binaries=binaries,
datas=datas,
hiddenimports=hiddenimports,
excludes=['_tkinter', 'tkinter'],
hooksconfig={
"gstreamer": {
"exclude_plugins": gst_exclude_plugins,
},
},
)

pyz = PYZ(
a.pure,
a.zipped_data,
)

a = Analysis([afile],
pathex=['_inst/usr/lib/exaile'],
binaries=binaries,
datas=datas,
hiddenimports=hiddenimports,
hookspath=[],
runtime_hooks=[],
excludes=['tcl', 'tk', '_tkinter', 'tkinter', 'Tkinter'],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
assemble_hook=assemble_hook)
exe = EXE(
pyz,
a.scripts,
exclude_binaries=True,
name='exaile',
debug=False,
strip=False,
upx=True,
console=False,
)

pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
exclude_binaries=True,
name='exaile',
debug=False,
strip=False,
upx=True,
console=False )
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
name='exaile')
coll = COLLECT(
exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
name='exaile',
)

if sys.platform == 'darwin':
app = BUNDLE(coll,
name='Exaile.app',
icon="../../data/images/exaile.icns",
bundle_identifier=None)
app = BUNDLE(
coll,
name='Exaile.app',
icon="../../data/images/exaile.icns",
bundle_identifier=None,
)
2 changes: 1 addition & 1 deletion tools/installer/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pywin32-ctypes==0.2.0
https://github.com/exaile/pyinstaller/archive/sdk-py3.zip#egg=PyInstaller
pyinstaller==5.7
musicbrainzngs==0.6
mutagen==1.40
pylast==1.8.0
Expand Down

0 comments on commit cbafae0

Please sign in to comment.