diff options
author | Paweł Jastrzębski <pawelj@iosphe.re> | 2017-03-17 10:55:56 +0100 |
---|---|---|
committer | Paweł Jastrzębski <pawelj@iosphe.re> | 2017-03-17 10:55:56 +0100 |
commit | 8048b91fa86428d71329b15275d3134230a06019 (patch) | |
tree | 8d1f2c06c18f9aee0c28bcfee902729501e0ad7c | |
parent | Code cleanup (diff) | |
download | kcc-8048b91fa86428d71329b15275d3134230a06019.tar.gz kcc-8048b91fa86428d71329b15275d3134230a06019.tar.bz2 kcc-8048b91fa86428d71329b15275d3134230a06019.zip |
Overhauled startup functions for PyPI packaging
-rw-r--r-- | MANIFEST.in | 1 | ||||
-rwxr-xr-x | kcc-c2e.py | 9 | ||||
-rwxr-xr-x | kcc-c2p.py | 9 | ||||
-rwxr-xr-x | kcc.py | 20 | ||||
-rw-r--r-- | kindlecomicconverter/startup.py | 53 | ||||
-rwxr-xr-x | setup.py | 54 |
6 files changed, 74 insertions, 72 deletions
diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..e938f6e --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1 @@ +exclude kindlecomicconverter/sentry.py \ No newline at end of file diff --git a/kcc-c2e.py b/kcc-c2e.py index cb83188..c17deec 100755 --- a/kcc-c2e.py +++ b/kcc-c2e.py @@ -23,14 +23,9 @@ if sys.version_info[0] != 3: print('ERROR: This is Python 3 script!') exit(1) -from kindlecomicconverter.shared import dependencyCheck -dependencyCheck(2) - from multiprocessing import freeze_support -from kindlecomicconverter import __version__ -from kindlecomicconverter.comic2ebook import main +from kindlecomicconverter.startup import startC2E if __name__ == "__main__": freeze_support() - print('comic2ebook v' + __version__ + ' - Written by Ciro Mattia Gonano and Pawel Jastrzebski.') - sys.exit(main(sys.argv[1:])) + startC2E() diff --git a/kcc-c2p.py b/kcc-c2p.py index bc6aa6b..f1fb915 100755 --- a/kcc-c2p.py +++ b/kcc-c2p.py @@ -23,14 +23,9 @@ if sys.version_info[0] != 3: print('ERROR: This is Python 3 script!') exit(1) -from kindlecomicconverter.shared import dependencyCheck -dependencyCheck(1) - from multiprocessing import freeze_support -from kindlecomicconverter import __version__ -from kindlecomicconverter.comic2panel import main +from kindlecomicconverter.startup import startC2P if __name__ == "__main__": freeze_support() - print('comic2panel v' + __version__ + ' - Written by Ciro Mattia Gonano and Pawel Jastrzebski.') - sys.exit(main(sys.argv[1:])) + startC2P() \ No newline at end of file diff --git a/kcc.py b/kcc.py index a93e48f..445b0a3 100755 --- a/kcc.py +++ b/kcc.py @@ -63,24 +63,10 @@ if getattr(sys, 'frozen', False): except: pass -from kindlecomicconverter.shared import dependencyCheck -dependencyCheck(3) - from multiprocessing import freeze_support -from kindlecomicconverter import KCC_gui +from kindlecomicconverter.startup import start if __name__ == "__main__": freeze_support() - os.environ['QT_AUTO_SCREEN_SCALE_FACTOR'] = "1" - KCCAplication = KCC_gui.QApplicationMessaging(sys.argv) - if KCCAplication.isRunning(): - if len(sys.argv) > 1: - KCCAplication.sendMessage(sys.argv[1]) - else: - KCCAplication.sendMessage('ARISE') - else: - KCCWindow = KCC_gui.QMainWindowKCC() - KCCUI = KCC_gui.KCCGUI(KCCAplication, KCCWindow) - if len(sys.argv) > 1: - KCCUI.handleMessage(sys.argv[1]) - sys.exit(KCCAplication.exec_()) + start() + diff --git a/kindlecomicconverter/startup.py b/kindlecomicconverter/startup.py new file mode 100644 index 0000000..4c47a17 --- /dev/null +++ b/kindlecomicconverter/startup.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# +# Copyright (c) 2012-2014 Ciro Mattia Gonano <ciromattia@gmail.com> +# Copyright (c) 2013-2017 Pawel Jastrzebski <pawelj@iosphe.re> +# +# Permission to use, copy, modify, and/or distribute this software for +# any purpose with or without fee is hereby granted, provided that the +# above copyright notice and this permission notice appear in all +# copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL +# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE +# AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL +# DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA +# OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +# PERFORMANCE OF THIS SOFTWARE. +# + +import os +import sys +from . import __version__ +from .shared import dependencyCheck + +def start(): + dependencyCheck(3) + from . import KCC_gui + os.environ['QT_AUTO_SCREEN_SCALE_FACTOR'] = "1" + KCCAplication = KCC_gui.QApplicationMessaging(sys.argv) + if KCCAplication.isRunning(): + if len(sys.argv) > 1: + KCCAplication.sendMessage(sys.argv[1]) + else: + KCCAplication.sendMessage('ARISE') + else: + KCCWindow = KCC_gui.QMainWindowKCC() + KCCUI = KCC_gui.KCCGUI(KCCAplication, KCCWindow) + if len(sys.argv) > 1: + KCCUI.handleMessage(sys.argv[1]) + sys.exit(KCCAplication.exec_()) + +def startC2E(): + dependencyCheck(2) + from .comic2ebook import main + print('comic2ebook v' + __version__ + ' - Written by Ciro Mattia Gonano and Pawel Jastrzebski.') + sys.exit(main(sys.argv[1:])) + +def startC2P(): + dependencyCheck(1) + from .comic2panel import main + print('comic2panel v' + __version__ + ' - Written by Ciro Mattia Gonano and Pawel Jastrzebski.') + sys.exit(main(sys.argv[1:])) \ No newline at end of file diff --git a/setup.py b/setup.py index cdd19eb..7e330fe 100755 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ Usage (Windows): py -3 setup.py build_binary Usage (Linux/OS X): - python3 setup.py build_binary or python3 setup.py build_binary --pyz + python3 setup.py build_binary """ import os @@ -60,42 +60,8 @@ class BuildBinaryCommand(distutils.cmd.Command): os.system('setup.bat') exit(0) else: - if self.pyz: - script = ''' - cp kcc.py __main__.py - zip kcc.zip __main__.py kindlecomicconverter/*.py - echo "#!/usr/bin/env python3" > kcc-bin - cat kcc.zip >> kcc-bin - chmod +x kcc-bin - - cp kcc-c2e.py __main__.py - zip kcc-c2e.zip __main__.py kindlecomicconverter/*.py - echo "#!/usr/bin/env python3" > kcc-c2e-bin - cat kcc-c2e.zip >> kcc-c2e-bin - chmod +x kcc-c2e-bin - - cp kcc-c2p.py __main__.py - zip kcc-c2p.zip __main__.py kindlecomicconverter/*.py - echo "#!/usr/bin/env python3" > kcc-c2p-bin - cat kcc-c2p.zip >> kcc-c2p-bin - chmod +x kcc-c2p-bin - - mkdir dist - tar --xform s:^.*/:: \ - --xform s/LICENSE.txt/LICENSE/ \ - --xform s/kcc-bin/kcc/ \ - --xform s/kcc-c2p-bin/kcc-c2p/ \ - --xform s/kcc-c2e-bin/kcc-c2e/ \ - --xform s/comic2ebook/kcc/ \ - -czf dist/KindleComicConverter_linux_''' + VERSION + '''.tar.gz \ - kcc-bin kcc-c2e-bin kcc-c2p-bin LICENSE.txt README.md icons/comic2ebook.png - rm __main__.py kcc.zip kcc-c2e.zip kcc-c2p.zip kcc-bin kcc-c2e-bin kcc-c2p-bin - ''' - os.system("bash -c '%s'" % script) - exit(0) - else: - os.system('docker run --rm -v ' + os.getcwd() + ':/app -e KCCVER=' + VERSION + ' acidweb/kcc') - exit(0) + os.system('docker run --rm -v ' + os.getcwd() + ':/app -e KCCVER=' + VERSION + ' acidweb/kcc') + exit(0) setuptools.setup( cmdclass={ @@ -109,12 +75,18 @@ setuptools.setup( license='ISC License (ISCL)', keywords=['kindle', 'kobo', 'comic', 'manga', 'mobi', 'epub', 'cbz'], url='http://github.com/ciromattia/kcc', - scripts=['kcc.py', - 'kcc-c2e.py', - 'kcc-c2p.py'], + entry_points={ + 'console_scripts': [ + 'kcc-c2e = kindlecomicconverter.startup:startC2E', + 'kcc-c2p = kindlecomicconverter.startup:startC2P', + ], + 'gui_scripts': [ + 'kcc = kindlecomicconverter.startup:start', + ], + }, packages=['kindlecomicconverter'], install_requires=[ - 'PyQt5>=5.6.0' + 'PyQt5>=5.6.0', 'Pillow>=4.0.0', 'psutil>=5.0.0', 'python-slugify>=1.2.1', |