Bastian Germann has proposed merging lp:~bastian-germann/openlp/setup into 
lp:openlp.

Commit message:
This fixes setuptools' dependencies according to
scripts/check_dependencies.py.
The minimum Python version is set to 3.6 because this was agreed to on the 
mailing list.

To overcome the module conflict, openlp.py is replaced with __main__.py which 
setuptools installs as /usr/bin/openlp (or openlp.exe on Windows).
You can call it locally via `python -m openlp`.

Some packages which are optional in the source are declared as optional (uno, 
pyenchant, pyodbc).

The vendored (ripped) pymediainfo module is replaced by its upstream version.

Additionally, replace pyxdg with appdirs (see License violations issue).

Requested reviews:
  Raoul Snyman (raoul-snyman)
Related bugs:
  Bug #1795876 in OpenLP: "License violations"
  https://bugs.launchpad.net/openlp/+bug/1795876

For more details, see:
https://code.launchpad.net/~bastian-germann/openlp/setup/+merge/356560


-- 
Your team OpenLP Core is subscribed to branch lp:openlp.
=== renamed file 'openlp.py' => 'openlp/__main__.py'
--- openlp.py	2017-12-29 09:15:48 +0000
+++ openlp/__main__.py	2018-10-11 11:05:44 +0000
@@ -42,7 +42,7 @@
     faulthandler.enable((AppLocation.get_directory(AppLocation.CacheDir) / 'error.log').open('wb'))
 
 
-if __name__ == '__main__':
+def start():
     """
     Instantiate and run the application.
     """
@@ -58,3 +58,6 @@
     if is_macosx():
         sys.argv = [x for x in sys.argv if not x.startswith('-psn')]
     main()
+
+if __name__ == '__main__':
+    start()

