mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Make sure that python setup.py resources works even if calibre has not been installed
This commit is contained in:
parent
8e7a9eceb1
commit
2d6291e5fc
@ -6,7 +6,7 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import os, cPickle, re, shutil, marshal, zipfile, glob, time
|
||||
import os, cPickle, re, shutil, marshal, zipfile, glob, time, subprocess, sys
|
||||
from zlib import compress
|
||||
|
||||
from setup import Command, basenames, __appname__
|
||||
@ -35,8 +35,8 @@ class Coffee(Command): # {{{
|
||||
help='Display the generated javascript')
|
||||
|
||||
def run(self, opts):
|
||||
from calibre.utils.serve_coffee import compile_coffeescript
|
||||
self.compiler = compile_coffeescript
|
||||
cc = self.j(self.SRC, 'calibre', 'utils', 'serve_coffee.py')
|
||||
self.compiler = [sys.executable, cc, 'compile']
|
||||
self.do_coffee_compile(opts)
|
||||
if opts.watch:
|
||||
try:
|
||||
@ -63,24 +63,24 @@ class Coffee(Command): # {{{
|
||||
if self.newer(js, x):
|
||||
print ('\t%sCompiling %s'%(time.strftime('[%H:%M:%S] ') if
|
||||
timestamp else '', os.path.basename(x)))
|
||||
with open(x, 'rb') as f:
|
||||
cs, errs = self.compiler(f.read())
|
||||
for line in errs:
|
||||
print (line)
|
||||
if cs and not errs:
|
||||
try:
|
||||
cs = subprocess.check_output(self.compiler +
|
||||
[x]).decode('utf-8')
|
||||
except Exception as e:
|
||||
print ('\n\tCompilation of %s failed'%os.path.basename(x))
|
||||
print (e)
|
||||
if ignore_errors:
|
||||
with open(js, 'wb') as f:
|
||||
f.write('# Compilation from coffeescript failed')
|
||||
else:
|
||||
raise SystemExit(1)
|
||||
else:
|
||||
with open(js, 'wb') as f:
|
||||
f.write(cs.encode('utf-8'))
|
||||
if opts.show_js:
|
||||
self.show_js(js)
|
||||
print ('#'*80)
|
||||
print ('#'*80)
|
||||
else:
|
||||
print ('\n\tCompilation of %s failed'%os.path.basename(x))
|
||||
if ignore_errors:
|
||||
with open(js, 'wb') as f:
|
||||
f.write('# Compilation from coffeescript failed')
|
||||
else:
|
||||
raise SystemExit(1)
|
||||
|
||||
def clean(self):
|
||||
for toplevel, dest in self.COFFEE_DIRS.iteritems():
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user