mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-02 13:14:50 -04:00
Allow running calibre from source without needing to run either develop or install
This commit is contained in:
parent
d3e42a4cf3
commit
4e3c64d09f
26
run-local
Executable file
26
run-local
Executable file
@ -0,0 +1,26 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
import importlib
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
sys.run_local = os.path.abspath(__file__)
|
||||||
|
base = os.path.dirname(sys.run_local)
|
||||||
|
src = os.path.join(base, 'src')
|
||||||
|
if src not in sys.path:
|
||||||
|
sys.path.insert(0, src)
|
||||||
|
sys.resources_location = os.path.join(base, 'resources')
|
||||||
|
sys.extensions_location = os.path.join(src, 'calibre', 'plugins')
|
||||||
|
entry_point = sys.argv[1]
|
||||||
|
del sys.argv[1]
|
||||||
|
del src
|
||||||
|
del base
|
||||||
|
|
||||||
|
for ep in importlib.import_module('calibre.linux').entry_points.values():
|
||||||
|
for line in ep:
|
||||||
|
q, spec = (x.strip() for x in line.split('='))
|
||||||
|
if q == entry_point:
|
||||||
|
mod, func = spec.split(':')
|
||||||
|
m = importlib.import_module(mod)
|
||||||
|
sys.exit(getattr(m, func)())
|
||||||
|
raise SystemExit('No entry point named: {}'.format(entry_point))
|
@ -62,6 +62,8 @@ class Worker(object):
|
|||||||
def executable(self):
|
def executable(self):
|
||||||
if hasattr(sys, 'running_from_setup'):
|
if hasattr(sys, 'running_from_setup'):
|
||||||
return [sys.executable, os.path.join(sys.setup_dir, 'run-calibre-worker.py')]
|
return [sys.executable, os.path.join(sys.setup_dir, 'run-calibre-worker.py')]
|
||||||
|
if getattr(sys, 'run_local', False):
|
||||||
|
return [sys.executable, sys.run_local, self.exe_name]
|
||||||
e = self.exe_name
|
e = self.exe_name
|
||||||
if iswindows:
|
if iswindows:
|
||||||
return os.path.join(os.path.dirname(sys.executable),
|
return os.path.join(os.path.dirname(sys.executable),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user