=== modified file 'openlp/core/app.py'
--- openlp/core/app.py	2018-08-25 14:36:46 +0000
+++ openlp/core/app.py	2018-10-11 11:05:44 +0000
@@ -288,7 +288,7 @@
     :return: a tuple of parsed options of type optparse.Value and a list of remaining argsZ
     """
     # Set up command line options.
-    parser = argparse.ArgumentParser(prog='openlp.py')
+    parser = argparse.ArgumentParser(prog='openlp')
     parser.add_argument('-e', '--no-error-form', dest='no_error_form', action='store_true',
                         help='Disable the error notification form.')
     parser.add_argument('-l', '--log-level', dest='loglevel', default='warning', metavar='LEVEL',

=== modified file 'openlp/core/common/applocation.py'
--- openlp/core/common/applocation.py	2018-01-07 04:45:13 +0000
+++ openlp/core/common/applocation.py	2018-10-11 11:05:44 +0000
@@ -26,18 +26,13 @@
 import os
 import sys
 
+import appdirs
+
 import openlp
 from openlp.core.common import get_frozen_path, is_win, is_macosx
 from openlp.core.common.path import Path, create_paths
 from openlp.core.common.settings import Settings
 
-if not is_win() and not is_macosx():
-    try:
-        from xdg import BaseDirectory
-        XDG_BASE_AVAILABLE = True
-    except ImportError:
-        XDG_BASE_AVAILABLE = False
-
 log = logging.getLogger(__name__)
 
 FROZEN_APP_PATH = Path(sys.argv[0]).parent
@@ -143,8 +138,10 @@
         elif dir_type == AppLocation.LanguageDir:
             return Path(openlp.__file__).parent
         return openlp_folder_path
-    elif is_macosx():
-        openlp_folder_path = Path(os.getenv('HOME'), 'Library', 'Application Support', 'openlp')
+
+    dirs = appdirs.AppDirs('openlp', multipath=True)
+    if is_macosx():
+        openlp_folder_path = Path(dirs.user_data_dir)
         if dir_type == AppLocation.DataDir:
             return openlp_folder_path / 'Data'
         elif dir_type == AppLocation.LanguageDir:
@@ -152,15 +149,15 @@
         return openlp_folder_path
     else:
         if dir_type == AppLocation.LanguageDir:
-            directory = Path('/usr', 'local', 'share', 'openlp')
+            site_dirs = dirs.site_data_dir.split(os.pathsep)
+            directory = Path(site_dirs[0])
             if directory.exists():
                 return directory
-            return Path('/usr', 'share', 'openlp')
-        if XDG_BASE_AVAILABLE:
-            if dir_type == AppLocation.DataDir:
-                return Path(BaseDirectory.xdg_data_home, 'openlp')
-            elif dir_type == AppLocation.CacheDir:
-                return Path(BaseDirectory.xdg_cache_home, 'openlp')
+            return Path(site_dirs[1])
+        if dir_type == AppLocation.DataDir:
+            return Path(dirs.user_data_dir)
+        elif dir_type == AppLocation.CacheDir:
+            return Path(dirs.user_cache_dir)
         if dir_type == AppLocation.DataDir:
             return Path(os.getenv('HOME'), '.openlp', 'data')
         return Path(os.getenv('HOME'), '.openlp')

=== modified file 'openlp/core/common/registry.py'
--- openlp/core/common/registry.py	2018-06-24 06:56:50 +0000
+++ openlp/core/common/registry.py	2018-10-11 11:05:44 +0000
@@ -57,8 +57,7 @@
         registry.functions_list = {}
         registry.working_flags = {}
         # Allow the tests to remove Registry entries but not the live system
-        registry.running_under_test = 'nose' in sys.argv[0]
-        registry.running_under_test = 'pytest' in sys.argv[0]
+        registry.running_under_test = 'nose' in sys.argv[0] or 'pytest' in sys.argv[0]
         registry.initialising = True
         return registry
 

=== added file 'openlp/core/ui/fonts/LICENSE'
--- openlp/core/ui/fonts/LICENSE	1970-01-01 00:00:00 +0000
+++ openlp/core/ui/fonts/LICENSE	2018-10-11 11:05:44 +0000
@@ -0,0 +1,94 @@
+Copyright Dave Gandy 2016. All rights reserved
+with Reserved Font Name FontAwesome
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+http://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded, 
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.

=== modified file 'openlp/core/ui/media/vendor/mediainfoWrapper.py'
--- openlp/core/ui/media/vendor/mediainfoWrapper.py	2017-12-29 09:15:48 +0000
+++ openlp/core/ui/media/vendor/mediainfoWrapper.py	2018-10-11 11:05:44 +0000
@@ -20,109 +20,20 @@
 # Temple Place, Suite 330, Boston, MA 02111-1307 USA                          #
 ###############################################################################
 """
