calibre has a new installation layout with all the resources (icons, fonts, etc) in separate files. Also on linux, the install and develop commands have changed, they no longer modify the system pythonpath. See the INSTALL file for details.
25
.bzrignore
@ -1,29 +1,18 @@
|
||||
*_ui.py
|
||||
moc_*.cpp
|
||||
.check-cache.pickle
|
||||
src/calibre/plugins
|
||||
src/calibre/gui2/pictureflow/*.so*
|
||||
src/calibre/gui2/pictureflow/PyQt/.build/
|
||||
src/calibre/gui2/pictureflow/Makefile
|
||||
src/calibre.egg-info/
|
||||
src/calibre/resources.py
|
||||
src/calibre/gui2/images.qrc
|
||||
src/calibre/gui2/images_rc.py
|
||||
resources/images.qrc
|
||||
src/calibre/manual/.build/
|
||||
src/calibre/manual/cli/
|
||||
build
|
||||
dist
|
||||
docs
|
||||
nbproject/
|
||||
src/calibre/gui2/pictureflow/Makefile.Debug
|
||||
src/calibre/gui2/pictureflow/Makefile.Release
|
||||
src/calibre/gui2/pictureflow/debug/
|
||||
src/calibre/gui2/pictureflow/pictureflow_resource.rc
|
||||
src/calibre/gui2/pictureflow/release/
|
||||
src/calibre/translations/compiled.py
|
||||
installer/windows/calibre/build.log
|
||||
resources/localization
|
||||
resources/images.qrc
|
||||
resources/recipes.pickle
|
||||
resources/scripts.pickle
|
||||
setup/installer/windows/calibre/build.log
|
||||
src/calibre/translations/.errors
|
||||
src/calibre/plugins/*
|
||||
src/calibre/gui2/pictureflow/.build
|
||||
src/cssutils/.svn/
|
||||
src/cssutils/_todo/
|
||||
src/cssutils/scripts/
|
||||
|
47
INSTALL
Normal file
@ -0,0 +1,47 @@
|
||||
calibre supports installation from source, only on Linux.
|
||||
On Windows and OS X use the provided installers and use
|
||||
the facilities of the calibre-debug command to hack on the calibre source.
|
||||
|
||||
On Linux, there are two kinds of installation from source possible.
|
||||
Note that both kinds require lots of dependencies as well as a
|
||||
full development environment (compilers, headers files, etc.)
|
||||
|
||||
All installation related functions are accessed by the command::
|
||||
|
||||
python setup.py
|
||||
|
||||
Install
|
||||
==========
|
||||
|
||||
The first type of install will actually "install" calibre to
|
||||
your computer by putting its files into the system in the following locations:
|
||||
|
||||
- Binaries (actually python wrapper scripts) in <prefix>/bin
|
||||
- Python and C modules in <prefix>/lib/calibre
|
||||
- Resources like icons, etc. in <prefix>/share/calibre
|
||||
|
||||
This type of install can be run by the command::
|
||||
|
||||
sudo python setup.py install
|
||||
|
||||
<prefix> is normally the installation prefix of python, usually /usr.
|
||||
It can be controlled by the --prefix option. See
|
||||
|
||||
python setup.py install -h
|
||||
|
||||
for details.
|
||||
|
||||
Develop
|
||||
=============
|
||||
|
||||
This type of install is designed to let you run calibre from your home directory,
|
||||
making it easy to hack on it.
|
||||
It will only install binaries into /usr/bin, but all the actual code and resource
|
||||
files will be read from the calibre source tree in your home directory
|
||||
(or wherever you choose to put it).
|
||||
|
||||
This type of install can be run with the command::
|
||||
|
||||
sudo python setup.py develop
|
||||
|
||||
Use the -h flag for help on the develop command.
|
17
README
Normal file
@ -0,0 +1,17 @@
|
||||
calibre 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 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://calibre.kovidgoyal.net/wiki/Screenshots
|
||||
|
||||
For installation/usage instructions please see
|
||||
http://calibre.kovidgoyal.net
|
||||
|
||||
For source code access:
|
||||
bzr branch lp:calibre
|
||||
|
||||
To update your copy of the source code:
|
||||
bzr merge
|
||||
|
@ -1,253 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
from __future__ import with_statement
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
'''
|
||||
Create linux binary.
|
||||
'''
|
||||
|
||||
def freeze():
|
||||
import glob, sys, tarfile, os, textwrap, shutil, platform
|
||||
from contextlib import closing
|
||||
from cx_Freeze import Executable, setup
|
||||
from calibre.constants import __version__, __appname__
|
||||
from calibre.linux import entry_points
|
||||
from calibre import walk
|
||||
from calibre.web.feeds.recipes import recipe_modules
|
||||
from calibre.ebooks.lrf.fonts import FONT_MAP
|
||||
import calibre
|
||||
|
||||
is64bit = platform.architecture()[0] == '64bit'
|
||||
arch = 'x86_64' if is64bit else 'i686'
|
||||
|
||||
|
||||
QTDIR = '/usr/lib/qt4'
|
||||
QTDLLS = ('QtCore', 'QtGui', 'QtNetwork', 'QtSvg', 'QtXml',
|
||||
'QtWebKit', 'QtDBus')
|
||||
|
||||
binary_excludes = ['libGLcore*', 'libGL*', 'libnvidia*']
|
||||
|
||||
os.system('sudo cp /usr/bin/calibre-mount-helper /tmp/calibre-mount-helper')
|
||||
os.system('sudo chown kovid:users /tmp/calibre-mount-helper')
|
||||
|
||||
binary_includes = [
|
||||
'/usr/bin/pdftohtml',
|
||||
'/tmp/calibre-mount-helper',
|
||||
'/usr/lib/libunrar.so',
|
||||
'/usr/lib/libsqlite3.so.0',
|
||||
'/usr/lib/libsqlite3.so.0',
|
||||
'/usr/lib/libmng.so.1',
|
||||
'/usr/lib/libpodofo.so.0.6.99',
|
||||
'/lib/libz.so.1',
|
||||
'/lib/libbz2.so.1',
|
||||
'/usr/lib/libpoppler.so.4',
|
||||
'/usr/lib/libpoppler-qt4.so.3',
|
||||
'/usr/lib/libxml2.so.2',
|
||||
'/usr/lib/libopenjpeg.so.2',
|
||||
'/usr/lib/libxslt.so.1',
|
||||
'/usr/lib64/libjpeg.so.7'.replace('64', '64' if is64bit
|
||||
else ''),
|
||||
'/usr/lib/libxslt.so.1',
|
||||
'/usr/lib/libgthread-2.0.so.0',
|
||||
'/usr/lib/gcc/***-pc-linux-gnu/4.4.1/libstdc++.so.6'.replace('***',
|
||||
arch),
|
||||
'/usr/lib/libpng12.so.0',
|
||||
'/usr/lib/libexslt.so.0',
|
||||
'/usr/lib/libMagickWand.so',
|
||||
'/usr/lib/libMagickCore.so',
|
||||
'/usr/lib/libgcrypt.so.11',
|
||||
'/usr/lib/libgpg-error.so.0',
|
||||
'/usr/lib/libphonon.so.4',
|
||||
'/usr/lib/libssl.so.0.9.8',
|
||||
'/usr/lib/libcrypto.so.0.9.8',
|
||||
'/lib/libreadline.so.6',
|
||||
]
|
||||
|
||||
binary_includes += [os.path.join(QTDIR, 'lib%s.so.4'%x) for x in QTDLLS]
|
||||
|
||||
|
||||
d = os.path.dirname
|
||||
CALIBRESRC = d(d(d(os.path.abspath(calibre.__file__))))
|
||||
CALIBREPLUGINS = os.path.join(CALIBRESRC, 'src', 'calibre', 'plugins')
|
||||
FREEZE_DIR = os.path.join(CALIBRESRC, 'build', 'cx_freeze')
|
||||
DIST_DIR = os.path.join(CALIBRESRC, 'dist')
|
||||
|
||||
os.chdir(CALIBRESRC)
|
||||
|
||||
print 'Freezing calibre located at', CALIBRESRC
|
||||
|
||||
sys.path.insert(0, os.path.join(CALIBRESRC, 'src'))
|
||||
|
||||
entry_points = entry_points['console_scripts'] + entry_points['gui_scripts']
|
||||
entry_points = ['calibre_postinstall=calibre.linux:binary_install',
|
||||
'calibre-parallel=calibre.parallel:main'] + entry_points
|
||||
executables = {}
|
||||
for ep in entry_points:
|
||||
executables[ep.split('=')[0].strip()] = (ep.split('=')[1].split(':')[0].strip(),
|
||||
ep.split(':')[-1].strip())
|
||||
|
||||
if os.path.exists(FREEZE_DIR):
|
||||
shutil.rmtree(FREEZE_DIR)
|
||||
os.makedirs(FREEZE_DIR)
|
||||
|
||||
if not os.path.exists(DIST_DIR):
|
||||
os.makedirs(DIST_DIR)
|
||||
|
||||
includes = [x[0] for x in executables.values()]
|
||||
includes += ['calibre.ebooks.lrf.fonts.prs500.'+x for x in FONT_MAP.values()]
|
||||
includes += ['email.iterators', 'email.generator', 'sqlite3.dump']
|
||||
|
||||
|
||||
excludes = ['matplotlib', "Tkconstants", "Tkinter", "tcl", "_imagingtk",
|
||||
"ImageTk", "FixTk", 'wx', 'PyQt4.QtAssistant', 'PyQt4.QtOpenGL.so',
|
||||
'PyQt4.QtScript.so', 'PyQt4.QtSql.so', 'PyQt4.QtTest.so', 'qt',
|
||||
'glib', 'gobject']
|
||||
|
||||
packages = ['calibre', 'encodings', 'cherrypy', 'cssutils', 'xdg',
|
||||
'dateutil', 'dns', 'email']
|
||||
|
||||
includes += ['calibre.web.feeds.recipes.'+r for r in recipe_modules]
|
||||
includes += ['calibre.gui2.convert.'+x.split('/')[-1].rpartition('.')[0] for x in \
|
||||
glob.glob('src/calibre/gui2/convert/*.py')]
|
||||
|
||||
LOADER = '/tmp/loader.py'
|
||||
open(LOADER, 'wb').write('# This script is never actually used.\nimport sys')
|
||||
|
||||
INIT_SCRIPT = '/tmp/init.py'
|
||||
open(INIT_SCRIPT, 'wb').write(textwrap.dedent('''
|
||||
## Load calibre module specified in the environment variable CALIBRE_CX_EXE
|
||||
## Also restrict sys.path to the executables' directory and add the
|
||||
## executables directory to LD_LIBRARY_PATH
|
||||
import encodings
|
||||
import os
|
||||
import sys
|
||||
import warnings
|
||||
import zipimport
|
||||
import locale
|
||||
import codecs
|
||||
|
||||
enc = locale.getdefaultlocale()[1]
|
||||
if not enc:
|
||||
enc = locale.nl_langinfo(locale.CODESET)
|
||||
enc = codecs.lookup(enc if enc else 'UTF-8').name
|
||||
sys.setdefaultencoding(enc)
|
||||
|
||||
paths = os.environ.get('LD_LIBRARY_PATH', '').split(os.pathsep)
|
||||
if DIR_NAME not in paths or not sys.getfilesystemencoding():
|
||||
paths.insert(0, DIR_NAME)
|
||||
os.environ['LD_LIBRARY_PATH'] = os.pathsep.join(paths)
|
||||
os.environ['PYTHONIOENCODING'] = enc
|
||||
os.execv(sys.executable, sys.argv)
|
||||
|
||||
sys.path = sys.path[:3]
|
||||
sys.frozen = True
|
||||
sys.frozen_path = DIR_NAME
|
||||
|
||||
executables = %(executables)s
|
||||
|
||||
exe = os.environ.get('CALIBRE_CX_EXE', False)
|
||||
ret = 1
|
||||
if not exe:
|
||||
print >>sys.stderr, 'Invalid invocation of calibre loader. CALIBRE_CX_EXE not set'
|
||||
elif exe not in executables:
|
||||
print >>sys.stderr, 'Invalid invocation of calibre loader. CALIBRE_CX_EXE=%%s is unknown'%%exe
|
||||
else:
|
||||
from PyQt4.QtCore import QCoreApplication
|
||||
QCoreApplication.setLibraryPaths([sys.frozen_path, os.path.join(sys.frozen_path, "qtplugins")])
|
||||
sys.argv[0] = exe
|
||||
module, func = executables[exe]
|
||||
module = __import__(module, fromlist=[1])
|
||||
func = getattr(module, func)
|
||||
ret = func()
|
||||
|
||||
module = sys.modules.get("threading")
|
||||
if module is not None:
|
||||
module._shutdown()
|
||||
sys.exit(ret)
|
||||
''')%dict(executables=repr(executables)))
|
||||
sys.argv = ['freeze', 'build_exe']
|
||||
setup(
|
||||
name = __appname__,
|
||||
version = __version__,
|
||||
executables = [Executable(script=LOADER, targetName='loader', compress=False)],
|
||||
options = { 'build_exe' :
|
||||
{
|
||||
'build_exe' : os.path.join(CALIBRESRC, 'build/cx_freeze'),
|
||||
'optimize' : 2,
|
||||
'excludes' : excludes,
|
||||
'includes' : includes,
|
||||
'packages' : packages,
|
||||
'init_script' : INIT_SCRIPT,
|
||||
'copy_dependent_files' : True,
|
||||
'create_shared_zip' : False,
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
def copy_binary(src, dest_dir):
|
||||
dest = os.path.join(dest_dir, os.path.basename(src))
|
||||
if not os.path.exists(dest_dir):
|
||||
os.makedirs(dest_dir)
|
||||
shutil.copyfile(os.path.realpath(src), dest)
|
||||
shutil.copymode(os.path.realpath(src), dest)
|
||||
|
||||
for f in binary_includes:
|
||||
copy_binary(f, FREEZE_DIR)
|
||||
|
||||
for pat in binary_excludes:
|
||||
matches = glob.glob(os.path.join(FREEZE_DIR, pat))
|
||||
for f in matches:
|
||||
os.remove(f)
|
||||
|
||||
print 'Adding calibre plugins...'
|
||||
os.makedirs(os.path.join(FREEZE_DIR, 'plugins'))
|
||||
for f in glob.glob(os.path.join(CALIBREPLUGINS, '*.so')):
|
||||
copy_binary(f, os.path.join(FREEZE_DIR, 'plugins'))
|
||||
|
||||
print 'Adding Qt plugins...'
|
||||
plugdir = os.path.join(QTDIR, 'plugins')
|
||||
for dirpath, dirnames, filenames in os.walk(plugdir):
|
||||
for f in filenames:
|
||||
if not f.endswith('.so') or 'designer' in dirpath or 'codecs' in dirpath or 'sqldrivers' in dirpath:
|
||||
continue
|
||||
f = os.path.join(dirpath, f)
|
||||
dest_dir = dirpath.replace(plugdir, os.path.join(FREEZE_DIR, 'qtplugins'))
|
||||
copy_binary(f, dest_dir)
|
||||
|
||||
print 'Creating launchers'
|
||||
for exe in executables:
|
||||
path = os.path.join(FREEZE_DIR, exe)
|
||||
open(path, 'wb').write(textwrap.dedent('''\
|
||||
#!/bin/sh
|
||||
export CALIBRE_CX_EXE=%s
|
||||
path=`readlink -e $0`
|
||||
base=`dirname $path`
|
||||
loader=$base/loader
|
||||
export LD_LIBRARY_PATH=$base:$LD_LIBRARY_PATH
|
||||
$loader "$@"
|
||||
''')%exe)
|
||||
os.chmod(path, 0755)
|
||||
|
||||
exes = list(executables.keys())
|
||||
exes.remove('calibre_postinstall')
|
||||
exes.remove('calibre-parallel')
|
||||
open(os.path.join(FREEZE_DIR, 'manifest'), 'wb').write('\n'.join(exes))
|
||||
|
||||
print 'Creating archive...'
|
||||
dist = open(os.path.join(DIST_DIR, 'calibre-%s-%s.tar.bz2'%(__version__,
|
||||
arch)), 'wb')
|
||||
with closing(tarfile.open(fileobj=dist, mode='w:bz2',
|
||||
format=tarfile.PAX_FORMAT)) as tf:
|
||||
for f in walk(FREEZE_DIR):
|
||||
name = f.replace(FREEZE_DIR, '')[1:]
|
||||
if name:
|
||||
tf.add(f, name)
|
||||
dist.flush()
|
||||
dist.seek(0, 2)
|
||||
print 'Archive %s created: %.2f MB'%(dist.name, dist.tell()/(1024.**2))
|
||||
return 0
|
||||
|
||||
if __name__ == '__main__':
|
||||
freeze()
|
218
jsmin.py
@ -1,218 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
# This code is original from jsmin by Douglas Crockford, it was translated to
|
||||
# Python by Baruch Even. The original code had the following copyright and
|
||||
# license.
|
||||
#
|
||||
# /* jsmin.c
|
||||
# 2007-05-22
|
||||
#
|
||||
# Copyright (c) 2002 Douglas Crockford (www.crockford.com)
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
# this software and associated documentation files (the "Software"), to deal in
|
||||
# the Software without restriction, including without limitation the rights to
|
||||
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
# of the Software, and to permit persons to whom the Software is furnished to do
|
||||
# so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# The Software shall be used for Good, not Evil.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
# */
|
||||
|
||||
from StringIO import StringIO
|
||||
|
||||
def jsmin(js):
|
||||
ins = StringIO(js)
|
||||
outs = StringIO()
|
||||
JavascriptMinify().minify(ins, outs)
|
||||
str = outs.getvalue()
|
||||
if len(str) > 0 and str[0] == '\n':
|
||||
str = str[1:]
|
||||
return str
|
||||
|
||||
def isAlphanum(c):
|
||||
"""return true if the character is a letter, digit, underscore,
|
||||
dollar sign, or non-ASCII character.
|
||||
"""
|
||||
return ((c >= 'a' and c <= 'z') or (c >= '0' and c <= '9') or
|
||||
(c >= 'A' and c <= 'Z') or c == '_' or c == '$' or c == '\\' or (c is not None and ord(c) > 126));
|
||||
|
||||
class UnterminatedComment(Exception):
|
||||
pass
|
||||
|
||||
class UnterminatedStringLiteral(Exception):
|
||||
pass
|
||||
|
||||
class UnterminatedRegularExpression(Exception):
|
||||
pass
|
||||
|
||||
class JavascriptMinify(object):
|
||||
|
||||
def _outA(self):
|
||||
self.outstream.write(self.theA)
|
||||
def _outB(self):
|
||||
self.outstream.write(self.theB)
|
||||
|
||||
def _get(self):
|
||||
"""return the next character from stdin. Watch out for lookahead. If
|
||||
the character is a control character, translate it to a space or
|
||||
linefeed.
|
||||
"""
|
||||
c = self.theLookahead
|
||||
self.theLookahead = None
|
||||
if c == None:
|
||||
c = self.instream.read(1)
|
||||
if c >= ' ' or c == '\n':
|
||||
return c
|
||||
if c == '': # EOF
|
||||
return '\000'
|
||||
if c == '\r':
|
||||
return '\n'
|
||||
return ' '
|
||||
|
||||
def _peek(self):
|
||||
self.theLookahead = self._get()
|
||||
return self.theLookahead
|
||||
|
||||
def _next(self):
|
||||
"""get the next character, excluding comments. peek() is used to see
|
||||
if an unescaped '/' is followed by a '/' or '*'.
|
||||
"""
|
||||
c = self._get()
|
||||
if c == '/' and self.theA != '\\':
|
||||
p = self._peek()
|
||||
if p == '/':
|
||||
c = self._get()
|
||||
while c > '\n':
|
||||
c = self._get()
|
||||
return c
|
||||
if p == '*':
|
||||
c = self._get()
|
||||
while 1:
|
||||
c = self._get()
|
||||
if c == '*':
|
||||
if self._peek() == '/':
|
||||
self._get()
|
||||
return ' '
|
||||
if c == '\000':
|
||||
raise UnterminatedComment()
|
||||
|
||||
return c
|
||||
|
||||
def _action(self, action):
|
||||
"""do something! What you do is determined by the argument:
|
||||
1 Output A. Copy B to A. Get the next B.
|
||||
2 Copy B to A. Get the next B. (Delete A).
|
||||
3 Get the next B. (Delete B).
|
||||
action treats a string as a single character. Wow!
|
||||
action recognizes a regular expression if it is preceded by ( or , or =.
|
||||
"""
|
||||
if action <= 1:
|
||||
self._outA()
|
||||
|
||||
if action <= 2:
|
||||
self.theA = self.theB
|
||||
if self.theA == "'" or self.theA == '"':
|
||||
while 1:
|
||||
self._outA()
|
||||
self.theA = self._get()
|
||||
if self.theA == self.theB:
|
||||
break
|
||||
if self.theA <= '\n':
|
||||
raise UnterminatedStringLiteral()
|
||||
if self.theA == '\\':
|
||||
self._outA()
|
||||
self.theA = self._get()
|
||||
|
||||
|
||||
if action <= 3:
|
||||
self.theB = self._next()
|
||||
if self.theB == '/' and (self.theA == '(' or self.theA == ',' or
|
||||
self.theA == '=' or self.theA == ':' or
|
||||
self.theA == '[' or self.theA == '?' or
|
||||
self.theA == '!' or self.theA == '&' or
|
||||
self.theA == '|' or self.theA == ';' or
|
||||
self.theA == '{' or self.theA == '}' or
|
||||
self.theA == '\n'):
|
||||
self._outA()
|
||||
self._outB()
|
||||
while 1:
|
||||
self.theA = self._get()
|
||||
if self.theA == '/':
|
||||
break
|
||||
elif self.theA == '\\':
|
||||
self._outA()
|
||||
self.theA = self._get()
|
||||
elif self.theA <= '\n':
|
||||
raise UnterminatedRegularExpression()
|
||||
self._outA()
|
||||
self.theB = self._next()
|
||||
|
||||
|
||||
def _jsmin(self):
|
||||
"""Copy the input to the output, deleting the characters which are
|
||||
insignificant to JavaScript. Comments will be removed. Tabs will be
|
||||
replaced with spaces. Carriage returns will be replaced with linefeeds.
|
||||
Most spaces and linefeeds will be removed.
|
||||
"""
|
||||
self.theA = '\n'
|
||||
self._action(3)
|
||||
|
||||
while self.theA != '\000':
|
||||
if self.theA == ' ':
|
||||
if isAlphanum(self.theB):
|
||||
self._action(1)
|
||||
else:
|
||||
self._action(2)
|
||||
elif self.theA == '\n':
|
||||
if self.theB in ['{', '[', '(', '+', '-']:
|
||||
self._action(1)
|
||||
elif self.theB == ' ':
|
||||
self._action(3)
|
||||
else:
|
||||
if isAlphanum(self.theB):
|
||||
self._action(1)
|
||||
else:
|
||||
self._action(2)
|
||||
else:
|
||||
if self.theB == ' ':
|
||||
if isAlphanum(self.theA):
|
||||
self._action(1)
|
||||
else:
|
||||
self._action(3)
|
||||
elif self.theB == '\n':
|
||||
if self.theA in ['}', ']', ')', '+', '-', '"', '\'']:
|
||||
self._action(1)
|
||||
else:
|
||||
if isAlphanum(self.theA):
|
||||
self._action(1)
|
||||
else:
|
||||
self._action(3)
|
||||
else:
|
||||
self._action(1)
|
||||
|
||||
def minify(self, instream, outstream):
|
||||
self.instream = instream
|
||||
self.outstream = outstream
|
||||
self.theA = '\n'
|
||||
self.theB = None
|
||||
self.theLookahead = None
|
||||
|
||||
self._jsmin()
|
||||
self.instream.close()
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
jsm = JavascriptMinify()
|
||||
jsm.minify(sys.stdin, sys.stdout)
|
279
pyqtdistutils.py
@ -1,279 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
'''
|
||||
Build PyQt extensions. Integrates with distutils (but uses the PyQt build system).
|
||||
'''
|
||||
from distutils.core import Extension as _Extension
|
||||
from distutils.command.build_ext import build_ext as _build_ext
|
||||
from distutils.dep_util import newer_group
|
||||
from distutils import log
|
||||
from distutils.spawn import find_executable
|
||||
|
||||
import sipconfig, os, sys, string, glob, shutil
|
||||
from PyQt4 import pyqtconfig
|
||||
iswindows = 'win32' in sys.platform
|
||||
isosx = 'darwin' in sys.platform
|
||||
QMAKE = '/Volumes/sw/qt/bin/qmake' if isosx else 'qmake'
|
||||
if find_executable('qmake-qt4'):
|
||||
QMAKE = find_executable('qmake-qt4')
|
||||
elif find_executable('qmake'):
|
||||
QMAKE = find_executable('qmake')
|
||||
QMAKE = os.environ.get('QMAKE', QMAKE)
|
||||
WINDOWS_PYTHON = ['C:/Python26/libs']
|
||||
OSX_SDK = '/Developer/SDKs/MacOSX10.5.sdk'
|
||||
if not os.path.exists(OSX_SDK):
|
||||
OSX_SDK = '/Developer/SDKs/MacOSX10.4u.sdk'
|
||||
|
||||
leopard_build = '10.5' in OSX_SDK
|
||||
|
||||
def replace_suffix(path, new_suffix):
|
||||
return os.path.splitext(path)[0] + new_suffix
|
||||
|
||||
class Extension(_Extension):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
if leopard_build:
|
||||
prev = kwargs.get('extra_compile_args', [])
|
||||
prev.extend(['-arch', 'ppc64', '-arch', 'x86_64'])
|
||||
kwargs['extra_compile_args'] = prev
|
||||
_Extension.__init__(self, *args, **kwargs)
|
||||
|
||||
|
||||
if iswindows:
|
||||
from distutils import msvc9compiler
|
||||
msvc = msvc9compiler.MSVCCompiler()
|
||||
msvc.initialize()
|
||||
nmake = msvc.find_exe('nmake.exe')
|
||||
rc = msvc.find_exe('rc.exe')
|
||||
|
||||
class PyQtExtension(Extension):
|
||||
|
||||
def __init__(self, name, sources, sip_sources, **kw):
|
||||
'''
|
||||
:param sources: Qt .cpp and .h files needed for this extension
|
||||
:param sip_sources: List of .sip files this extension depends on. The
|
||||
first .sip file will be used toactually build the extension.
|
||||
'''
|
||||
self.module_makefile = pyqtconfig.QtGuiModuleMakefile
|
||||
self.sip_sources = map(lambda x: x.replace('/', os.sep), sip_sources)
|
||||
Extension.__init__(self, name, sources, **kw)
|
||||
|
||||
|
||||
class build_ext(_build_ext):
|
||||
|
||||
def make(self, makefile):
|
||||
make = nmake if iswindows else 'make'
|
||||
self.spawn([make, '-f', makefile])
|
||||
|
||||
def build_qt_objects(self, ext, bdir):
|
||||
if not iswindows:
|
||||
bdir = os.path.join(bdir, 'qt')
|
||||
if not os.path.exists(bdir):
|
||||
os.makedirs(bdir)
|
||||
cwd = os.getcwd()
|
||||
sources = map(os.path.abspath, ext.sources)
|
||||
os.chdir(bdir)
|
||||
archs = 'x86_64 ppc64' if leopard_build else 'x86 ppc'
|
||||
try:
|
||||
headers = set([f for f in sources if f.endswith('.h')])
|
||||
sources = set(sources) - headers
|
||||
name = ext.name.rpartition('.')[-1]
|
||||
pro = '''\
|
||||
TARGET = %s
|
||||
TEMPLATE = lib
|
||||
HEADERS = %s
|
||||
SOURCES = %s
|
||||
VERSION = 1.0.0
|
||||
CONFIG += %s
|
||||
'''%(name, ' '.join(headers), ' '.join(sources), archs)
|
||||
open(name+'.pro', 'wb').write(pro)
|
||||
self.spawn([QMAKE, '-o', 'Makefile.qt', name+'.pro'])
|
||||
if leopard_build:
|
||||
raw = open('Makefile.qt', 'rb').read()
|
||||
open('Makefile.qt', 'wb').write(raw.replace('ppc64', 'x86_64'))
|
||||
self.make('Makefile.qt')
|
||||
pat = 'release\\*.obj' if iswindows else '*.o'
|
||||
return map(os.path.abspath, glob.glob(pat))
|
||||
finally:
|
||||
os.chdir(cwd)
|
||||
|
||||
def build_sbf(self, sip, sbf, bdir):
|
||||
print '\tBuilding sbf...'
|
||||
sip_bin = self.sipcfg.sip_bin
|
||||
pyqt_sip_flags = []
|
||||
if hasattr(self, 'pyqtcfg'):
|
||||
pyqt_sip_flags += ['-I', self.pyqtcfg.pyqt_sip_dir]
|
||||
pyqt_sip_flags += self.pyqtcfg.pyqt_sip_flags.split()
|
||||
self.spawn([sip_bin,
|
||||
"-c", bdir,
|
||||
"-b", sbf,
|
||||
] + pyqt_sip_flags +
|
||||
[sip])
|
||||
|
||||
def build_pyqt(self, bdir, sbf, ext, qtobjs, headers):
|
||||
makefile = ext.module_makefile(configuration=self.pyqtcfg,
|
||||
build_file=sbf, dir=bdir,
|
||||
makefile='Makefile.pyqt',
|
||||
universal=OSX_SDK, qt=1)
|
||||
makefile.extra_libs = ext.libraries
|
||||
makefile.extra_lib_dirs = ext.library_dirs
|
||||
makefile.extra_cxxflags = ext.extra_compile_args
|
||||
|
||||
if 'win32' in sys.platform:
|
||||
makefile.extra_lib_dirs += WINDOWS_PYTHON
|
||||
makefile.extra_include_dirs = list(set(map(os.path.dirname, headers)))
|
||||
makefile.extra_include_dirs += ext.include_dirs
|
||||
makefile.extra_lflags += qtobjs
|
||||
makefile.generate()
|
||||
cwd = os.getcwd()
|
||||
os.chdir(bdir)
|
||||
if leopard_build:
|
||||
mf = 'Makefile.pyqt'
|
||||
raw = open(mf, 'rb').read()
|
||||
raw = raw.replace('ppc64 x86_64', 'x86_64')
|
||||
for x in ('ppc64', 'ppc', 'i386'):
|
||||
raw = raw.replace(x, 'x86_64')
|
||||
open(mf, 'wb').write(raw)
|
||||
try:
|
||||
self.make('Makefile.pyqt')
|
||||
finally:
|
||||
os.chdir(cwd)
|
||||
|
||||
|
||||
|
||||
def build_extension(self, ext):
|
||||
self.inplace = True # Causes extensions to be built in the source tree
|
||||
|
||||
fullname = self.get_ext_fullname(ext.name)
|
||||
if self.inplace:
|
||||
# ignore build-lib -- put the compiled extension into
|
||||
# the source tree along with pure Python modules
|
||||
|
||||
modpath = string.split(fullname, '.')
|
||||
package = string.join(modpath[0:-1], '.')
|
||||
base = modpath[-1]
|
||||
|
||||
build_py = self.get_finalized_command('build_py')
|
||||
package_dir = build_py.get_package_dir(package)
|
||||
ext_filename = os.path.join(package_dir,
|
||||
self.get_ext_filename(base))
|
||||
else:
|
||||
ext_filename = os.path.join(self.build_lib,
|
||||
self.get_ext_filename(fullname))
|
||||
bdir = os.path.abspath(os.path.join(self.build_temp, fullname))
|
||||
if not os.path.exists(bdir):
|
||||
os.makedirs(bdir)
|
||||
|
||||
if not isinstance(ext, PyQtExtension):
|
||||
if not iswindows:
|
||||
return _build_ext.build_extension(self, ext)
|
||||
|
||||
c_sources = [f for f in ext.sources if os.path.splitext(f)[1].lower() in ('.c', '.cpp', '.cxx')]
|
||||
compile_args = '/c /nologo /Ox /MD /W3 /EHsc /DNDEBUG'.split()
|
||||
compile_args += ext.extra_compile_args
|
||||
self.swig_opts = ''
|
||||
inc_dirs = self.include_dirs + [x.replace('/', '\\') for x in ext.include_dirs]
|
||||
cc = [msvc.cc] + compile_args + ['-I%s'%x for x in list(set(inc_dirs))]
|
||||
objects = []
|
||||
for f in c_sources:
|
||||
o = os.path.join(bdir, os.path.basename(f)+'.obj')
|
||||
objects.append(o)
|
||||
inf = '/Tp' if f.endswith('.cpp') else '/Tc'
|
||||
compiler = cc + [inf+f, '/Fo'+o]
|
||||
self.spawn(compiler)
|
||||
out = os.path.join(bdir, base+'.pyd')
|
||||
linker = [msvc.linker] + '/DLL /nologo /INCREMENTAL:NO'.split()
|
||||
linker += ['/LIBPATH:'+x for x in self.library_dirs+ext.library_dirs]
|
||||
linker += [x+'.lib' for x in ext.libraries]
|
||||
linker += ['/EXPORT:init'+base] + objects + ['/OUT:'+out]
|
||||
self.spawn(linker)
|
||||
for src in (out, out+'.manifest'):
|
||||
shutil.copyfile(src, os.path.join('src', 'calibre', 'plugins', os.path.basename(src)))
|
||||
return
|
||||
|
||||
|
||||
|
||||
if not os.path.exists(bdir):
|
||||
os.makedirs(bdir)
|
||||
ext.sources2 = map(os.path.abspath, ext.sources)
|
||||
qt_dir = 'qt\\release' if iswindows else 'qt'
|
||||
objects = set(map(lambda x: os.path.join(bdir, qt_dir, replace_suffix(os.path.basename(x), '.o')),
|
||||
[s for s in ext.sources2 if not s.endswith('.h')]))
|
||||
newer = False
|
||||
for object in objects:
|
||||
if newer_group(ext.sources2, object, missing='newer'):
|
||||
newer = True
|
||||
break
|
||||
headers = [f for f in ext.sources2 if f.endswith('.h')]
|
||||
if self.force or newer:
|
||||
log.info('building \'%s\' extension', ext.name)
|
||||
objects = self.build_qt_objects(ext, bdir)
|
||||
|
||||
self.sipcfg = sipconfig.Configuration()
|
||||
self.pyqtcfg = pyqtconfig.Configuration()
|
||||
sbf_sources = []
|
||||
for sip in ext.sip_sources:
|
||||
sipbasename = os.path.basename(sip)
|
||||
sbf = os.path.join(bdir, replace_suffix(sipbasename, ".sbf"))
|
||||
sbf_sources.append(sbf)
|
||||
if self.force or newer_group(ext.sip_sources, sbf, 'newer'):
|
||||
self.build_sbf(sip, sbf, bdir)
|
||||
generated_sources = []
|
||||
for sbf in sbf_sources:
|
||||
generated_sources += self.get_sip_output_list(sbf, bdir)
|
||||
|
||||
depends = generated_sources + list(objects)
|
||||
mod = os.path.join(bdir, os.path.basename(ext_filename))
|
||||
|
||||
if self.force or newer_group(depends, mod, 'newer'):
|
||||
self.build_pyqt(bdir, sbf_sources[0], ext, list(objects), headers)
|
||||
|
||||
if self.force or newer_group([mod], ext_filename, 'newer'):
|
||||
if os.path.exists(ext_filename):
|
||||
os.unlink(ext_filename)
|
||||
shutil.copyfile(mod, ext_filename)
|
||||
shutil.copymode(mod, ext_filename)
|
||||
|
||||
|
||||
if self.force or newer_group([mod], ext_filename, 'newer'):
|
||||
if os.path.exists(ext_filename):
|
||||
os.unlink(ext_filename)
|
||||
shutil.copyfile(mod, ext_filename)
|
||||
shutil.copymode(mod, ext_filename)
|
||||
|
||||
|
||||
def get_sip_output_list(self, sbf, bdir):
|
||||
"""
|
||||
Parse the sbf file specified to extract the name of the generated source
|
||||
files. Make them absolute assuming they reside in the temp directory.
|
||||
"""
|
||||
for L in file(sbf):
|
||||
key, value = L.split("=", 1)
|
||||
if key.strip() == "sources":
|
||||
out = []
|
||||
for o in value.split():
|
||||
out.append(os.path.join(bdir, o))
|
||||
return out
|
||||
|
||||
raise RuntimeError, "cannot parse SIP-generated '%s'" % sbf
|
||||
|
||||
def run_sip(self, sip_files):
|
||||
sip_bin = self.sipcfg.sip_bin
|
||||
sip_sources = [i[0] for i in sip_files]
|
||||
generated_sources = []
|
||||
for sip, sbf in sip_files:
|
||||
if not (self.force or newer_group(sip_sources, sbf, 'newer')):
|
||||
log.info(sbf + ' is up to date')
|
||||
continue
|
||||
self.spawn([sip_bin,
|
||||
"-c", self.build_temp,
|
||||
"-b", sbf,
|
||||
'-I', self.pyqtcfg.pyqt_sip_dir,
|
||||
] + self.pyqtcfg.pyqt_sip_flags.split()+
|
||||
[sip])
|
||||
generated_sources += self.get_sip_output_list(sbf)
|
||||
return generated_sources
|
||||
|
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 471 B After Width: | Height: | Size: 471 B |
Before Width: | Height: | Size: 335 B After Width: | Height: | Size: 335 B |
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 37 KiB |
Before Width: | Height: | Size: 248 B After Width: | Height: | Size: 248 B |
Before Width: | Height: | Size: 255 B After Width: | Height: | Size: 255 B |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 267 B After Width: | Height: | Size: 267 B |
Before Width: | Height: | Size: 262 B After Width: | Height: | Size: 262 B |
BIN
resources/fonts/liberation/LiberationMono-Bold.ttf
Normal file
BIN
resources/fonts/liberation/LiberationMono-BoldItalic.ttf
Normal file
BIN
resources/fonts/liberation/LiberationMono-Italic.ttf
Normal file
BIN
resources/fonts/liberation/LiberationMono-Regular.ttf
Normal file
BIN
resources/fonts/liberation/LiberationSans-Bold.ttf
Normal file
BIN
resources/fonts/liberation/LiberationSans-BoldItalic.ttf
Normal file
BIN
resources/fonts/liberation/LiberationSans-Italic.ttf
Normal file
BIN
resources/fonts/liberation/LiberationSans-Regular.ttf
Normal file
BIN
resources/fonts/liberation/LiberationSerif-Bold.ttf
Normal file
BIN
resources/fonts/liberation/LiberationSerif-BoldItalic.ttf
Normal file
BIN
resources/fonts/liberation/LiberationSerif-Italic.ttf
Normal file
BIN
resources/fonts/liberation/LiberationSerif-Regular.ttf
Normal file
BIN
resources/fonts/prs500/tt0003m_.ttf
Normal file
BIN
resources/fonts/prs500/tt0011m_.ttf
Normal file
BIN
resources/fonts/prs500/tt0419m_.ttf
Normal file
Before Width: | Height: | Size: 89 KiB After Width: | Height: | Size: 89 KiB |
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 35 KiB |
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 35 KiB |
Before Width: | Height: | Size: 46 KiB After Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 6.9 KiB After Width: | Height: | Size: 6.9 KiB |
Before Width: | Height: | Size: 117 KiB After Width: | Height: | Size: 117 KiB |
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 75 KiB After Width: | Height: | Size: 75 KiB |
Before Width: | Height: | Size: 117 KiB After Width: | Height: | Size: 117 KiB |
Before Width: | Height: | Size: 6.9 KiB After Width: | Height: | Size: 6.9 KiB |
Before Width: | Height: | Size: 124 KiB After Width: | Height: | Size: 124 KiB |
Before Width: | Height: | Size: 185 KiB After Width: | Height: | Size: 185 KiB |
Before Width: | Height: | Size: 116 KiB After Width: | Height: | Size: 116 KiB |
Before Width: | Height: | Size: 92 KiB After Width: | Height: | Size: 92 KiB |
Before Width: | Height: | Size: 203 KiB After Width: | Height: | Size: 203 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 38 KiB |
Before Width: | Height: | Size: 8.0 KiB After Width: | Height: | Size: 8.0 KiB |
Before Width: | Height: | Size: 64 KiB After Width: | Height: | Size: 64 KiB |
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
Before Width: | Height: | Size: 6.9 KiB After Width: | Height: | Size: 6.9 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 43 KiB |
Before Width: | Height: | Size: 116 KiB After Width: | Height: | Size: 116 KiB |
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 5.4 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 8.4 KiB After Width: | Height: | Size: 8.4 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 80 KiB |
Before Width: | Height: | Size: 158 KiB After Width: | Height: | Size: 158 KiB |
Before Width: | Height: | Size: 8.5 KiB After Width: | Height: | Size: 8.5 KiB |
Before Width: | Height: | Size: 274 KiB After Width: | Height: | Size: 274 KiB |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 80 KiB |
Before Width: | Height: | Size: 108 KiB After Width: | Height: | Size: 108 KiB |
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 80 KiB |
Before Width: | Height: | Size: 483 KiB After Width: | Height: | Size: 483 KiB |
Before Width: | Height: | Size: 95 KiB After Width: | Height: | Size: 95 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 5.6 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 85 KiB After Width: | Height: | Size: 85 KiB |
Before Width: | Height: | Size: 131 KiB After Width: | Height: | Size: 131 KiB |
Before Width: | Height: | Size: 143 KiB After Width: | Height: | Size: 143 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 131 KiB After Width: | Height: | Size: 131 KiB |
Before Width: | Height: | Size: 9.8 KiB After Width: | Height: | Size: 9.8 KiB |
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 7.2 KiB |
Before Width: | Height: | Size: 127 KiB After Width: | Height: | Size: 127 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 168 KiB After Width: | Height: | Size: 168 KiB |
Before Width: | Height: | Size: 109 KiB After Width: | Height: | Size: 109 KiB |
Before Width: | Height: | Size: 671 B After Width: | Height: | Size: 671 B |
Before Width: | Height: | Size: 830 B After Width: | Height: | Size: 830 B |
Before Width: | Height: | Size: 686 B After Width: | Height: | Size: 686 B |
Before Width: | Height: | Size: 508 B After Width: | Height: | Size: 508 B |
Before Width: | Height: | Size: 834 B After Width: | Height: | Size: 834 B |
Before Width: | Height: | Size: 659 B After Width: | Height: | Size: 659 B |