Skip to content

Commit 4e3c64d

Browse files
committed
Allow running calibre from source without needing to run either develop or install
1 parent d3e42a4 commit 4e3c64d

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

run-local

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env python
2+
import importlib
3+
import os
4+
import sys
5+
6+
7+
sys.run_local = os.path.abspath(__file__)
8+
base = os.path.dirname(sys.run_local)
9+
src = os.path.join(base, 'src')
10+
if src not in sys.path:
11+
sys.path.insert(0, src)
12+
sys.resources_location = os.path.join(base, 'resources')
13+
sys.extensions_location = os.path.join(src, 'calibre', 'plugins')
14+
entry_point = sys.argv[1]
15+
del sys.argv[1]
16+
del src
17+
del base
18+
19+
for ep in importlib.import_module('calibre.linux').entry_points.values():
20+
for line in ep:
21+
q, spec = (x.strip() for x in line.split('='))
22+
if q == entry_point:
23+
mod, func = spec.split(':')
24+
m = importlib.import_module(mod)
25+
sys.exit(getattr(m, func)())
26+
raise SystemExit('No entry point named: {}'.format(entry_point))

src/calibre/utils/ipc/launch.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ def osx_contents_dir(self):
6262
def executable(self):
6363
if hasattr(sys, 'running_from_setup'):
6464
return [sys.executable, os.path.join(sys.setup_dir, 'run-calibre-worker.py')]
65+
if getattr(sys, 'run_local', False):
66+
return [sys.executable, sys.run_local, self.exe_name]
6567
e = self.exe_name
6668
if iswindows:
6769
return os.path.join(os.path.dirname(sys.executable),

0 commit comments

Comments
 (0)