about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPaweł Jastrzębski <pawelj@vulturis.eu>2014-01-22 16:47:55 +0100
committerPaweł Jastrzębski <pawelj@vulturis.eu>2014-01-22 16:47:55 +0100
commitaa96381eb5839590bf5d3856b4fcb42552858a73 (patch)
treead2aa8e7ad46f5427b66b19623723958b1ac1759
parentLinux/OSX: Drag&Drop fix (diff)
downloadkcc-aa96381eb5839590bf5d3856b4fcb42552858a73.tar.gz
kcc-aa96381eb5839590bf5d3856b4fcb42552858a73.tar.bz2
kcc-aa96381eb5839590bf5d3856b4fcb42552858a73.zip
Added experimental Linux setup
-rw-r--r--README.md10
-rw-r--r--kcc.iss2
-rw-r--r--other/LinuxInit.py14
-rwxr-xr-xsetup.py54
-rwxr-xr-xsetup.sh25
5 files changed, 65 insertions, 40 deletions
diff --git a/README.md b/README.md
index 6e2c121..6f58a76 100644
--- a/README.md
+++ b/README.md
@@ -24,7 +24,7 @@ If you find **KCC** valuable you can consider donating to the authors:
 You can find the latest released binary at the following links:
 - **Windows:** [http://kcc.vulturis.eu/Windows/](http://kcc.vulturis.eu/Windows/)
 - **Linux:** [http://kcc.vulturis.eu/Linux/](http://kcc.vulturis.eu/Linux/)
-- **OS X 10.8+:** [http://kcc.vulturis.eu/OSX/](http://kcc.vulturis.eu/OSX/)
+- **OS X (10.8+):** [http://kcc.vulturis.eu/OSX/](http://kcc.vulturis.eu/OSX/)
 
 ## INPUT FORMATS
 **KCC** can understand and convert, at the moment, the following input types:
@@ -46,8 +46,14 @@ You can find the latest released binary at the following links:
 - [psutil](https://pypi.python.org/pypi/psutil)
 - [python-slugify](http://pypi.python.org/pypi/python-slugify)
 
+On Debian based distributions these two commands should install all dependencies:
+```
+sudo apt-get install python3 python3-dev python3-pip python3-pyqt5 libtiff-dev libpng-dev libjpeg-dev p7zip-full unrar
+sudo pip3 install pillow python-slugify psutil
+```
+
 ### For freezing code:
-- Windows - [cx_Freeze](https://bitbucket.org/anthony_tuininga/cx_freeze) version 4.3.2 with [this](https://bitbucket.org/anthony_tuininga/cx_freeze/pull-request/29/conversions-to-support-untranslated-wide) patchset.
+- Windows/Linux - [cx_Freeze](https://bitbucket.org/anthony_tuininga/cx_freeze) version 4.3.2 with [this](https://bitbucket.org/anthony_tuininga/cx_freeze/pull-request/29/conversions-to-support-untranslated-wide) patchset.
 - OS X - [py2app](https://bitbucket.org/ronaldoussoren/py2app) HEAD version.
 
 ## USAGE
diff --git a/kcc.iss b/kcc.iss
index 6dfa659..8aebf13 100644
--- a/kcc.iss
+++ b/kcc.iss
@@ -47,7 +47,6 @@ Source: "build\exe.win-amd64-3.3\platforms\*"; DestDir: "{app}\platforms\"; Flag
 Source: "build\exe.win-amd64-3.3\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion; Check: Is64BitInstallMode
 Source: "build\exe.win-amd64-3.3\*.pyd"; DestDir: "{app}"; Flags: ignoreversion; Check: Is64BitInstallMode
 Source: "build\exe.win-amd64-3.3\*.dll"; DestDir: "{app}"; Flags: ignoreversion; Check: Is64BitInstallMode
-Source: "build\exe.win-amd64-3.3\*.zip"; DestDir: "{app}"; Flags: ignoreversion; Check: Is64BitInstallMode
 Source: "other\vcredist_x64.exe"; DestDir: "{tmp}"; Flags: ignoreversion deleteafterinstall; Check: Is64BitInstallMode
 ; x86 files
 Source: "build\exe.win32-3.3\imageformats\*"; DestDir: "{app}\imageformats\"; Flags: ignoreversion; Check: not Is64BitInstallMode
@@ -55,7 +54,6 @@ Source: "build\exe.win32-3.3\platforms\*"; DestDir: "{app}\platforms\"; Flags: i
 Source: "build\exe.win32-3.3\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion; Check: not Is64BitInstallMode
 Source: "build\exe.win32-3.3\*.pyd"; DestDir: "{app}"; Flags: ignoreversion; Check: not Is64BitInstallMode
 Source: "build\exe.win32-3.3\*.dll"; DestDir: "{app}"; Flags: ignoreversion; Check: not Is64BitInstallMode
-Source: "build\exe.win32-3.3\*.zip"; DestDir: "{app}"; Flags: ignoreversion; Check: not Is64BitInstallMode
 Source: "other\vcredist_x86.exe"; DestDir: "{tmp}"; Flags: ignoreversion deleteafterinstall; Check: not Is64BitInstallMode
 ; Common files
 Source: "LICENSE.txt"; DestDir: "{app}"; Flags: ignoreversion solidbreak
diff --git a/other/LinuxInit.py b/other/LinuxInit.py
new file mode 100644
index 0000000..7fa1150
--- /dev/null
+++ b/other/LinuxInit.py
@@ -0,0 +1,14 @@
+import os
+import sys
+import zipimport
+
+sys.frozen = True
+sys.path = sys.path[:4]
+sys.path.insert(0, '/usr/lib/kcc')
+sys.path.insert(0, '/usr/local/lib/kcc')
+sys.path.insert(0, os.path.join(DIR_NAME, '..', 'lib'))
+
+m = __import__("__main__")
+importer = zipimport.zipimporter(INITSCRIPT_ZIP_FILE_NAME)
+code = importer.get_code(m.__name__)
+exec(code, m.__dict__)
diff --git a/setup.py b/setup.py
index 6e5b5b9..9d73375 100755
--- a/setup.py
+++ b/setup.py
@@ -5,10 +5,13 @@ cx_Freeze build script for KCC.
 Usage (Mac OS X):
     python setup.py py2app
 
-Usage (Windows):
+Usage (Windows/Linux):
     python setup.py build
 """
-from sys import platform
+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"
@@ -60,24 +63,40 @@ elif platform == "win32":
         library = 'libEGL32.dll'
     base = "Win32GUI"
     extra_options = dict(
-        options={"build_exe": {"include_files": ['LICENSE.txt',
+        options={"build_exe": {"optimize": 2,
+                               "include_files": ['LICENSE.txt',
                                                  ['other/UnRAR.exe', 'UnRAR.exe'],
                                                  ['other/7za.exe', '7za.exe'],
                                                  ['other/Additional-LICENSE.txt', 'Additional-LICENSE.txt'],
                                                  ['other/' + library, 'libEGL.dll']
-                                                 ], "compressed": True,
+                                                 ],
+                               "copy_dependent_files": True,
+                               "create_shared_zip": False,
+                               "append_script_to_exe": True,
                                "excludes": ['tkinter']}},
         executables=[Executable(MAIN,
                                 base=base,
                                 targetName="KCC.exe",
                                 icon="icons/comic2ebook.ico",
-                                copyDependentFiles=True,
-                                appendScriptToExe=True,
-                                appendScriptToLibrary=False,
-                                compress=True)])
+                                compress=False)])
 else:
-    print('Please use setup.sh to build Linux package.')
-    exit()
+    import platform as arch
+    import os
+    from cx_Freeze import setup, Executable
+    if arch.architecture()[0] == '64bit':
+        library = 'x86_64'
+    else:
+        library = 'x86'
+    extra_options = dict(
+        options={"build_exe": {"optimize": 2,
+                               "copy_dependent_files": True,
+                               "create_shared_zip": False,
+                               "append_script_to_exe": True,
+                               "init_script": os.path.join(os.getcwd(), 'other', 'LinuxInit.py'),
+                               "excludes": ['tkinter']}},
+        executables=[Executable(MAIN,
+                                base=None,
+                                compress=False)])
 
 #noinspection PyUnboundLocalVariable
 setup(
@@ -99,4 +118,17 @@ if platform == "darwin":
     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)
\ No newline at end of file
+    chmod('dist/' + NAME + '.app/Contents/Resources/7za', 0o777)
+
+if platform == "linux":
+    from os import chmod, makedirs, remove
+    from shutil import copyfile, copytree
+    makedirs('dist/kcc/bin')
+    # noinspection PyUnboundLocalVariable
+    copyfile('build/exe.linux-' + library + '-3.3/kcc', 'dist/kcc/bin/kcc')
+    chmod('dist/kcc/bin/kcc', 0o755)
+    # noinspection PyUnboundLocalVariable
+    copytree('build/exe.linux-' + library + '-3.3', 'dist/kcc/lib')
+    remove('dist/kcc/lib/kcc')
+    copyfile('LICENSE.txt', 'dist/kcc/LICENSE.txt')
+    copyfile('icons/comic2ebook.png', 'dist/kcc/kcc.png')
\ No newline at end of file
diff --git a/setup.sh b/setup.sh
deleted file mode 100755
index ed1f9e5..0000000
--- a/setup.sh
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/bin/bash
-# Linux Python package build script
-
-VERSION="4.0"
-
-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
-
-tar --xform s:^.*/:: --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 icons/comic2ebook.png
-rm __main__.py kcc.zip kcc-c2e.zip kcc-c2p.zip kcc-bin kcc-c2e-bin kcc-c2p-bin