mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
build: add option to symlink to system mathjax installation
This commit is contained in:
parent
6adedd8603
commit
82617d3a74
@ -27,6 +27,8 @@ class MathJax(Command):
|
|||||||
def add_options(self, parser):
|
def add_options(self, parser):
|
||||||
parser.add_option('--path-to-mathjax', help='Path to the MathJax source code')
|
parser.add_option('--path-to-mathjax', help='Path to the MathJax source code')
|
||||||
parser.add_option('--mathjax-url', default=self.MATH_JAX_URL, help='URL to MathJax source archive in zip format')
|
parser.add_option('--mathjax-url', default=self.MATH_JAX_URL, help='URL to MathJax source archive in zip format')
|
||||||
|
parser.add_option('--system-mathjax', default=False, action='store_true',
|
||||||
|
help='Treat MathJax as system copy and symlink instead of copy')
|
||||||
|
|
||||||
def download_mathjax_release(self, tdir, url):
|
def download_mathjax_release(self, tdir, url):
|
||||||
self.info('Downloading MathJax:', url)
|
self.info('Downloading MathJax:', url)
|
||||||
@ -44,6 +46,9 @@ class MathJax(Command):
|
|||||||
base = os.path.dirname(dest)
|
base = os.path.dirname(dest)
|
||||||
if not os.path.exists(base):
|
if not os.path.exists(base):
|
||||||
os.makedirs(base)
|
os.makedirs(base)
|
||||||
|
if self.use_symlinks:
|
||||||
|
os.symlink(path, dest)
|
||||||
|
else:
|
||||||
with open(dest, 'wb') as f:
|
with open(dest, 'wb') as f:
|
||||||
f.write(raw)
|
f.write(raw)
|
||||||
|
|
||||||
@ -63,6 +68,7 @@ class MathJax(Command):
|
|||||||
def run(self, opts):
|
def run(self, opts):
|
||||||
self.h = sha1()
|
self.h = sha1()
|
||||||
self.mathjax_files = {}
|
self.mathjax_files = {}
|
||||||
|
self.use_symlinks = opts.system_mathjax
|
||||||
self.clean()
|
self.clean()
|
||||||
os.mkdir(self.mathjax_dir)
|
os.mkdir(self.mathjax_dir)
|
||||||
tdir = mkdtemp('calibre-mathjax-build')
|
tdir = mkdtemp('calibre-mathjax-build')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user