From d91aaaf1de9c4be986fdbd407ffe501edecf2cce Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 15 May 2008 00:23:01 -0700 Subject: [PATCH] IGN: Setup loading of pictureflow plugin in linux --- .bzrignore | 2 +- Makefile | 6 ++--- setup.py | 26 ++++++++++++++----- src/calibre/__init__.py | 17 ++++++++++++ .../gui2/pictureflow/PyQt/configure.py | 1 + src/calibre/manual/faq.rst | 1 + 6 files changed, 42 insertions(+), 11 deletions(-) diff --git a/.bzrignore b/.bzrignore index 4820e06463..444b169850 100644 --- a/.bzrignore +++ b/.bzrignore @@ -1,6 +1,6 @@ *_ui.py moc_*.cpp -plugins +src/calibre/plugins src/calibre/gui2/pictureflow/.build/ src/calibre/gui2/pictureflow/PyQt/.build/ src/calibre/gui2/pictureflow/Makefile diff --git a/Makefile b/Makefile index f3aab1c9f6..76141fa079 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,7 @@ manual: make -C src/calibre/manual clean html pictureflow : - mkdir -p plugins && rm -f plugins/*pictureflow* && \ + mkdir -p src/calibre/plugins && rm -f src/calibre/plugins/*pictureflow* && \ cd src/calibre/gui2/pictureflow && \ mkdir -p .build && cd .build && rm -f * && \ qmake ../pictureflow-lib.pro && make && \ @@ -30,7 +30,7 @@ pictureflow : cd .build && rm -f * && \ python ../configure.py && make && \ cd ../../../../../.. && \ - cp src/calibre/gui2/pictureflow/.build/libpictureflow.so.?.?.? src/calibre/gui2/pictureflow/PyQt/.build/pictureflow.so plugins/ && \ - python -c "import os, glob; lp = glob.glob('plugins/libpictureflow.so.*')[0]; os.rename(lp, lp[:-4])" + cp src/calibre/gui2/pictureflow/.build/libpictureflow.so.?.?.? src/calibre/gui2/pictureflow/PyQt/.build/pictureflow.so src/calibre/plugins/ && \ + python -c "import os, glob; lp = glob.glob('src/calibre/plugins/libpictureflow.so.*')[0]; os.rename(lp, lp[:-4])" diff --git a/setup.py b/setup.py index d605555e0d..b90150eb36 100644 --- a/setup.py +++ b/setup.py @@ -48,11 +48,21 @@ main_functions = { if __name__ == '__main__': from setuptools import setup, find_packages - import subprocess + import subprocess, glob + + from setuptools.command.egg_info import egg_info + + class CalibreEggInfo(egg_info): + + def run(self): + files = glob.glob('plugins/*') + egg_info.run(self) + entry_points['console_scripts'].append('calibre_postinstall = calibre.linux:post_install') setup( + cmdclass = { 'egg_info' : CalibreEggInfo, }, name=APPNAME, packages = find_packages('src'), package_dir = { '' : 'src' }, @@ -61,14 +71,16 @@ if __name__ == '__main__': author_email='kovid@kovidgoyal.net', url = 'http://%s.kovidgoyal.net'%APPNAME, include_package_data = True, + package_data = {'': ['*.so.*', '*.so']}, entry_points = entry_points, - zip_safe = True, + zip_safe = False, + options = { 'bdist_egg' : {'exclude_source_files': True,}, }, description = - """ - Ebook management application. - """, + ''' + E-book management application. + ''', long_description = - """ + ''' %s is an e-book library manager. It can view, convert and catalog e-books in most of the major e-book formats. It can also talk to a few e-book reader devices. It can go out to the internet and fetch metadata for your books. It can download newspapers and convert them into e-books for convenient reading. It is cross platform, running on Linux, Windows and OS X. For screenshots: https://%s.kovidgoyal.net/wiki/Screenshots @@ -82,7 +94,7 @@ if __name__ == '__main__': To update your copy of the source code: bzr merge - """%(APPNAME, APPNAME, APPNAME, APPNAME, APPNAME), + '''%(APPNAME, APPNAME, APPNAME, APPNAME, APPNAME), license = 'GPL', classifiers = [ 'Development Status :: 4 - Beta', diff --git a/src/calibre/__init__.py b/src/calibre/__init__.py index f5fe3862b9..a63e0a1904 100644 --- a/src/calibre/__init__.py +++ b/src/calibre/__init__.py @@ -540,3 +540,20 @@ def strftime(fmt, t=time.localtime()): return unicode(result, locale.getpreferredencoding(), 'replace') except: return unicode(result, 'utf-8', 'replace') + +if islinux: + import pkg_resources + if not os.environ.has_key('LD_LIBRARY_PATH'): + os.environ['LD_LIBRARY_PATH'] = '' + plugins = pkg_resources.resource_filename(__appname__, 'plugins') + os.environ['LD_LIBRARY_PATH'] = plugins + ':' + os.environ['LD_LIBRARY_PATH'] + sys.path.insert(1, plugins) + cwd = os.getcwd() + os.chdir(plugins) + try: + import pictureflow + except: + import traceback + traceback.print_exc() + pictureflow = None + os.chdir(cwd) diff --git a/src/calibre/gui2/pictureflow/PyQt/configure.py b/src/calibre/gui2/pictureflow/PyQt/configure.py index 8c2c34aaa6..22424b724f 100644 --- a/src/calibre/gui2/pictureflow/PyQt/configure.py +++ b/src/calibre/gui2/pictureflow/PyQt/configure.py @@ -32,6 +32,7 @@ makefile = pyqtconfig.QtGuiModuleMakefile ( # ".dll" extension on Windows). makefile.extra_lib_dirs = ['../../.build'] makefile.extra_libs = ["pictureflow"] +makefile.extra_lflags = ['-Wl,--rpath=.'] # Generate the Makefile itself. makefile.generate() diff --git a/src/calibre/manual/faq.rst b/src/calibre/manual/faq.rst index ea90a8a1bd..1eb3e82944 100644 --- a/src/calibre/manual/faq.rst +++ b/src/calibre/manual/faq.rst @@ -123,6 +123,7 @@ Take your pick: * Convertor And LIBRary for E-books * A high *calibre* product * A tribute to the SONY Librie which was the first e-ink based e-book reader + * My wife chose it ;-) Why does |app| show only some of my fonts on OS X? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~