← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~bastian-germann/openlp/setup into lp:openlp

 

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.
Some packages which are optional in the source are declared as optional (uno, pyenchant, pyodbc).

To overcome a module conflict, openlp.py is replaced with run_openlp.py which setuptools installs as /usr/bin/openlp (or openlp.exe on Windows).

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

Requested reviews:
  Tim Bentley (trb143)
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/356881
-- 
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/app.py'
--- openlp/core/app.py	2018-08-25 14:36:46 +0000
+++ openlp/core/app.py	2018-10-16 21:00:41 +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-16 21:00:41 +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-16 21:00:41 +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
 

=== modified file 'openlp/core/ui/aboutdialog.py'
--- openlp/core/ui/aboutdialog.py	2018-06-24 06:56:50 +0000
+++ openlp/core/ui/aboutdialog.py	2018-10-16 21:00:41 +0000
@@ -112,8 +112,8 @@
                       'Andreas "googol" Preikschat', 'Ken "alisonken1" Roberts', 'Raoul "superfly" Snyman',
                       'Jonathan "springermac" Springer', 'Philip "Phill" Ridout']
         contributors = ['Stuart "sibecker" Becker', 'Gerald "jerryb" Britton', 'Jonathan "gushie" Corwin',
-                        'Samuel "MrGamgee" Findlay', 'Michael "cocooncrash" Gorven', 'Scott "sguerrieri" Guerrieri',
-                        'Simon Hanna', 'Chris Hill',
+                        'Samuel "MrGamgee" Findlay', 'Bastian Germann', 'Michael "cocooncrash" Gorven',
+                        'Scott "sguerrieri" Guerrieri', 'Simon Hanna', 'Chris Hill',
                         'Matthias "matthub" Hub', 'Meinert "m2j" Jordan', 'Ian Knightly'
                         'Armin "orangeshirt" K\xf6hler',
                         'Rafael "rafaellerm" Lerm', 'Gabriel loo', 'Erik "luen" Lundin', 'Edwin "edwinlunando" Lunando',

=== 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-16 21:00:41 +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.

=== renamed file 'openlp.py' => 'run_openlp.py'
--- openlp.py	2017-12-29 09:15:48 +0000
+++ run_openlp.py	2018-10-16 21:00:41 +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,7 @@
     if is_macosx():
         sys.argv = [x for x in sys.argv if not x.startswith('-psn')]
     main()
+
+
+if __name__ == '__main__':
+    start()

=== modified file 'scripts/appveyor.yml'
--- scripts/appveyor.yml	2018-08-05 20:28:01 +0000
+++ scripts/appveyor.yml	2018-10-16 21:00:41 +0000
@@ -11,11 +11,8 @@
 
 install:
   # Install dependencies from pypi
-  - "%PYTHON%\\python.exe -m pip install sqlalchemy alembic chardet beautifulsoup4 Mako nose mock pyodbc==4.0.8 psycopg2 pypiwin32==219 pyenchant websockets asyncio waitress six webob requests QtAwesome"
-  # Install mysql dependency
-  - "%PYTHON%\\python.exe -m pip install http://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-2.0.4.zip#md5=3df394d89300db95163f17c843ef49df";
-  # Download and install lxml and pyicu (originally from http://www.lfd.uci.edu/~gohlke/pythonlibs/)
-  - "%PYTHON%\\python.exe -m pip install https://get.openlp.org/win-sdk/lxml-3.6.4-cp34-cp34m-win32.whl";
+  - "%PYTHON%\\python.exe -m pip install sqlalchemy alembic appdirs chardet beautifulsoup4 lxml Mako mysql-connector-python nose mock pyodbc==4.0.8 psycopg2 pypiwin32==219 pyenchant pymediainfo websockets asyncio waitress six webob requests QtAwesome"
+  # Download and install pyicu (originally from http://www.lfd.uci.edu/~gohlke/pythonlibs/)
   - "%PYTHON%\\python.exe -m pip install https://get.openlp.org/win-sdk/PyICU-1.9.5-cp34-cp34m-win32.whl";
   # Download and install PyQt5
   - appveyor DownloadFile http://downloads.sourceforge.net/project/pyqt/PyQt5/PyQt-5.5.1/PyQt5-5.5.1-gpl-Py3.4-Qt5.5.1-x32.exe

=== modified file 'scripts/check_dependencies.py'
--- scripts/check_dependencies.py	2018-04-22 06:59:35 +0000
+++ scripts/check_dependencies.py	2018-10-16 21:00:41 +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,17 @@
 
 
 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)'),
+    ('enchant', '(spell checker)'),
+    ('pysword', '(import SWORD bibles)'),
+    ('uno', '(LibreOffice/OpenOffice support)'),
+    # development/testing modules
+    ('jenkins', '(access jenkins api)'),
+    ('launchpadlib', '(launchpad script support)'),
+    ('nose2', '(testing framework)'),
+    ('pylint', '(linter)')
 ]
 
 w = sys.stdout.write
@@ -238,8 +233,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-16 21:00:41 +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,25 @@
     keywords='open source church presentation lyrics projection song bible display project',
     author='Raoul Snyman',
     author_email='raoulsnyman@xxxxxxxxxx',
-    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']),
+    py_modules=['run_openlp'],
     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={
+        'mysql': ['mysql-connector-python'],
+        'odbc': ['pyodbc'],
+        'postgresql': ['psycopg2'],
+        'spellcheck': ['pyenchant >= 1.6'],
+        'sword-bibles': ['pysword'],
+        # Required for scripts/*.py:
+        'jenkins': ['python-jenkins'],
+        'launchpad': ['launchpadlib']
+    },
+    tests_require=['nose2', 'PyICU', 'pylint', 'pyodbc', 'pysword'],
+    test_suite='nose2.collector.collector',
+    entry_points={'gui_scripts': ['openlp = run_openlp:start']}
 )

=== modified file 'tests/README.txt'
--- tests/README.txt	2012-12-05 18:52:31 +0000
+++ tests/README.txt	2018-10-16 21:00:41 +0000
@@ -8,10 +8,10 @@
 
 In order to run the unit tests, you will need the following Python packages/libraries installed:
 
- - Mock
- - Nose
+ - pytest
+ - pylint3
 
-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 python3-pytest and pylint3 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,12 @@
 
 To run the tests, navigate to the root directory of the OpenLP project, and then run the following command::
 
-    nosetests -v tests
+    pytest -v tests
 
 Or, to run only the functional tests, run the following command::
 
-    nosetests -v tests/functional
+    pytest -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
-
-Finally, to only run a particular test, run the following command::
-
-    nosetests -v tests/functional/test_applocation.py:TestAppLocation.get_frozen_path_test
+    pytest -v tests/functional/openlp_core/test_app.py


Follow ups