Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Recipes

Notices

Reply
 
Thread Tools Search this Thread
Old 10-15-2016, 12:10 AM   #1
bently
Junior Member
bently began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Oct 2016
Device: pi
Building calibre 1.48 from source on a raspberry pi

I wanted to turn my raspberry pi into a calibre ebook server. I didn't need the gui functionality, intending to just run calibre-server from the pi, and do the book adding and updating via another system with the library cross mounted with sshfs_mount.

The version of calibre that's currently available (as of 2016/10) via apt for raspberry pi is 0.8.51, which is, shall we say, a little long in the tooth. If I started the server on the pi, I could browse the library as a content server, but not download any of the books or see the metadata. So time to see if I could build it from source.

The list of dependencies is a little daunting, and there were not many posts describing the procedure. Those that I found were rather old, and not terribly descriptive.

calibre has a major dependency on Qt. Given that the version available on the pi is Qt4, and I really didn't want to build all of Qt5, I decided to stick to the 1.XX releases of calibre, and picked 1.48 as that was the last one.

There were 2 dependencies that needed to be built from scratch, as the packages available via apt were insufficiently recent:

- python (2.7.9)
- icu (49)

You could probably use a more recent version of python 2.7, but I stuck with 2.7.9 as that's what was referenced in the docs.

the main gotcha that I didn't catch until much later when building calibre (and then had to wipe out the build and restart from scratch), was to use the correct version of unicode. This is the configuration I used for building python:

./configure --prefix=/usr/local --enable-shared --enable-unicode=ucs4

it built and installed cleanly (I ignored the warnings about missing features that I didn't care about). you'll want to update your ld cache after the install, to make sure the right libraries are picked up. check with python --version.

you may need to adjust your PYTHONPATH environment variable according to where the packages were installed. eg:
export PYTHONPATH=/usr/lib/python2.7/dist-packages


icu built without incident or deviations from the instructions.

now for calibre. download the source, unpack it, and build with
python2 setup.py install
there are lots of package dependencies that I discovered by trial and error: try to build calibre, look at the error message about missing file or module, do an apt-file search, and see what comes up. install the relevant package, and try again. here is a non-comprehensive list (depending on what you already have installed, you may need more or less).

python-qt4,python-qt4-dev,libsqlite3-dev, libchm-dev,libmagickwand-dev,
libpodofo-dev,python-sip-dev,python-qt4-dev,libqt4-private-dev,libusb-1.0-0-dev,libmtp-dev,python-cssselect,python-apsw

doing an apt-get install on these will probably bring in lots of other packages too, so make sure you have plenty of space free in /usr.


next problem: the build tries to import some icu plugins before they've been built. so comment out the icu related lines (lines 178 to 181) in src/calibre/startup.py

ok now you're ready to build (but read the next paragraph first). do
python2 setup.py install

finally, some of the modules in Qt4 are not in the places that calibre thinks they are. I needed to modify src/calibre/gui2/__init__.py so that it looked like this:

from PyQt4.QtCore import (QVariant, QFileInfo, QObject, QBuffer, Qt,
QByteArray, QTranslator, QCoreApplication, QThread,
QEvent, QTimer, pyqtSignal, QDateTime,
QSettings, QUrl, QLocale)
from PyQt4.QtGui import (QDesktopServices, QFileDialog,QFileIconProvider,
QIcon, QDialog, QColor, QFont, QPalette,
QApplication, QFontDatabase)


you may or may not have to do the same. if there's a problem, there will be import errors.

towards the end of the build, you'll run into icu related issues again. so after the build fails, go back and uncomment the bits you commented out towards the start, and build again. the icu plugin has been built by this point, so it works!

that should be it. I had one final build error when it was generating the file name completions and desktop integration, as is_safe_name doesn't seem to be in cssselect.xpath any more, but I didn't care about that feature, and it didn't affect the functionality of the calibre-server binary.

after that I started calibre-server, and was able to successfully serve content to another device over the network, and view metadata, which is all that I wanted. I did not explore any of the other features.
bently is offline   Reply With Quote
Old 10-15-2016, 12:27 AM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,353
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Interesting. Is there some reason you chose to do the build on the Raspberry Pi instead of cross-compiling? I suppose setting up the cross compile environment is a fairly painful initial effort.

There are build scripts for automatically building calibre and all its dependencies including python and Qt here: https://github.com/kovidgoyal/build-calibre

Someday I should get around to adding linux ARM builds to those scripts. All that's needed is creating a docker image setup for cross-compiling and adjusting a few of the build scripts as appropraite for cross compiling.
kovidgoyal is offline   Reply With Quote
Advert
Old 10-15-2016, 01:37 AM   #3
bently
Junior Member
bently began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Oct 2016
Device: pi
indeed - a cross compile seemed like a lot more work, and in my experience with other projects, less likely to succeed. however, if you think it will work, I will try it next with a more recent version of calibre.
bently is offline   Reply With Quote
Old 10-15-2016, 02:35 AM   #4
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,353
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
I dont know, I haven't really looked into it in any detail. Something for my TODO list.

The motivation for it is that the content server has been completely re-written for calibre 3.0 withmuch enhanced capabilities, so you dont want to be stuck on 1.48 forever.
kovidgoyal is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Building Calibre from source for Raspberry Pi wayt Calibre 12 08-08-2014 12:53 PM
Building Sigil from source on Linux xingenter Sigil 10 04-29-2013 01:18 PM
building from source - qt4.8.1? platt Sigil 10 05-21-2012 09:32 AM
Problem building Calibre from source on Ubuntu 10.10 rozen Calibre 1 03-28-2011 02:02 AM
Building Calibre from source al35 Calibre 3 03-24-2010 02:22 PM


All times are GMT -4. The time now is 09:23 AM.


MobileRead.com is a privately owned, operated and funded community.