-The :mod:`~openlp.core.ui.media.mediainfo` module contains code to run mediainfo on a media file and obtain
-information related to the rwquested media.
+The :mod:`~openlp.core.ui.media.mediainfo` module contains code to run mediainfo
+on a media file and obtain information related to the requested media.
 """
-import json
-import os
+from pymediainfo import MediaInfo
 from subprocess import check_output
 
-from bs4 import BeautifulSoup, NavigableString
-
-ENV_DICT = os.environ
-
-
-class Track(object):
-
-    def __getattribute__(self, name):
-        try:
-            return object.__getattribute__(self, name)
-        except:
-            pass
-        return None
-
-    def __init__(self, xml_dom_fragment):
-        self.xml_dom_fragment = xml_dom_fragment
-        self.track_type = xml_dom_fragment.attrs['type']
-        for el in self.xml_dom_fragment.children:
-            if not isinstance(el, NavigableString):
-                node_name = el.name.lower().strip().strip('_')
-                if node_name == 'id':
-                    node_name = 'track_id'
-                node_value = el.string
-                other_node_name = "other_%s" % node_name
-                if getattr(self, node_name) is None:
-                    setattr(self, node_name, node_value)
-                else:
-                    if getattr(self, other_node_name) is None:
-                        setattr(self, other_node_name, [node_value, ])
-                    else:
-                        getattr(self, other_node_name).append(node_value)
-
-        for o in [d for d in self.__dict__.keys() if d.startswith('other_')]:
-            try:
-                primary = o.replace('other_', '')
-                setattr(self, primary, int(getattr(self, primary)))
-            except:
-                for v in getattr(self, o):
-                    try:
-                        current = getattr(self, primary)
-                        setattr(self, primary, int(v))
-                        getattr(self, o).append(current)
-                        break
-                    except:
-                        pass
-
-    def __repr__(self):
-        return "<Track track_id='{0}', track_type='{1}'>".format(self.track_id, self.track_type)
-
-    def to_data(self):
-        data = {}
-        for k, v in self.__dict__.items():
-            if k != 'xml_dom_fragment':
-                data[k] = v
-        return data
-
-
 class MediaInfoWrapper(object):
 
-    def __init__(self, xml):
-        self.xml_dom = xml
-        xml_types = (str,)     # no unicode type in python3
-        if isinstance(xml, xml_types):
-            self.xml_dom = MediaInfoWrapper.parse_xml_data_into_dom(xml)
-
-    @staticmethod
-    def parse_xml_data_into_dom(xml_data):
-        return BeautifulSoup(xml_data, "xml")
-
-    @staticmethod
-    def parse(filename, environment=ENV_DICT):
-        xml = check_output(['mediainfo', '-f', '--Output=XML', '--Inform=OLDXML', filename])
-        if not xml.startswith(b'<?xml'):
-            xml = check_output(['mediainfo', '-f', '--Output=XML', filename])
-        xml_dom = MediaInfoWrapper.parse_xml_data_into_dom(xml)
-        return MediaInfoWrapper(xml_dom)
-
-    def _populate_tracks(self):
-        if self.xml_dom is None:
-            return
-        for xml_track in self.xml_dom.Mediainfo.File.find_all("track"):
-            self._tracks.append(Track(xml_track))
-
-    @property
-    def tracks(self):
-        if not hasattr(self, "_tracks"):
-            self._tracks = []
-        if len(self._tracks) == 0:
-            self._populate_tracks()
-        return self._tracks
-
-    def to_data(self):
-        data = {'tracks': []}
-        for track in self.tracks:
-            data['tracks'].append(track.to_data())
-        return data
-
-    def to_json(self):
-        return json.dumps(self.to_data())
+    @staticmethod
+    def parse(filename):
+        if MediaInfo.can_parse():
+            return MediaInfo.parse(filename)
+        else:
+            xml = check_output(['mediainfo', '-f', '--Output=XML', '--Inform=OLDXML', filename])
+            if not xml.startswith(b'<?xml'):
+                xml = check_output(['mediainfo', '-f', '--Output=XML', filename])
+            return MediaInfo(xml)

=== modified file 'openlp/plugins/media/mediaplugin.py'
--- openlp/plugins/media/mediaplugin.py	2018-08-25 14:08:19 +0000
+++ openlp/plugins/media/mediaplugin.py	2018-10-11 11:05:44 +0000
@@ -25,6 +25,7 @@
 import logging
 import re
 
+from pymediainfo import MediaInfo
 from PyQt5 import QtCore
 
 from openlp.core.api.http import register_endpoint
@@ -77,8 +78,8 @@
         :return: true or false
         """
         log.debug('check_installed Mediainfo')
-        # Try to find mediainfo in the path
-        exists = process_check_binary(Path('mediainfo'))
+        # Try to find libmediainfo or mediainfo in the path
+        exists = MediaInfo.can_parse() or process_check_binary(Path('mediainfo'))
         # If mediainfo is not in the path, try to find it in the application folder
         if not exists:
             exists = process_check_binary(AppLocation.get_directory(AppLocation.AppDir) / 'mediainfo')

=== modified file 'scripts/check_dependencies.py'
--- scripts/check_dependencies.py	2018-04-22 06:59:35 +0000
+++ scripts/check_dependencies.py	2018-10-11 11:05:44 +0000
@@ -33,24 +33,18 @@
 import sys
 from distutils.version import LooseVersion
 
