From 0b1ba4ba6d51149cec78dbbdf2904315c48867f2 Mon Sep 17 00:00:00 2001 From: Bastian Germann Date: Wed, 3 Oct 2018 01:19:49 +0200 Subject: [PATCH] Fix setup's requirements Move the startup script so that its name does not conflict with the openlp namespace. Codify scripts/check_dependencies.py in setup.py. The name on PyPI is used to declare the dependencies. This is a first step to enable OpenLP distribution via PyPI. The differences are: * pyenchant and pyodbc are declared optional because they are optional in the code and pyenchant is not maintained anymore. * pyenchant's required version is set to 1.6 not only for windows. This version is quite old. * The 5.0 version checks for PyQt5 are left out because this is the first version anyway. * LibreOffice's uno does not exist on PyPI * sqlite3, asyncio and mock are available in Python >= 3.4 anyway and not noted as dependencies. * six is not defined as dependency because the code should be py3 only. The situation with regards to platform wheels being published looks quite promising. As Linux users typically install via their package manager wheel availability is not as import for them as for Win or Mac users. Both of them are available for most dependencies with native extensions. The few exceptions: * PyICU does not publish any platform wheels. More info: https://github.com/ovalhub/pyicu/issues/79 * mysql-connector-python does not publish win32 wheels. * pyenchant does not publish win64 wheels. The wheels are typically available for Py=2.7 and Py>=3.4, although some (mysql-connector-python, PyQt5, pywin32) need Py>=3.5 --- openlp.py => openlp/__main__.py | 5 +++- setup.py | 53 ++++++++++++++++++++++++++------- 2 files changed, 46 insertions(+), 12 deletions(-) rename openlp.py => openlp/__main__.py (99%) diff --git a/openlp.py b/openlp/__main__.py similarity index 99% rename from openlp.py rename to openlp/__main__.py index 38e270a9d..bf6378ed6 100755 --- a/openlp.py +++ b/openlp/__main__.py @@ -42,7 +42,7 @@ def set_up_fault_handling(): 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 __name__ == '__main__': if is_macosx(): sys.argv = [x for x in sys.argv if not x.startswith('-psn')] main() + +if __name__ == '__main__': + start() diff --git a/setup.py b/setup.py index a28fa0300..a7bc15c13 100755 --- a/setup.py +++ b/setup.py @@ -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,32 @@ except Exception: finally: ver_file.close() +requires = [ + 'alembic', + 'beautifulsoup4', + 'chardet', + 'lxml', + 'Mako', + '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 +184,21 @@ using a computer and a data projector.""", keywords='open source church presentation lyrics projection song bible display project', author='Raoul Snyman', author_email='raoulsnyman@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.4', + 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', 'pylint'], + entry_points={'gui_scripts': ['openlp = openlp.__main__:start']} )