View Single Post
Old 12-10-2016, 09:50 PM   #1
botmtl
Enthusiast
botmtl really knows where his or her towel isbotmtl really knows where his or her towel isbotmtl really knows where his or her towel isbotmtl really knows where his or her towel isbotmtl really knows where his or her towel isbotmtl really knows where his or her towel isbotmtl really knows where his or her towel isbotmtl really knows where his or her towel isbotmtl really knows where his or her towel isbotmtl really knows where his or her towel isbotmtl really knows where his or her towel is
 
botmtl's Avatar
 
Posts: 43
Karma: 70238
Join Date: Jun 2014
Device: none
Post Calibre on Ubuntu on Windows (WSL)

Although not apparent at first glance, this picture is calibre running on the Windows Subsystem for Linux.



Why?: Because you can
No really why?: Shit and giggles
Theoretical whys:
- test if your plugin works on linux
- use linux-only plugins (although as of this moment there is only one such plugin - recoll - and it should not be linux-only since recoll is also available on the windows platform).
- (very theoretical) I have a feeling that visual studio ptvsd will work better connecting to a linux remote debugger than it does with the source code on a local windows only environment. (more to come on that later if I manage it).

Environment:
- Windows 14965+
______________________________
/ Distributor ID: Ubuntu Description: \
| Ubuntu 16.04.1 LTS Release: 16.04 |
\ Codename: xenial /
-------------------------------------

How to do it.

Windows side:
- install VcXsrv (or Xming, but I used VcXrv)

Bash side:
- X11 forwarding
Code:
echo "export DISPLAY=:0.0" >> ~/.bashrc
- fix most dbus problems
Code:
sudo sed -i 's$<listen>.*</listen>$<listen>tcp:host=localhost,port=0</listen>$' /etc/dbus-1/session.conf
- install calibre
sudo apt-get -y update
sudo apt-get -y upgrade
sudo apt-get install -y calibre

- monotonic patch
for some reason, kovid's monotonic implementation crashes in this environment. replace it with pipy's own monotonic lib.
Code:
sudo mv /usr/lib/calibre/calibre/utils/monotonic.py /usr/lib/calibre/calibre/utils/monotonic.bak
sudo mv /usr/lib/calibre/calibre/utils/monotonic.pyc /usr/lib/calibre/calibre/utils/monotonic.bakc
sudo wget https://raw.githubusercontent.com/atdt/monotonic/master/monotonic.py
sudo mv monotonic.py /usr/lib/calibre/calibre/utils/monotonic.py
I mostly tested the UI. calibre-viewer, calibre-editor, calibre, etc.

There shouldn't be anything not obvious missing. I chose not to go into the obvious stuff like install xpdf to be able to view pdf files, etc.

*edited*
Forgot a part. I can totally picture Kovid's face twisting in disgust at this "patch".
In /home/wsl/calibre/src/calibre/gui2/__init__.py, comment out line 1159
#fcntl.fcntl(fd, fcntl.F_SETFD, flags | cloexec_flag | os.O_NONBLOCK)

be warned that this tiny comment is bound to have huge effects on everything from filelocking to leaking file descriptors, to making your harddrive explode (not really).

Last edited by botmtl; 12-14-2016 at 07:43 PM.
botmtl is offline   Reply With Quote