Skip to content

Commit

Permalink
Overhauled startup functions for PyPI packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
AcidWeb committed Mar 17, 2017
1 parent 2e9b338 commit 8048b91
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 72 deletions.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
exclude kindlecomicconverter/sentry.py
9 changes: 2 additions & 7 deletions kcc-c2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,9 @@
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()
9 changes: 2 additions & 7 deletions kcc-c2p.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,9 @@
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()
20 changes: 3 additions & 17 deletions kcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,24 +63,10 @@ def __init__(self, *args, **kw):
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()

53 changes: 53 additions & 0 deletions kindlecomicconverter/startup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# -*- coding: utf-8 -*-
#
# Copyright (c) 2012-2014 Ciro Mattia Gonano <[email protected]>
# Copyright (c) 2013-2017 Pawel Jastrzebski <[email protected]>
#
# 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:]))
54 changes: 13 additions & 41 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
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
Expand Down Expand Up @@ -60,42 +60,8 @@ def run(self):
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={
Expand All @@ -109,12 +75,18 @@ def run(self):
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',
Expand Down

0 comments on commit 8048b91

Please sign in to comment.