-# If we try to import uno before nose this will create a warning. Just try to import nose first to suppress the warning.
-try:
-    import nose
-except ImportError:
-    nose = None
-
 IS_WIN = sys.platform.startswith('win')
 IS_LIN = sys.platform.startswith('lin')
 IS_MAC = sys.platform.startswith('dar')
 
 
 VERS = {
-    'Python': '3.4',
+    'Python': '3.6',
     'PyQt5': '5.0',
     'Qt5': '5.0',
+    'pymediainfo': '2.2',
     'sqlalchemy': '0.5',
-    # pyenchant 1.6 required on Windows
-    'enchant': '1.6' if IS_WIN else '1.3'
+    'enchant': '1.6'
 }
 
 # pywin32
@@ -58,7 +52,6 @@
     'win32com',
     'win32ui',
     'pywintypes',
-    'pyodbc',
     'icu',
 ]
 
@@ -84,19 +77,16 @@
     'PyQt5.QtTest',
     'PyQt5.QtWebKit',
     'PyQt5.QtMultimedia',
+    'pymediainfo',
+    'appdirs',
     'sqlalchemy',
     'alembic',
-    'sqlite3',
     'lxml',
     'chardet',
-    'enchant',
     'bs4',
     'mako',
-    'uno',
     'websockets',
-    'asyncio',
     'waitress',
-    'six',
     'webob',
     'requests',
     'qtawesome'
@@ -104,12 +94,16 @@
 
 
 OPTIONAL_MODULES = [
-    ('mysql.connector', '(MySQL support)', True),
-    ('psycopg2', '(PostgreSQL support)', True),
-    ('nose', '(testing framework)', True),
-    ('mock', '(testing module)', sys.version_info[1] < 3),
-    ('jenkins', '(access jenkins api - package name: jenkins-webapi)', True),
-    ('pysword', '(import SWORD bibles)', True),
+    ('mysql.connector', '(MySQL support)'),
+    ('pyodbc', '(ODBC support)'),
+    ('psycopg2', '(PostgreSQL support)'),
+    ('jenkins', '(access jenkins api - package name: jenkins-webapi)'),
+    ('enchant', '(spell checker)'),
+    ('pysword', '(import SWORD bibles)'),
+    ('uno', '(LibreOffice/OpenOffice support)'),
+    # development/testing modules
+    ('nose2', '(testing framework)'),
+    ('pylint', '(linter)')
 ]
 
 w = sys.stdout.write
@@ -238,8 +232,7 @@
         check_module(m)
     print('Checking for optional modules...')
     for m in OPTIONAL_MODULES:
-        if m[2]:
-            check_module(m[0], text=m[1])
+        check_module(m[0], text=m[1])
     if IS_WIN:
         print('Checking for Windows specific modules...')
         for m in WIN32_MODULES:

=== modified file 'setup.py'
--- setup.py	2018-08-22 05:04:11 +0000
+++ setup.py	2018-10-11 11:05:44 +0000
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
 # -*- coding: utf-8 -*-
 # vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
 
@@ -21,6 +22,7 @@
 ###############################################################################
 
 import re
+import sys
 from setuptools import setup, find_packages
 from subprocess import Popen, PIPE
 
@@ -109,6 +111,34 @@
 finally:
     ver_file.close()
 
