mirror of
https://github.com/ciromattia/kcc
synced 2025-12-11 00:36:33 +00:00
Migrated to PyInstaller
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -10,3 +10,6 @@ Output
|
||||
test
|
||||
solaio
|
||||
kindlegen*
|
||||
*.spec
|
||||
setup.bat
|
||||
setup.sh
|
||||
|
||||
26
Dockerfile
Normal file
26
Dockerfile
Normal file
@@ -0,0 +1,26 @@
|
||||
# Recipe used to build DEB package
|
||||
|
||||
FROM acidweb/kcc-base
|
||||
MAINTAINER Paweł Jastrzębski <pawelj@iosphe.re>
|
||||
|
||||
ENV KCCVER 4.6.5
|
||||
ADD . /app
|
||||
|
||||
RUN pip3 install pillow python-slugify psutil scandir https://github.com/pyinstaller/pyinstaller/archive/develop.zip
|
||||
RUN gem install fpm
|
||||
RUN useradd -ms /bin/bash kcc && chown -R kcc:kcc /app
|
||||
|
||||
USER kcc
|
||||
WORKDIR /app
|
||||
RUN pyinstaller -F -s kcc.py
|
||||
RUN mkdir -p dist/usr/bin dist/usr/share/applications dist/usr/share/doc/kindlecomicconverter dist/usr/share/kindlecomicconverter dist/usr/share/lintian/overrides
|
||||
RUN mv dist/kcc dist/usr/bin
|
||||
RUN cp icons/comic2ebook.png dist/usr/share/kindlecomicconverter
|
||||
RUN cp LICENSE.txt dist/usr/share/doc/kindlecomicconverter/copyright
|
||||
RUN cp other/kindlecomicconverter.desktop dist/usr/share/applications
|
||||
RUN cp other/kindlecomicconverter dist/usr/share/lintian/overrides
|
||||
|
||||
WORKDIR /app/dist
|
||||
RUN fpm -f -s dir -t deb -n kindlecomicconverter -v $KCCVER -m "Paweł Jastrzębski <pawelj@iosphe.re>" --license "ISC" --description "Comic and Manga converter for e-book readers.\nThis app allows you to transform your PNG, JPG, GIF, CBZ, CBR and CB7 files\ninto EPUB or MOBI format e-books." --url "https://kcc.iosphe.re/" --deb-priority "optional" --vendor "" --category "graphics" -d "unrar | unrar-free" -d "p7zip-full" usr
|
||||
|
||||
CMD mkdir -p /out/dist && cp kindlecomicconverter_${KCCVER}_amd64.deb /out/dist
|
||||
12
README.md
12
README.md
@@ -32,16 +32,16 @@ You can find the latest released binary at the following links:
|
||||
## DEPENDENCIES
|
||||
Following software is required to run Linux version of **KCC** and/or bare sources:
|
||||
- Python 3.3+
|
||||
- [PyQt](http://www.riverbankcomputing.co.uk/software/pyqt/download5) 5.2.1+
|
||||
- [Pillow](http://pypi.python.org/pypi/Pillow/) 2.8.2+
|
||||
- [psutil](https://pypi.python.org/pypi/psutil) 3.0.0+
|
||||
- [python-slugify](http://pypi.python.org/pypi/python-slugify) 1.1.3+
|
||||
- [scandir](https://pypi.python.org/pypi/scandir) 1.1.0+
|
||||
- [PyQt](http://www.riverbankcomputing.co.uk/software/pyqt/download5) 5.2.1+ _(5.5+ is recommended)_
|
||||
- [Pillow](http://pypi.python.org/pypi/Pillow/) 3.0.0+
|
||||
- [psutil](https://pypi.python.org/pypi/psutil) 3.2.1+
|
||||
- [python-slugify](http://pypi.python.org/pypi/python-slugify) 1.1.4+
|
||||
- [scandir](https://pypi.python.org/pypi/scandir) 1.1.0+ _(needed only when using Python 3.3 or 3.4)_
|
||||
|
||||
On Debian based distributions these two commands should install all needed dependencies:
|
||||
```
|
||||
sudo apt-get install python3 python3-dev python3-pip python3-pyqt5 libpng-dev libjpeg-dev p7zip-full unrar
|
||||
sudo pip3 install pillow python-slugify psutil scandir
|
||||
sudo pip3 install --upgrade pillow python-slugify psutil scandir
|
||||
```
|
||||
|
||||
### Optional dependencies
|
||||
|
||||
19
kcc.iss
19
kcc.iss
@@ -13,6 +13,7 @@ AppPublisherURL={#MyAppURL}
|
||||
AppSupportURL={#MyAppURL}
|
||||
AppUpdatesURL={#MyAppURL}
|
||||
AppCopyright=Copyright (C) 2012-2015 Ciro Mattia Gonano and Paweł Jastrzębski
|
||||
ArchitecturesAllowed=x64
|
||||
DefaultDirName={pf}\{#MyAppName}
|
||||
DefaultGroupName={#MyAppName}
|
||||
AllowNoIcons=yes
|
||||
@@ -20,7 +21,6 @@ LicenseFile=LICENSE.txt
|
||||
OutputBaseFilename=KindleComicConverter_win_{#MyAppVersion}
|
||||
SetupIconFile=icons\comic2ebook.ico
|
||||
SolidCompression=yes
|
||||
ArchitecturesInstallIn64BitMode=x64
|
||||
ShowLanguageDialog=no
|
||||
LanguageDetectionMethod=none
|
||||
WizardImageFile=icons\Wizard.bmp
|
||||
@@ -31,6 +31,7 @@ ChangesAssociations=True
|
||||
InfoAfterFile=other\windows\InstallWarning.rtf
|
||||
SignTool=SignTool /d $q{#MyAppName}$q /du $q{#MyAppURL}$q $f
|
||||
MinVersion=0,6.0
|
||||
OutputDir=dist
|
||||
|
||||
[Languages]
|
||||
Name: "english"; MessagesFile: "compiler:Default.isl"
|
||||
@@ -42,21 +43,12 @@ Name: "CBRassociation"; Description: "CBR"; GroupDescription: "File associations
|
||||
Name: "CB7association"; Description: "CB7"; GroupDescription: "File associations:"
|
||||
|
||||
[Files]
|
||||
; x64 files
|
||||
Source: "dist_64\platforms\*"; DestDir: "{app}\platforms\"; Flags: ignoreversion; Check: Is64BitInstallMode
|
||||
Source: "dist_64\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion; Check: Is64BitInstallMode
|
||||
Source: "dist_64\*.dll"; DestDir: "{app}"; Flags: ignoreversion; Check: Is64BitInstallMode
|
||||
Source: "other\windows\vcredist_x64.exe"; DestDir: "{tmp}"; Flags: ignoreversion deleteafterinstall; Check: Is64BitInstallMode
|
||||
; x86 files
|
||||
Source: "dist\platforms\*"; DestDir: "{app}\platforms\"; Flags: ignoreversion; Check: not Is64BitInstallMode
|
||||
Source: "dist\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion; Check: not Is64BitInstallMode
|
||||
Source: "dist\*.dll"; DestDir: "{app}"; Flags: ignoreversion; Check: not Is64BitInstallMode
|
||||
Source: "other\windows\vcredist_x86.exe"; DestDir: "{tmp}"; Flags: ignoreversion deleteafterinstall; Check: not Is64BitInstallMode
|
||||
; Common files
|
||||
Source: "dist\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "LICENSE.txt"; DestDir: "{app}"; Flags: ignoreversion solidbreak
|
||||
Source: "other\windows\Additional-LICENSE.txt"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "other\windows\UnRAR.exe"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "other\windows\7za.exe"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "other\windows\vc_redist.x64.exe"; DestDir: "{tmp}"; Flags: ignoreversion deleteafterinstall
|
||||
|
||||
[Icons]
|
||||
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
|
||||
@@ -64,9 +56,8 @@ Name: "{group}\Readme"; Filename: "https://github.com/ciromattia/kcc#kcc"
|
||||
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
|
||||
|
||||
[Run]
|
||||
Filename: "{tmp}\vc_redist.x64.exe"; Parameters: "/quiet"; StatusMsg: "Installing Microsoft Visual C++ 2015 Redistributable Package..."
|
||||
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall
|
||||
Filename: "{tmp}\vcredist_x64.exe"; Parameters: "/passive /Q:a /c:""msiexec /qb /i vcredist.msi"" "; StatusMsg: "Installing Microsoft Visual C++ 2010 Redistributable Package..."; Check: Is64BitInstallMode
|
||||
Filename: "{tmp}\vcredist_x86.exe"; Parameters: "/passive /Q:a /c:""msiexec /qb /i vcredist.msi"" "; StatusMsg: "Installing Microsoft Visual C++ 2010 Redistributable Package..."; Check: not Is64BitInstallMode
|
||||
|
||||
[Messages]
|
||||
WelcomeLabel1=Welcome to the KCC Setup Wizard
|
||||
|
||||
20
kcc.py
20
kcc.py
@@ -26,24 +26,16 @@ if sys.version_info[0] != 3:
|
||||
# OS specific PATH variable workarounds
|
||||
import os
|
||||
if sys.platform.startswith('darwin'):
|
||||
if 'RESOURCEPATH' not in os.environ:
|
||||
os.environ['PATH'] = os.path.dirname(os.path.abspath(__file__)) + '/other/osx/:' + os.environ['PATH']
|
||||
else:
|
||||
os.environ['PATH'] = './../Resources:/usr/local/bin:/usr/bin:/bin'
|
||||
if getattr(sys, 'frozen', False):
|
||||
os.environ['PATH'] = os.path.dirname(os.path.abspath(sys.executable)) + \
|
||||
'/../Resources:/usr/local/bin:/usr/bin:/bin'
|
||||
os.system('defaults write com.kindlecomicconverter.KindleComicConverter ApplePersistenceIgnoreState YES')
|
||||
os.system('defaults write com.kindlecomicconverter.KindleComicConverter NSInitialToolTipDelay -int 1000')
|
||||
else:
|
||||
os.environ['PATH'] = os.path.dirname(os.path.abspath(__file__)) + '/other/osx/:' + os.environ['PATH']
|
||||
elif sys.platform.startswith('win'):
|
||||
if getattr(sys, 'frozen', False):
|
||||
os.chdir(os.path.dirname(os.path.abspath(sys.executable)))
|
||||
|
||||
# Implementing dummy stdout and stderr for frozen Windows release
|
||||
class FakeSTD(object):
|
||||
def write(self, string):
|
||||
pass
|
||||
|
||||
def flush(self):
|
||||
pass
|
||||
sys.stdout = FakeSTD()
|
||||
sys.stderr = FakeSTD()
|
||||
else:
|
||||
os.environ['PATH'] = os.path.dirname(os.path.abspath(__file__)) + '/other/windows/;' + os.environ['PATH']
|
||||
os.chdir(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
@@ -153,22 +153,22 @@ def dependencyCheck(level):
|
||||
if level > 1:
|
||||
try:
|
||||
from psutil import __version__ as psutilVersion
|
||||
if StrictVersion('3.0.0') > StrictVersion(psutilVersion):
|
||||
missing.append('psutil 3.0.0+')
|
||||
if StrictVersion('3.2.1') > StrictVersion(psutilVersion):
|
||||
missing.append('psutil 3.2.1+')
|
||||
except ImportError:
|
||||
missing.append('psutil 3.0.0+')
|
||||
missing.append('psutil 3.2.1+')
|
||||
try:
|
||||
from slugify import __version__ as slugifyVersion
|
||||
if StrictVersion('1.1.3') > StrictVersion(slugifyVersion):
|
||||
missing.append('python-slugify 1.1.3+')
|
||||
if StrictVersion('1.1.4') > StrictVersion(slugifyVersion):
|
||||
missing.append('python-slugify 1.1.4+')
|
||||
except ImportError:
|
||||
missing.append('python-slugify 1.1.3+')
|
||||
missing.append('python-slugify 1.1.4+')
|
||||
try:
|
||||
from PIL import PILLOW_VERSION as pillowVersion
|
||||
if StrictVersion('2.8.2') > StrictVersion(pillowVersion):
|
||||
missing.append('Pillow 2.8.2+')
|
||||
if StrictVersion('3.0.0') > StrictVersion(pillowVersion):
|
||||
missing.append('Pillow 3.0.0+')
|
||||
except ImportError:
|
||||
missing.append('Pillow 2.8.2+')
|
||||
missing.append('Pillow 3.0.0+')
|
||||
if version_info[1] < 5:
|
||||
try:
|
||||
from scandir import __version__ as scandirVersion
|
||||
|
||||
4
other/linux/kindlecomicconverter
Normal file
4
other/linux/kindlecomicconverter
Normal file
@@ -0,0 +1,4 @@
|
||||
kindlecomicconverter: statically-linked-binary usr/bin/kcc
|
||||
kindlecomicconverter: binary-without-manpage usr/bin/kcc
|
||||
kindlecomicconverter: wrong-name-for-changelog-of-native-package usr/share/doc/kindlecomicconverter/changelog.Debian.gz
|
||||
kindlecomicconverter: file-missing-in-md5sums usr/share/doc/kindlecomicconverter/changelog.Debian.gz
|
||||
11
other/linux/kindlecomicconverter.desktop
Normal file
11
other/linux/kindlecomicconverter.desktop
Normal file
@@ -0,0 +1,11 @@
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Version=1.0
|
||||
Name=Kindle Comic Converter
|
||||
GenericName=Kindle Comic Converter
|
||||
Comment=Comic and Manga converter for e-book readers
|
||||
Icon=/usr/share/kindlecomicconverter/comic2ebook.png
|
||||
Exec=/usr/bin/kcc
|
||||
Terminal=false
|
||||
Categories=Graphics;
|
||||
MimeType=application/zip;application/x-rar;application/x-7z-compressed;
|
||||
68
other/osx/Info.plist
Normal file
68
other/osx/Info.plist
Normal file
@@ -0,0 +1,68 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>Kindle Comic Converter</string>
|
||||
<key>CFBundleDocumentTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CFBundleTypeExtensions</key>
|
||||
<array>
|
||||
<string>cbz</string>
|
||||
<string>cbr</string>
|
||||
<string>cb7</string>
|
||||
<string>zip</string>
|
||||
<string>rar</string>
|
||||
<string>7z</string>
|
||||
<string>pdf</string>
|
||||
</array>
|
||||
<key>CFBundleTypeIconFile</key>
|
||||
<string>comic2ebook.icns</string>
|
||||
<key>CFBundleTypeName</key>
|
||||
<string>Comics</string>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Editor</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>MacOS/Kindle Comic Converter</string>
|
||||
<key>CFBundleGetInfoString</key>
|
||||
<string>KindleComicConverter 4.6.5, written 2012-2015 by Ciro Mattia Gonano and Pawel Jastrzebski</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>comic2ebook.icns</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.kindlecomicconverter.KindleComicConverter</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>Kindle Comic Converter</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>4.6.5</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>4.6.5</string>
|
||||
<key>LSEnvironment</key>
|
||||
<dict>
|
||||
<key>PATH</key>
|
||||
<string>./../Resources:/usr/local/bin:/usr/bin:/bin</string>
|
||||
</dict>
|
||||
<key>LSHasLocalizedDisplayName</key>
|
||||
<false/>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>10.8.0</string>
|
||||
<key>NSAppleScriptEnabled</key>
|
||||
<false/>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>ISC License (ISCL)</string>
|
||||
<key>NSMainNibFile</key>
|
||||
<string>MainMenu</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>NSApplication</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,3 +0,0 @@
|
||||
; Qt Configuration file
|
||||
[Paths]
|
||||
Plugins = PlugIns
|
||||
242
setup.py
242
setup.py
@@ -1,168 +1,136 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
pip/py2exe/py2app build script for KCC.
|
||||
pip/pyinstaller build script for KCC.
|
||||
|
||||
Usage (Windows):
|
||||
py -3.4 setup.py py2exe
|
||||
py -3 setup.py build_binary
|
||||
|
||||
Usage (Linux):
|
||||
python3 setup.py make_pyz or python3 setup.py install
|
||||
|
||||
Usage (Mac OS X):
|
||||
python3 setup.py py2app
|
||||
Usage (Linux/OS X):
|
||||
python3 setup.py build_binary or python3 setup.py build_binary --pyz
|
||||
"""
|
||||
|
||||
from sys import platform, version_info, argv
|
||||
import os
|
||||
import sys
|
||||
import shutil
|
||||
import setuptools
|
||||
import distutils.cmd
|
||||
from distutils.command.build import build
|
||||
from kcc import __version__
|
||||
|
||||
|
||||
NAME = 'KindleComicConverter'
|
||||
VERSION = __version__
|
||||
MAIN = 'kcc.py'
|
||||
extra_options = {}
|
||||
VERSION = __version__
|
||||
OPTIONS = {}
|
||||
|
||||
|
||||
if platform == 'darwin':
|
||||
from setuptools import setup
|
||||
from os import chmod, makedirs, system
|
||||
from shutil import copyfile
|
||||
extra_options = dict(
|
||||
setup_requires=['py2app'],
|
||||
app=[MAIN],
|
||||
options=dict(
|
||||
py2app=dict(
|
||||
argv_emulation=True,
|
||||
iconfile='icons/comic2ebook.icns',
|
||||
includes=['sip', 'PyQt5.QtPrintSupport'],
|
||||
resources=['LICENSE.txt',
|
||||
'other/osx/qt.conf',
|
||||
'other/osx/Additional-LICENSE.txt',
|
||||
'other/osx/unrar',
|
||||
'other/osx/7za'],
|
||||
plist=dict(
|
||||
CFBundleName='Kindle Comic Converter',
|
||||
CFBundleShortVersionString=VERSION,
|
||||
CFBundleGetInfoString=NAME + ' ' + VERSION +
|
||||
', written 2012-2015 by Ciro Mattia Gonano and Pawel Jastrzebski',
|
||||
CFBundleExecutable=NAME,
|
||||
CFBundleDocumentTypes=[
|
||||
dict(
|
||||
CFBundleTypeExtensions=['cbz', 'cbr', 'cb7', 'zip', 'rar', '7z', 'pdf'],
|
||||
CFBundleTypeName='Comics',
|
||||
CFBundleTypeIconFile='comic2ebook.icns',
|
||||
CFBundleTypeRole='Editor',
|
||||
)
|
||||
],
|
||||
CFBundleIdentifier='com.kindlecomicconverter.KindleComicConverter',
|
||||
LSMinimumSystemVersion='10.8.0',
|
||||
LSEnvironment=dict(
|
||||
PATH='./../Resources:/usr/local/bin:/usr/bin:/bin'
|
||||
),
|
||||
NSHumanReadableCopyright='ISC License (ISCL)'
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
elif platform == 'win32':
|
||||
import py2exe
|
||||
from platform import architecture
|
||||
from distutils.core import setup
|
||||
if architecture()[0] == '64bit':
|
||||
suffix = '_64'
|
||||
else:
|
||||
suffix = ''
|
||||
additional_files = [('platforms', ['C:\Python34' + suffix +
|
||||
'\Lib\site-packages\PyQt5\plugins\platforms\qwindows.dll']),
|
||||
('', ['LICENSE.txt',
|
||||
'other\\windows\\7za.exe',
|
||||
'other\\windows\\UnRAR.exe',
|
||||
'other\\windows\\Additional-LICENSE.txt',
|
||||
'C:\Python34' + suffix + '\Lib\site-packages\PyQt5\libGLESv2.dll',
|
||||
'C:\Python34' + suffix + '\Lib\site-packages\PyQt5\libEGL.dll'])]
|
||||
extra_options = dict(
|
||||
options={'py2exe': {'bundle_files': 1,
|
||||
'dist_dir': 'dist' + suffix,
|
||||
'compressed': True,
|
||||
'includes': ['sip'],
|
||||
'excludes': ['tkinter'],
|
||||
'optimize': 2}},
|
||||
windows=[{'script': MAIN,
|
||||
'dest_base': 'KCC',
|
||||
'version': VERSION,
|
||||
'copyright': 'Ciro Mattia Gonano, Pawel Jastrzebski © 2012-2015',
|
||||
'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:
|
||||
if len(argv) > 1 and argv[1] == 'make_pyz':
|
||||
from os import system
|
||||
script = '''
|
||||
cp kcc.py __main__.py
|
||||
zip kcc.zip __main__.py kcc/*.py
|
||||
echo "#!/usr/bin/env python3" > kcc-bin
|
||||
cat kcc.zip >> kcc-bin
|
||||
chmod +x kcc-bin
|
||||
class BuildBinaryCommand(distutils.cmd.Command):
|
||||
description = 'build binary release'
|
||||
user_options = [
|
||||
('pyz', None, 'build PYZ package'),
|
||||
]
|
||||
|
||||
cp kcc-c2e.py __main__.py
|
||||
zip kcc-c2e.zip __main__.py kcc/*.py
|
||||
echo "#!/usr/bin/env python3" > kcc-c2e-bin
|
||||
cat kcc-c2e.zip >> kcc-c2e-bin
|
||||
chmod +x kcc-c2e-bin
|
||||
def initialize_options(self):
|
||||
# noinspection PyAttributeOutsideInit
|
||||
self.pyz = False
|
||||
|
||||
cp kcc-c2p.py __main__.py
|
||||
zip kcc-c2p.zip __main__.py kcc/*.py
|
||||
echo "#!/usr/bin/env python3" > kcc-c2p-bin
|
||||
cat kcc-c2p.zip >> kcc-c2p-bin
|
||||
chmod +x kcc-c2p-bin
|
||||
def finalize_options(self):
|
||||
pass
|
||||
|
||||
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 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
|
||||
'''
|
||||
system("bash -c '%s'" % script)
|
||||
exit(0)
|
||||
else:
|
||||
from setuptools import setup
|
||||
from os import makedirs
|
||||
from shutil import copyfile
|
||||
makedirs('build/_scripts/', exist_ok=True)
|
||||
copyfile('kcc.py', 'build/_scripts/kcc')
|
||||
copyfile('kcc-c2e.py', 'build/_scripts/kcc-c2e')
|
||||
copyfile('kcc-c2p.py', 'build/_scripts/kcc-c2p')
|
||||
extra_options = dict(
|
||||
scripts=['build/_scripts/kcc', 'build/_scripts/kcc-c2e', 'build/_scripts/kcc-c2p'],
|
||||
def run(self):
|
||||
if sys.platform == 'darwin':
|
||||
os.system('pyinstaller -y -F -i icons/comic2ebook.icns -n "Kindle Comic Converter" -w -s kcc.py')
|
||||
shutil.copy('other/osx/7za', 'dist/Kindle Comic Converter.app/Contents/Resources')
|
||||
shutil.copy('other/osx/unrar', 'dist/Kindle Comic Converter.app/Contents/Resources')
|
||||
shutil.copy('other/osx/Info.plist', 'dist/Kindle Comic Converter.app/Contents')
|
||||
shutil.copy('LICENSE.txt', 'dist/Kindle Comic Converter.app/Contents/Resources')
|
||||
shutil.copy('other/windows/Additional-LICENSE.txt', 'dist/Kindle Comic Converter.app/Contents/Resources')
|
||||
os.chmod('dist/Kindle Comic Converter.app/Contents/Resources/unrar', 0o777)
|
||||
os.chmod('dist/Kindle Comic Converter.app/Contents/Resources/7za', 0o777)
|
||||
if os.path.isfile('setup.sh'):
|
||||
os.system('setup.sh')
|
||||
os.system('appdmg kcc.json dist/KindleComicConverter_osx_' + VERSION + '.dmg')
|
||||
exit(0)
|
||||
elif sys.platform == 'win32':
|
||||
os.system('pyinstaller -y -F -i icons\comic2ebook.ico -n KCC -w kcc.py')
|
||||
if os.path.isfile('setup.bat'):
|
||||
os.system('setup.bat ' + VERSION)
|
||||
exit(0)
|
||||
else:
|
||||
if self.pyz:
|
||||
script = '''
|
||||
cp kcc.py __main__.py
|
||||
zip kcc.zip __main__.py kcc/*.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 kcc/*.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 kcc/*.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 build --no-cache -t kcc . && docker run --rm -v ' + os.getcwd() +
|
||||
':/out kcc && docker rmi kcc')
|
||||
exit(0)
|
||||
|
||||
|
||||
class BuildCommand(build):
|
||||
def run(self):
|
||||
os.makedirs('build/_scripts/', exist_ok=True)
|
||||
shutil.copyfile('kcc.py', 'build/_scripts/kcc')
|
||||
shutil.copyfile('kcc-c2e.py', 'build/_scripts/kcc-c2e')
|
||||
shutil.copyfile('kcc-c2p.py', 'build/_scripts/kcc-c2p')
|
||||
# noinspection PyShadowingNames
|
||||
OPTIONS = dict(
|
||||
scripts=['build/_scripts/kcc',
|
||||
'build/_scripts/kcc-c2e',
|
||||
'build/_scripts/kcc-c2p'],
|
||||
packages=['kcc'],
|
||||
install_requires=[
|
||||
'Pillow>=2.8.2',
|
||||
'psutil>=3.0.0',
|
||||
'python-slugify>=1.1.3',
|
||||
'Pillow>=3.0.0',
|
||||
'psutil>=3.2.1',
|
||||
'python-slugify>=1.1.4',
|
||||
],
|
||||
zip_safe=False,
|
||||
)
|
||||
if version_info[1] < 5:
|
||||
extra_options['install_requires'].append('scandir>=1.1.0')
|
||||
if sys.version_info[1] < 5:
|
||||
OPTIONS['install_requires'].append('scandir>=1.1.0')
|
||||
build.run(self)
|
||||
|
||||
|
||||
setup(
|
||||
setuptools.setup(
|
||||
cmdclass={
|
||||
'build_binary': BuildBinaryCommand,
|
||||
'build': BuildCommand,
|
||||
},
|
||||
name=NAME,
|
||||
version=VERSION,
|
||||
author='Ciro Mattia Gonano, Pawel Jastrzebski',
|
||||
author_email='ciromattia@gmail.com, pawelj@iosphe.re',
|
||||
description='Comic and manga converter for E-Book readers.',
|
||||
description='Comic and Manga converter for e-book readers.',
|
||||
license='ISC License (ISCL)',
|
||||
keywords='kindle comic mobipocket mobi cbz cbr manga',
|
||||
url='http://github.com/ciromattia/kcc',
|
||||
**extra_options
|
||||
**OPTIONS
|
||||
)
|
||||
|
||||
if platform == 'darwin':
|
||||
makedirs('dist/Kindle Comic Converter.app/Contents/PlugIns/platforms', exist_ok=True)
|
||||
copyfile('other/osx/libqcocoa.dylib', 'dist/Kindle Comic Converter.app/Contents/PlugIns/platforms/libqcocoa.dylib')
|
||||
chmod('dist/Kindle Comic Converter.app/Contents/Resources/unrar', 0o777)
|
||||
chmod('dist/Kindle Comic Converter.app/Contents/Resources/7za', 0o777)
|
||||
system('appdmg setup.json dist/KindleComicConverter_osx_' + VERSION + '.dmg')
|
||||
|
||||
Reference in New Issue
Block a user