mirror of
https://github.com/ciromattia/kcc
synced 2025-12-12 17:26:23 +00:00
Migrated to PyInstaller
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -10,3 +10,6 @@ Output
|
|||||||
test
|
test
|
||||||
solaio
|
solaio
|
||||||
kindlegen*
|
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
|
## DEPENDENCIES
|
||||||
Following software is required to run Linux version of **KCC** and/or bare sources:
|
Following software is required to run Linux version of **KCC** and/or bare sources:
|
||||||
- Python 3.3+
|
- Python 3.3+
|
||||||
- [PyQt](http://www.riverbankcomputing.co.uk/software/pyqt/download5) 5.2.1+
|
- [PyQt](http://www.riverbankcomputing.co.uk/software/pyqt/download5) 5.2.1+ _(5.5+ is recommended)_
|
||||||
- [Pillow](http://pypi.python.org/pypi/Pillow/) 2.8.2+
|
- [Pillow](http://pypi.python.org/pypi/Pillow/) 3.0.0+
|
||||||
- [psutil](https://pypi.python.org/pypi/psutil) 3.0.0+
|
- [psutil](https://pypi.python.org/pypi/psutil) 3.2.1+
|
||||||
- [python-slugify](http://pypi.python.org/pypi/python-slugify) 1.1.3+
|
- [python-slugify](http://pypi.python.org/pypi/python-slugify) 1.1.4+
|
||||||
- [scandir](https://pypi.python.org/pypi/scandir) 1.1.0+
|
- [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:
|
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 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
|
### Optional dependencies
|
||||||
|
|||||||
19
kcc.iss
19
kcc.iss
@@ -13,6 +13,7 @@ AppPublisherURL={#MyAppURL}
|
|||||||
AppSupportURL={#MyAppURL}
|
AppSupportURL={#MyAppURL}
|
||||||
AppUpdatesURL={#MyAppURL}
|
AppUpdatesURL={#MyAppURL}
|
||||||
AppCopyright=Copyright (C) 2012-2015 Ciro Mattia Gonano and Paweł Jastrzębski
|
AppCopyright=Copyright (C) 2012-2015 Ciro Mattia Gonano and Paweł Jastrzębski
|
||||||
|
ArchitecturesAllowed=x64
|
||||||
DefaultDirName={pf}\{#MyAppName}
|
DefaultDirName={pf}\{#MyAppName}
|
||||||
DefaultGroupName={#MyAppName}
|
DefaultGroupName={#MyAppName}
|
||||||
AllowNoIcons=yes
|
AllowNoIcons=yes
|
||||||
@@ -20,7 +21,6 @@ LicenseFile=LICENSE.txt
|
|||||||
OutputBaseFilename=KindleComicConverter_win_{#MyAppVersion}
|
OutputBaseFilename=KindleComicConverter_win_{#MyAppVersion}
|
||||||
SetupIconFile=icons\comic2ebook.ico
|
SetupIconFile=icons\comic2ebook.ico
|
||||||
SolidCompression=yes
|
SolidCompression=yes
|
||||||
ArchitecturesInstallIn64BitMode=x64
|
|
||||||
ShowLanguageDialog=no
|
ShowLanguageDialog=no
|
||||||
LanguageDetectionMethod=none
|
LanguageDetectionMethod=none
|
||||||
WizardImageFile=icons\Wizard.bmp
|
WizardImageFile=icons\Wizard.bmp
|
||||||
@@ -31,6 +31,7 @@ ChangesAssociations=True
|
|||||||
InfoAfterFile=other\windows\InstallWarning.rtf
|
InfoAfterFile=other\windows\InstallWarning.rtf
|
||||||
SignTool=SignTool /d $q{#MyAppName}$q /du $q{#MyAppURL}$q $f
|
SignTool=SignTool /d $q{#MyAppName}$q /du $q{#MyAppURL}$q $f
|
||||||
MinVersion=0,6.0
|
MinVersion=0,6.0
|
||||||
|
OutputDir=dist
|
||||||
|
|
||||||
[Languages]
|
[Languages]
|
||||||
Name: "english"; MessagesFile: "compiler:Default.isl"
|
Name: "english"; MessagesFile: "compiler:Default.isl"
|
||||||
@@ -42,21 +43,12 @@ Name: "CBRassociation"; Description: "CBR"; GroupDescription: "File associations
|
|||||||
Name: "CB7association"; Description: "CB7"; GroupDescription: "File associations:"
|
Name: "CB7association"; Description: "CB7"; GroupDescription: "File associations:"
|
||||||
|
|
||||||
[Files]
|
[Files]
|
||||||
; x64 files
|
Source: "dist\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
|
||||||
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: "LICENSE.txt"; DestDir: "{app}"; Flags: ignoreversion solidbreak
|
Source: "LICENSE.txt"; DestDir: "{app}"; Flags: ignoreversion solidbreak
|
||||||
Source: "other\windows\Additional-LICENSE.txt"; DestDir: "{app}"; Flags: ignoreversion
|
Source: "other\windows\Additional-LICENSE.txt"; DestDir: "{app}"; Flags: ignoreversion
|
||||||
Source: "other\windows\UnRAR.exe"; 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\7za.exe"; DestDir: "{app}"; Flags: ignoreversion
|
||||||
|
Source: "other\windows\vc_redist.x64.exe"; DestDir: "{tmp}"; Flags: ignoreversion deleteafterinstall
|
||||||
|
|
||||||
[Icons]
|
[Icons]
|
||||||
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
|
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
|
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
|
||||||
|
|
||||||
[Run]
|
[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: "{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]
|
[Messages]
|
||||||
WelcomeLabel1=Welcome to the KCC Setup Wizard
|
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
|
# OS specific PATH variable workarounds
|
||||||
import os
|
import os
|
||||||
if sys.platform.startswith('darwin'):
|
if sys.platform.startswith('darwin'):
|
||||||
if 'RESOURCEPATH' not in os.environ:
|
if getattr(sys, 'frozen', False):
|
||||||
os.environ['PATH'] = os.path.dirname(os.path.abspath(__file__)) + '/other/osx/:' + os.environ['PATH']
|
os.environ['PATH'] = os.path.dirname(os.path.abspath(sys.executable)) + \
|
||||||
else:
|
'/../Resources:/usr/local/bin:/usr/bin:/bin'
|
||||||
os.environ['PATH'] = './../Resources:/usr/local/bin:/usr/bin:/bin'
|
|
||||||
os.system('defaults write com.kindlecomicconverter.KindleComicConverter ApplePersistenceIgnoreState YES')
|
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'):
|
elif sys.platform.startswith('win'):
|
||||||
if getattr(sys, 'frozen', False):
|
if getattr(sys, 'frozen', False):
|
||||||
os.chdir(os.path.dirname(os.path.abspath(sys.executable)))
|
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:
|
else:
|
||||||
os.environ['PATH'] = os.path.dirname(os.path.abspath(__file__)) + '/other/windows/;' + os.environ['PATH']
|
os.environ['PATH'] = os.path.dirname(os.path.abspath(__file__)) + '/other/windows/;' + os.environ['PATH']
|
||||||
os.chdir(os.path.dirname(os.path.abspath(__file__)))
|
os.chdir(os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
|||||||
@@ -153,22 +153,22 @@ def dependencyCheck(level):
|
|||||||
if level > 1:
|
if level > 1:
|
||||||
try:
|
try:
|
||||||
from psutil import __version__ as psutilVersion
|
from psutil import __version__ as psutilVersion
|
||||||
if StrictVersion('3.0.0') > StrictVersion(psutilVersion):
|
if StrictVersion('3.2.1') > StrictVersion(psutilVersion):
|
||||||
missing.append('psutil 3.0.0+')
|
missing.append('psutil 3.2.1+')
|
||||||
except ImportError:
|
except ImportError:
|
||||||
missing.append('psutil 3.0.0+')
|
missing.append('psutil 3.2.1+')
|
||||||
try:
|
try:
|
||||||
from slugify import __version__ as slugifyVersion
|
from slugify import __version__ as slugifyVersion
|
||||||
if StrictVersion('1.1.3') > StrictVersion(slugifyVersion):
|
if StrictVersion('1.1.4') > StrictVersion(slugifyVersion):
|
||||||
missing.append('python-slugify 1.1.3+')
|
missing.append('python-slugify 1.1.4+')
|
||||||
except ImportError:
|
except ImportError:
|
||||||
missing.append('python-slugify 1.1.3+')
|
missing.append('python-slugify 1.1.4+')
|
||||||
try:
|
try:
|
||||||
from PIL import PILLOW_VERSION as pillowVersion
|
from PIL import PILLOW_VERSION as pillowVersion
|
||||||
if StrictVersion('2.8.2') > StrictVersion(pillowVersion):
|
if StrictVersion('3.0.0') > StrictVersion(pillowVersion):
|
||||||
missing.append('Pillow 2.8.2+')
|
missing.append('Pillow 3.0.0+')
|
||||||
except ImportError:
|
except ImportError:
|
||||||
missing.append('Pillow 2.8.2+')
|
missing.append('Pillow 3.0.0+')
|
||||||
if version_info[1] < 5:
|
if version_info[1] < 5:
|
||||||
try:
|
try:
|
||||||
from scandir import __version__ as scandirVersion
|
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
|
#!/usr/bin/env python3
|
||||||
"""
|
"""
|
||||||
pip/py2exe/py2app build script for KCC.
|
pip/pyinstaller build script for KCC.
|
||||||
|
|
||||||
Usage (Windows):
|
Usage (Windows):
|
||||||
py -3.4 setup.py py2exe
|
py -3 setup.py build_binary
|
||||||
|
|
||||||
Usage (Linux):
|
Usage (Linux/OS X):
|
||||||
python3 setup.py make_pyz or python3 setup.py install
|
python3 setup.py build_binary or python3 setup.py build_binary --pyz
|
||||||
|
|
||||||
Usage (Mac OS X):
|
|
||||||
python3 setup.py py2app
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
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__
|
from kcc import __version__
|
||||||
|
|
||||||
|
|
||||||
NAME = 'KindleComicConverter'
|
NAME = 'KindleComicConverter'
|
||||||
VERSION = __version__
|
|
||||||
MAIN = 'kcc.py'
|
MAIN = 'kcc.py'
|
||||||
extra_options = {}
|
VERSION = __version__
|
||||||
|
OPTIONS = {}
|
||||||
|
|
||||||
|
|
||||||
if platform == 'darwin':
|
class BuildBinaryCommand(distutils.cmd.Command):
|
||||||
from setuptools import setup
|
description = 'build binary release'
|
||||||
from os import chmod, makedirs, system
|
user_options = [
|
||||||
from shutil import copyfile
|
('pyz', None, 'build PYZ package'),
|
||||||
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
|
|
||||||
|
|
||||||
cp kcc-c2e.py __main__.py
|
def initialize_options(self):
|
||||||
zip kcc-c2e.zip __main__.py kcc/*.py
|
# noinspection PyAttributeOutsideInit
|
||||||
echo "#!/usr/bin/env python3" > kcc-c2e-bin
|
self.pyz = False
|
||||||
cat kcc-c2e.zip >> kcc-c2e-bin
|
|
||||||
chmod +x kcc-c2e-bin
|
|
||||||
|
|
||||||
cp kcc-c2p.py __main__.py
|
def finalize_options(self):
|
||||||
zip kcc-c2p.zip __main__.py kcc/*.py
|
pass
|
||||||
echo "#!/usr/bin/env python3" > kcc-c2p-bin
|
|
||||||
cat kcc-c2p.zip >> kcc-c2p-bin
|
|
||||||
chmod +x kcc-c2p-bin
|
|
||||||
|
|
||||||
tar --xform s:^.*/:: --xform s/LICENSE.txt/LICENSE/ --xform s/kcc-bin/kcc/ --xform s/kcc-c2p-bin/kcc-c2p/ \
|
def run(self):
|
||||||
--xform s/kcc-c2e-bin/kcc-c2e/ --xform s/comic2ebook/kcc/ -czf KindleComicConverter_linux_'''\
|
if sys.platform == 'darwin':
|
||||||
+ VERSION + '''.tar.gz kcc-bin kcc-c2e-bin kcc-c2p-bin LICENSE.txt README.md icons/comic2ebook.png
|
os.system('pyinstaller -y -F -i icons/comic2ebook.icns -n "Kindle Comic Converter" -w -s kcc.py')
|
||||||
rm __main__.py kcc.zip kcc-c2e.zip kcc-c2p.zip kcc-bin kcc-c2e-bin kcc-c2p-bin
|
shutil.copy('other/osx/7za', 'dist/Kindle Comic Converter.app/Contents/Resources')
|
||||||
'''
|
shutil.copy('other/osx/unrar', 'dist/Kindle Comic Converter.app/Contents/Resources')
|
||||||
system("bash -c '%s'" % script)
|
shutil.copy('other/osx/Info.plist', 'dist/Kindle Comic Converter.app/Contents')
|
||||||
exit(0)
|
shutil.copy('LICENSE.txt', 'dist/Kindle Comic Converter.app/Contents/Resources')
|
||||||
else:
|
shutil.copy('other/windows/Additional-LICENSE.txt', 'dist/Kindle Comic Converter.app/Contents/Resources')
|
||||||
from setuptools import setup
|
os.chmod('dist/Kindle Comic Converter.app/Contents/Resources/unrar', 0o777)
|
||||||
from os import makedirs
|
os.chmod('dist/Kindle Comic Converter.app/Contents/Resources/7za', 0o777)
|
||||||
from shutil import copyfile
|
if os.path.isfile('setup.sh'):
|
||||||
makedirs('build/_scripts/', exist_ok=True)
|
os.system('setup.sh')
|
||||||
copyfile('kcc.py', 'build/_scripts/kcc')
|
os.system('appdmg kcc.json dist/KindleComicConverter_osx_' + VERSION + '.dmg')
|
||||||
copyfile('kcc-c2e.py', 'build/_scripts/kcc-c2e')
|
exit(0)
|
||||||
copyfile('kcc-c2p.py', 'build/_scripts/kcc-c2p')
|
elif sys.platform == 'win32':
|
||||||
extra_options = dict(
|
os.system('pyinstaller -y -F -i icons\comic2ebook.ico -n KCC -w kcc.py')
|
||||||
scripts=['build/_scripts/kcc', 'build/_scripts/kcc-c2e', 'build/_scripts/kcc-c2p'],
|
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'],
|
packages=['kcc'],
|
||||||
install_requires=[
|
install_requires=[
|
||||||
'Pillow>=2.8.2',
|
'Pillow>=3.0.0',
|
||||||
'psutil>=3.0.0',
|
'psutil>=3.2.1',
|
||||||
'python-slugify>=1.1.3',
|
'python-slugify>=1.1.4',
|
||||||
],
|
],
|
||||||
zip_safe=False,
|
zip_safe=False,
|
||||||
)
|
)
|
||||||
if version_info[1] < 5:
|
if sys.version_info[1] < 5:
|
||||||
extra_options['install_requires'].append('scandir>=1.1.0')
|
OPTIONS['install_requires'].append('scandir>=1.1.0')
|
||||||
|
build.run(self)
|
||||||
|
|
||||||
|
|
||||||
setup(
|
setuptools.setup(
|
||||||
|
cmdclass={
|
||||||
|
'build_binary': BuildBinaryCommand,
|
||||||
|
'build': BuildCommand,
|
||||||
|
},
|
||||||
name=NAME,
|
name=NAME,
|
||||||
version=VERSION,
|
version=VERSION,
|
||||||
author='Ciro Mattia Gonano, Pawel Jastrzebski',
|
author='Ciro Mattia Gonano, Pawel Jastrzebski',
|
||||||
author_email='ciromattia@gmail.com, pawelj@iosphe.re',
|
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)',
|
license='ISC License (ISCL)',
|
||||||
keywords='kindle comic mobipocket mobi cbz cbr manga',
|
keywords='kindle comic mobipocket mobi cbz cbr manga',
|
||||||
url='http://github.com/ciromattia/kcc',
|
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