installer: add config for frappy gui exe

Change-Id: I1abc325f685f8e95fac281b419be3defcc1e4485
Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/30508
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Georg Brandl <g.brandl@fz-juelich.de>
This commit is contained in:
Georg Brandl 2023-02-23 13:47:50 +01:00 committed by Markus Zolliker
parent ef1664e1a2
commit 2cf073e7d8
5 changed files with 81 additions and 0 deletions

3
installer/README Normal file
View File

@ -0,0 +1,3 @@
To build the exe file, invoke:
pyinstaller frappy-gui.spec

33
installer/frappy-gui.spec Normal file
View File

@ -0,0 +1,33 @@
# -*- mode: python -*-
import sys
from os import path
sys.path.insert(0, path.abspath('.'))
from utils import rootdir, find_uis, find_modules
binscript = path.join(rootdir, 'bin', 'frappy-gui')
a = Analysis([binscript],
pathex=[rootdir],
binaries=[],
datas=find_uis() + [
(path.join(rootdir, 'frappy', 'RELEASE-VERSION'), 'frappy')],
hiddenimports=find_modules('frappy', 'gui'),
hookspath=[],
excludes=['matplotlib'],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=None)
pyz = PYZ(a.pure, a.zipped_data, cipher=None)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
name='frappy-gui',
strip=False,
debug=False,
console=False)

43
installer/utils.py Normal file
View File

@ -0,0 +1,43 @@
# -*- coding: utf-8 -*-
import os
import subprocess
import sys
from os import path
rootdir = path.abspath('..')
guidirs = [path.join('frappy', 'gui')]
# Make sure to generate the version file.
os.environ['PYTHONPATH'] = os.environ.get('PYTHONPATH', '') + path.pathsep + rootdir
subprocess.check_call([sys.executable,
path.join(rootdir, 'frappy', 'version.py')])
# Include all .ui files for the main GUI module.
def find_uis():
res = []
for guidir in guidirs:
for root, _dirs, files in os.walk(path.join(rootdir, guidir)):
if any(uifile for uifile in files if uifile.endswith('.ui')):
res.append((path.join(root, '*.ui'),
path.join(guidir,
root[len(path.join(rootdir, guidir)) + 1:])))
return res
# Include all modules found in a certain package -- they may not be
# automatically found because of dynamic importing via the guiconfig file
# and custom widgets in .ui files.
def find_modules(*modules):
res = []
startdir = path.join(rootdir, *modules)
startmod = '.'.join(modules) + '.'
for root, _dirs, files in os.walk(startdir):
modpath = root[len(startdir) + 1:].replace(path.sep, '.')
if modpath:
modpath += '.'
for mod in files:
if mod.endswith('.py'):
res.append(startmod + modpath + mod[:-3])
return res

View File

@ -1,2 +1,3 @@
mlzlog
PyQt5
pyqtgraph

View File

@ -0,0 +1 @@
-r requirements-gui.txt