First stab at creating a linux build with pyinstaller

This commit is contained in:
Tomas Groth 2024-02-08 22:39:35 +01:00
parent 5b42f3260d
commit e2a9d0c814
6 changed files with 161 additions and 4 deletions

View File

@ -4,7 +4,7 @@
##########################################################################
# OpenLP - Open Source Lyrics Projection #
# ---------------------------------------------------------------------- #
# Copyright (c) 2008-2019 OpenLP Developers #
# Copyright (c) 2008-2024 OpenLP Developers #
# ---------------------------------------------------------------------- #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #

135
builders/linux-builder.py Normal file
View File

@ -0,0 +1,135 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
##########################################################################
# OpenLP - Open Source Lyrics Projection #
# ---------------------------------------------------------------------- #
# Copyright (c) 2008-2024 OpenLP Developers #
# ---------------------------------------------------------------------- #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
##########################################################################
"""
Linux Build Script
--------------------
This script is used to build the Linux app bundle.
Python 3.7
PyQt5
You should already have this installed, OpenLP doesn't work without it. The
version the script expects is the packaged one available from River Bank
Computing.
PyEnchant
This script expects the precompiled, installable version of PyEnchant to be
installed. You can find this on the PyEnchant site.
Sphinx
This is used to build the documentation. The documentation trunk must be at
the same directory level as OpenLP trunk and named "documentation".
PyInstaller
PyInstaller can be installed with pip
Git
You need the command line "git" client installed.
OpenLP
A checkout of the latest code, in a branch directory, which is in a Bazaar
shared repository directory. This means your code should be in a directory
structure like this: "openlp\branch-name".
macosx-builder.py
This script, of course. It should be in the "osx-package" directory
at the same level as OpenLP trunk.
Mako
Mako Templates for Python. This package is required for building the
remote plugin.
Alembic
Required for upgrading the databases used in OpenLP.
PyMuPDF
Required for PDF support in OpenLP. Install using pip.
MachOLib
Python library to analyze and edit Mach-O headers, the executable format
used by Mac OS X. Used to relink the mudraw binary from MuPDF to the bundled
libraries. Install using macports or pip.
config.ini.default
The configuration file contains settings of the version string to include
in the bundle as well as directory and file settings for different
purposes (e.g. PyInstaller location or installer background image)
To install everything you should install latest python 3.7 from python.org. It
is recommended to create virtual environment. You can install all dependencies
like this:
$ python -m pip install sqlalchemy alembic appdirs chardet beautifulsoup4 \
lxml Mako mysql-connector-python pytest mock psycopg2-binary \
websockets asyncio waitress six webob requests QtAwesome PyQt5 \
PyQtWebEngine pymediainfo PyMuPDF==1.16.7 QDarkStyle python-vlc \
Pyro4 zeroconf flask-cors pytest-qt pyenchant pysword pyobjc-core \
pyobjc-framework-Cocoa dmgbuild sphinx PyInstaller
"""
import glob
import os
from pathlib import Path
from shutil import copy, copytree, move, rmtree
from builder import Builder
class LinuxBuilder(Builder):
"""
The :class:`LinuxBuilder` class encapsulates everything that is needed
to build a Linux app bundle.
"""
def get_platform(self):
"""
Return the plaform we're building for
"""
return 'Linux'
def get_qt_translations_path(self):
"""
Return the path to Qt translation files on macOS
"""
from PyQt5.QtCore import QCoreApplication
qt_library_path = QCoreApplication.libraryPaths()[0]
return os.path.join(os.path.dirname(qt_library_path), 'translations')
def copy_extra_files(self):
"""
Copy any extra files which are particular to a platform
"""
self._print('Copying extra files for Linux...')
def build_package(self):
"""
Build the actual DMG
"""
pass
if __name__ == '__main__':
LinuxBuilder().main()

View File

@ -4,7 +4,7 @@
##########################################################################
# OpenLP - Open Source Lyrics Projection #
# ---------------------------------------------------------------------- #
# Copyright (c) 2008-2019 OpenLP Developers #
# Copyright (c) 2008-2024 OpenLP Developers #
# ---------------------------------------------------------------------- #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #

View File

@ -4,7 +4,7 @@
##########################################################################
# OpenLP - Open Source Lyrics Projection #
# ---------------------------------------------------------------------- #
# Copyright (c) 2008-2019 OpenLP Developers #
# Copyright (c) 2008-2024 OpenLP Developers #
# ---------------------------------------------------------------------- #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #

18
linux/config.ini.default Normal file
View File

@ -0,0 +1,18 @@
[executables]
lrelease = /opt/local/libexec/qt5/bin/lrelease
[paths]
branch = path/to/openlp/trunk
documentation = path/to/openlp/documentation
icon = %(here)s/OpenLP.icns
bundle_info = %(here)s/Info.plist
hooks = %(here)s/../pyinstaller-hooks
dmg_settings = %(here)s/settings.py
license = %(here)s/LICENSE.txt
[transifex]
username =
password =
[codesigning]
certificate = org.openlp.OpenLP

View File

@ -29,7 +29,11 @@ if os.name.startswith('nt'):
dll = 'MediaInfo.dll'
elif sys.platform.startswith('darwin'):
dll = 'libmediainfo.0.dylib'
dll_path = os.path.join(os.path.dirname(pymediainfo.__file__), dll)
if sys.platform.startswith('linux'):
dll_path = '/usr/lib/libmediainfo.so'
else:
dll_path = os.path.join(os.path.dirname(pymediainfo.__file__), dll)
hiddenimports = ['pymediainfo']
binaries = [(dll_path, '.')]