1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
#!/usr/bin/env python3
"""
cx_Freeze/py2app build script for KCC.
Usage (Mac OS X):
python setup.py py2app
Usage (Windows):
python setup.py py2exe
"""
from sys import platform, version_info
if version_info[0] != 3:
print('ERROR: This is Python 3 script!')
exit(1)
NAME = "KindleComicConverter"
VERSION = "4.0.2"
MAIN = "kcc.py"
if platform == "darwin":
from setuptools import setup
extra_options = dict(
setup_requires=['py2app'],
app=[MAIN],
options=dict(
py2app=dict(
argv_emulation=True,
iconfile='icons/comic2ebook.icns',
includes=['PIL', 'sip', 'PyQt5', 'PyQt5.QtCore', 'PyQt5.QtGui', 'PyQt5.QtNetwork', 'PyQt5.QtWidgets',
'PyQt5.QtPrintSupport'],
resources=['LICENSE.txt', 'other/qt.conf', 'other/Additional-LICENSE.txt', 'other/unrar', 'other/7za'],
plist=dict(
CFBundleName=NAME,
CFBundleShortVersionString=VERSION,
CFBundleGetInfoString=NAME + " " + VERSION +
", written 2012-2014 by Ciro Mattia Gonano and Pawel Jastrzebski",
CFBundleExecutable=NAME,
CFBundleIdentifier='com.github.ciromattia.kcc',
CFBundleSignature='dplt',
CFBundleDocumentTypes=[
dict(
CFBundleTypeExtensions=['cbz', 'cbr', 'cb7', 'zip', 'rar', '7z', 'pdf'],
CFBundleTypeName='Comics',
CFBundleTypeIconFile='comic2ebook.icns',
CFBundleTypeRole='Editor',
)
],
LSMinimumSystemVersion='10.8.0',
LSEnvironment=dict(
PATH='/usr/local/bin:/usr/bin:/bin'
),
NSHumanReadableCopyright='ISC License (ISCL)'
)
)
)
)
elif platform == "win32":
# noinspection PyUnresolvedReferences
import py2exe
import platform as arch
from distutils.core import setup
if arch.architecture()[0] == '64bit':
suffix = '_64'
else:
suffix = ''
additional_files = [('imageformats', ['C:\Python33' + suffix +
'\Lib\site-packages\PyQt5\plugins\imageformats\qgif.dll',
'C:\Python33' + suffix +
'\Lib\site-packages\PyQt5\plugins\imageformats\qico.dll',
'C:\Python33' + suffix +
'\Lib\site-packages\PyQt5\plugins\imageformats\qjpeg.dll',
'C:\Python33' + suffix +
'\Lib\site-packages\PyQt5\plugins\imageformats\qmng.dll',
'C:\Python33' + suffix +
'\Lib\site-packages\PyQt5\plugins\imageformats\qsvg.dll',
'C:\Python33' + suffix +
'\Lib\site-packages\PyQt5\plugins\imageformats\qtga.dll',
'C:\Python33' + suffix +
'\Lib\site-packages\PyQt5\plugins\imageformats\qtiff.dll',
'C:\Python33' + suffix +
'\Lib\site-packages\PyQt5\plugins\imageformats\qwbmp.dll']),
('platforms', ['C:\Python33' + suffix +
'\Lib\site-packages\PyQt5\plugins\platforms\qminimal.dll',
'C:\Python33' + suffix +
'\Lib\site-packages\PyQt5\plugins\platforms\qoffscreen.dll',
'C:\Python33' + suffix +
'\Lib\site-packages\PyQt5\plugins\platforms\qwindows.dll']),
('', ['LICENSE.txt',
'other\\7za.exe',
'other\\UnRAR.exe',
'other\\Additional-LICENSE.txt',
'other\\7za.exe',
'C:\Python33' + suffix + '\Lib\site-packages\PyQt5\libEGL.dll'])]
extra_options = dict(
options={'py2exe': {"bundle_files": 2,
"dll_excludes": ["tcl85.dll", "tk85.dll"],
"dist_dir": "dist" + suffix,
"compressed": True,
"includes": ["sip"],
"excludes": ["tkinter"],
"optimize": 2}},
windows=[{"script": "kcc.py",
"dest_base": "KCC",
"version": VERSION,
"copyright": "Ciro Mattia Gonano, Pawel Jastrzebski © 2014",
"legal_copyright": "ISC License (ISCL)",
"product_version": VERSION,
"product_name": "Kindle Comic Converter",
"file_description": "Kindle Comic Converter",
"icon_resources": [(1, "icons\comic2ebook.ico")]}],
zipfile=None,
data_files=additional_files)
else:
print('Please use setup.sh to build Linux package.')
exit()
#noinspection PyUnboundLocalVariable
setup(
name=NAME,
version=VERSION,
author="Ciro Mattia Gonano, Pawel Jastrzebski",
author_email="ciromattia@gmail.com, pawelj@iosphe.re",
description="Kindle Comic Converter",
license="ISC License (ISCL)",
keywords="kindle comic mobipocket mobi cbz cbr manga",
url="http://github.com/ciromattia/kcc",
**extra_options
)
if platform == "darwin":
from os import chmod, makedirs
from shutil import copyfile
makedirs('dist/' + NAME + '.app/Contents/PlugIns/platforms')
copyfile('other/libqcocoa.dylib', 'dist/' + NAME + '.app/Contents/PlugIns/platforms/libqcocoa.dylib')
chmod('dist/' + NAME + '.app/Contents/Resources/unrar', 0o777)
chmod('dist/' + NAME + '.app/Contents/Resources/7za', 0o777)
|