+requires = [
+    'alembic',
+    'appdirs',
+    'beautifulsoup4',
+    'chardet',
+    'lxml',
+    'Mako',
+    'pymediainfo >= 2.2',
+    'PyQt5',
+    'QtAwesome',
+    'requests',
+    'SQLAlchemy >= 0.5',
+    'waitress',
+    'WebOb',
+    'websockets'
+]
+if sys.platform.startswith('win'):
+    requires.extend([
+        'PyICU',
+        'pywin32'
+    ])
+elif sys.platform.startswith('darwin'):
+    requires.extend([
+        'pyobjc',
+        'pyobjc-framework-Cocoa'
+    ])
+elif sys.platform.startswith('linux'):
+    requires.append('dbus-python')
 
 setup(
     name='OpenLP',
@@ -156,18 +186,22 @@
     keywords='open source church presentation lyrics projection song bible display project',
     author='Raoul Snyman',
     author_email='raoulsny...@openlp.org',
-    url='http://openlp.org/',
+    url='https://openlp.org/',
     license='GNU General Public License',
-    packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
-    scripts=['openlp.py'],
+    packages=find_packages(exclude=['ez_setup', 'tests*']),
     include_package_data=True,
     zip_safe=False,
-    install_requires=[
-        # -*- Extra requirements: -*-
-        'sqlalchemy',
-        'alembic'
-    ],
-    entry_points="""
-    # -*- Entry points: -*-
-    """
+    python_requires='>=3.6',
+    install_requires=requires,
+    extras_require={
+        'jenkins': ['python-jenkins'],
+        'mysql': ['mysql-connector-python'],
+        'odbc': ['pyodbc'],
+        'postgresql': ['psycopg2'],
+        'spellcheck': ['pyenchant >= 1.6'],
+        'sword-bibles': ['pysword']
+    },
+    tests_require=['nose2', 'PyICU', 'pylint'],
+    test_suite='nose2.collector.collector',
+    entry_points={'gui_scripts': ['openlp = openlp.__main__:start']}
 )

=== modified file 'tests/README.txt'
--- tests/README.txt	2012-12-05 18:52:31 +0000
+++ tests/README.txt	2018-10-11 11:05:44 +0000
@@ -8,10 +8,10 @@
 
 In order to run the unit tests, you will need the following Python packages/libraries installed:
 
- - Mock
- - Nose
+ - nose2
+ - pylint
 
-On Ubuntu you can simple install the python-mock and python-nose packages. Most other distributions will also have these
+On Ubuntu you can simple install the python-nose2 and pylint packages. Most other distributions will also have these
 packages. On Windows and Mac OS X you will need to use ``pip`` or ``easy_install`` to install these packages.
 
 Running the Tests
@@ -19,16 +19,16 @@
 
 To run the tests, navigate to the root directory of the OpenLP project, and then run the following command::
 
-    nosetests -v tests
+    nose2 -v tests
 
 Or, to run only the functional tests, run the following command::
 
-    nosetests -v tests/functional
+    nose2 -v tests.functional
 
 Or, to run only a particular test suite within a file, run the following command::
 
-    nosetests -v tests/functional/test_applocation.py
+    nose2 -v tests.functional.openlp_core.test_app
 
 Finally, to only run a particular test, run the following command::
 
-    nosetests -v tests/functional/test_applocation.py:TestAppLocation.get_frozen_path_test
+    nose2 -v tests.functional.openlp_core.test_app.TestOpenLP.test_process_events

=== modified file 'tests/functional/openlp_core/common/test_i18n.py'
--- tests/functional/openlp_core/common/test_i18n.py	2018-08-27 14:16:26 +0000
+++ tests/functional/openlp_core/common/test_i18n.py	2018-10-11 11:05:44 +0000
@@ -113,11 +113,11 @@
     assert language is None
 
 
-@skipIf(is_macosx(), 'This test doesn\'t work on macOS currently')
 def test_get_locale_key():
     """
     Test the get_locale_key(string) function
     """
+    import icu
     with patch('openlp.core.common.i18n.LanguageManager.get_language') as mocked_get_language:
         # GIVEN: The language is German
         # 0x00C3 (A with diaresis) should be sorted as "A". 0x00DF (sharp s) should be sorted as "ss".

_______________________________________________
Mailing list: https://launchpad.net/~openlp-core
Post to     : openlp-core@lists.launchpad.net
Unsubscribe : https://launchpad.net/~openlp-core
More help   : https://help.launchpad.net/ListHelp

Reply via email to