mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Use curl to download mathjax as well so that it works in Travis on OS X
This commit is contained in:
parent
e652bfac22
commit
91d3802377
@ -27,6 +27,7 @@ __version__ = __appname__ = modules = functions = basenames = scripts = None
|
|||||||
|
|
||||||
_cache_dir_built = False
|
_cache_dir_built = False
|
||||||
|
|
||||||
|
|
||||||
def newer(targets, sources):
|
def newer(targets, sources):
|
||||||
if isinstance(targets, basestring):
|
if isinstance(targets, basestring):
|
||||||
targets = [targets]
|
targets = [targets]
|
||||||
@ -40,6 +41,14 @@ def newer(targets, sources):
|
|||||||
newest_source, oldest_target = max(stimes), min(ttimes)
|
newest_source, oldest_target = max(stimes), min(ttimes)
|
||||||
return newest_source > oldest_target
|
return newest_source > oldest_target
|
||||||
|
|
||||||
|
|
||||||
|
def download_securely(url):
|
||||||
|
# We use curl here as on some OSes (OS X) when bootstrapping calibre,
|
||||||
|
# python will be unable to validate certificates until after cacerts is
|
||||||
|
# installed
|
||||||
|
return subprocess.check_output(['curl', '-fsSL', url])
|
||||||
|
|
||||||
|
|
||||||
def build_cache_dir():
|
def build_cache_dir():
|
||||||
global _cache_dir_built
|
global _cache_dir_built
|
||||||
ans = os.path.join(os.path.dirname(SRC), '.build-cache')
|
ans = os.path.join(os.path.dirname(SRC), '.build-cache')
|
||||||
@ -52,11 +61,13 @@ def build_cache_dir():
|
|||||||
raise
|
raise
|
||||||
return ans
|
return ans
|
||||||
|
|
||||||
|
|
||||||
def require_git_master():
|
def require_git_master():
|
||||||
if subprocess.check_output(['git', 'symbolic-ref', '--short', 'HEAD']).strip() != 'master':
|
if subprocess.check_output(['git', 'symbolic-ref', '--short', 'HEAD']).strip() != 'master':
|
||||||
print >>sys.stderr, 'You must be in the master git branch'
|
print >>sys.stderr, 'You must be in the master git branch'
|
||||||
raise SystemExit(1)
|
raise SystemExit(1)
|
||||||
|
|
||||||
|
|
||||||
def require_clean_git():
|
def require_clean_git():
|
||||||
c = subprocess.check_call
|
c = subprocess.check_call
|
||||||
p = subprocess.Popen
|
p = subprocess.Popen
|
||||||
@ -70,6 +81,7 @@ def require_clean_git():
|
|||||||
print >>sys.stderr, 'Your git index contains uncommitted changes'
|
print >>sys.stderr, 'Your git index contains uncommitted changes'
|
||||||
raise SystemExit(1)
|
raise SystemExit(1)
|
||||||
|
|
||||||
|
|
||||||
def initialize_constants():
|
def initialize_constants():
|
||||||
global __version__, __appname__, modules, functions, basenames, scripts
|
global __version__, __appname__, modules, functions, basenames, scripts
|
||||||
|
|
||||||
@ -102,10 +114,12 @@ def initialize_constants():
|
|||||||
modules[x] = list(map(e2m, entry_points[y]))
|
modules[x] = list(map(e2m, entry_points[y]))
|
||||||
scripts[x] = list(map(e2s, entry_points[y]))
|
scripts[x] = list(map(e2s, entry_points[y]))
|
||||||
|
|
||||||
|
|
||||||
initialize_constants()
|
initialize_constants()
|
||||||
|
|
||||||
preferred_encoding = 'utf-8'
|
preferred_encoding = 'utf-8'
|
||||||
|
|
||||||
|
|
||||||
def prints(*args, **kwargs):
|
def prints(*args, **kwargs):
|
||||||
'''
|
'''
|
||||||
Print unicode arguments safely by encoding them to preferred_encoding
|
Print unicode arguments safely by encoding them to preferred_encoding
|
||||||
@ -144,11 +158,14 @@ def prints(*args, **kwargs):
|
|||||||
file.write(sep)
|
file.write(sep)
|
||||||
file.write(end)
|
file.write(end)
|
||||||
|
|
||||||
|
|
||||||
warnings = []
|
warnings = []
|
||||||
|
|
||||||
|
|
||||||
def get_warnings():
|
def get_warnings():
|
||||||
return list(warnings)
|
return list(warnings)
|
||||||
|
|
||||||
|
|
||||||
class Command(object):
|
class Command(object):
|
||||||
|
|
||||||
SRC = SRC
|
SRC = SRC
|
||||||
@ -252,6 +269,7 @@ class Command(object):
|
|||||||
warnings.append((args, kwargs))
|
warnings.append((args, kwargs))
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
|
|
||||||
def installer_name(ext, is64bit=False):
|
def installer_name(ext, is64bit=False):
|
||||||
if is64bit and ext == 'msi':
|
if is64bit and ext == 'msi':
|
||||||
return 'dist/%s-64bit-%s.msi'%(__appname__, __version__)
|
return 'dist/%s-64bit-%s.msi'%(__appname__, __version__)
|
||||||
@ -266,6 +284,3 @@ def installer_name(ext, is64bit=False):
|
|||||||
if is64bit:
|
if is64bit:
|
||||||
ans = ans.replace('i686', 'x86_64')
|
ans = ans.replace('i686', 'x86_64')
|
||||||
return ans
|
return ans
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,14 +8,15 @@ __copyright__ = '2012, Kovid Goyal <kovid at kovidgoyal.net>'
|
|||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
import os, shutil
|
import os, shutil
|
||||||
from urllib import urlretrieve
|
from io import BytesIO
|
||||||
from zipfile import ZipFile, ZIP_STORED, ZipInfo
|
from zipfile import ZipFile, ZIP_STORED, ZipInfo
|
||||||
from hashlib import sha1
|
from hashlib import sha1
|
||||||
from tempfile import mkdtemp, SpooledTemporaryFile
|
from tempfile import mkdtemp, SpooledTemporaryFile
|
||||||
is_ci = os.environ.get('CI', '').lower() == 'true'
|
is_ci = os.environ.get('CI', '').lower() == 'true'
|
||||||
|
|
||||||
|
|
||||||
from setup import Command
|
from setup import Command, download_securely
|
||||||
|
|
||||||
|
|
||||||
class MathJax(Command):
|
class MathJax(Command):
|
||||||
|
|
||||||
@ -29,8 +30,8 @@ class MathJax(Command):
|
|||||||
|
|
||||||
def download_mathjax_release(self, tdir, url):
|
def download_mathjax_release(self, tdir, url):
|
||||||
self.info('Downloading MathJax:', url)
|
self.info('Downloading MathJax:', url)
|
||||||
filename = urlretrieve(url)[0]
|
raw = download_securely(url)
|
||||||
with ZipFile(filename) as zf:
|
with ZipFile(BytesIO(raw)) as zf:
|
||||||
zf.extractall(tdir)
|
zf.extractall(tdir)
|
||||||
return os.path.join(tdir, 'MathJax-master')
|
return os.path.join(tdir, 'MathJax-master')
|
||||||
|
|
||||||
|
@ -6,12 +6,13 @@ __license__ = 'GPL v3'
|
|||||||
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
import os, cPickle, re, shutil, marshal, zipfile, glob, time, sys, hashlib, json, errno, subprocess
|
import os, cPickle, re, shutil, marshal, zipfile, glob, time, sys, hashlib, json, errno
|
||||||
from zlib import compress
|
from zlib import compress
|
||||||
from itertools import chain
|
from itertools import chain
|
||||||
is_ci = os.environ.get('CI', '').lower() == 'true'
|
is_ci = os.environ.get('CI', '').lower() == 'true'
|
||||||
|
|
||||||
from setup import Command, basenames, __appname__
|
from setup import Command, basenames, __appname__, download_securely
|
||||||
|
|
||||||
|
|
||||||
def get_opts_from_parser(parser):
|
def get_opts_from_parser(parser):
|
||||||
def do_opt(opt):
|
def do_opt(opt):
|
||||||
@ -27,11 +28,6 @@ def get_opts_from_parser(parser):
|
|||||||
for x in do_opt(o):
|
for x in do_opt(o):
|
||||||
yield x
|
yield x
|
||||||
|
|
||||||
def download_securely(url):
|
|
||||||
# We use curl here as on some OSes (OS X) when bootstrapping calibre,
|
|
||||||
# python will be unable to validate certificates until after cacerts is
|
|
||||||
# installed
|
|
||||||
return subprocess.check_output(['curl', '-fsSL', url])
|
|
||||||
|
|
||||||
class Coffee(Command): # {{{
|
class Coffee(Command): # {{{
|
||||||
|
|
||||||
@ -128,6 +124,7 @@ class Coffee(Command): # {{{
|
|||||||
os.remove(x)
|
os.remove(x)
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
class Kakasi(Command): # {{{
|
class Kakasi(Command): # {{{
|
||||||
|
|
||||||
description = 'Compile resources for unihandecode'
|
description = 'Compile resources for unihandecode'
|
||||||
@ -229,6 +226,7 @@ class Kakasi(Command): # {{{
|
|||||||
shutil.rmtree(kakasi)
|
shutil.rmtree(kakasi)
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
class CACerts(Command): # {{{
|
class CACerts(Command): # {{{
|
||||||
|
|
||||||
description = 'Get updated mozilla CA certificate bundle'
|
description = 'Get updated mozilla CA certificate bundle'
|
||||||
@ -256,6 +254,7 @@ class CACerts(Command): # {{{
|
|||||||
get_https_resource_securely('https://calibre-ebook.com', cacerts=self.b(self.CA_PATH))
|
get_https_resource_securely('https://calibre-ebook.com', cacerts=self.b(self.CA_PATH))
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
class RecentUAs(Command):
|
class RecentUAs(Command):
|
||||||
|
|
||||||
description = 'Get updated list of recent browser user agents'
|
description = 'Get updated list of recent browser user agents'
|
||||||
@ -291,6 +290,7 @@ class RecentUAs(Command):
|
|||||||
with open(self.UA_PATH, 'wb') as f:
|
with open(self.UA_PATH, 'wb') as f:
|
||||||
f.write('\n'.join(lines).encode('ascii'))
|
f.write('\n'.join(lines).encode('ascii'))
|
||||||
|
|
||||||
|
|
||||||
class RapydScript(Command): # {{{
|
class RapydScript(Command): # {{{
|
||||||
|
|
||||||
description = 'Compile RapydScript to JavaScript'
|
description = 'Compile RapydScript to JavaScript'
|
||||||
@ -300,6 +300,7 @@ class RapydScript(Command): # {{{
|
|||||||
compile_srv()
|
compile_srv()
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
class Resources(Command): # {{{
|
class Resources(Command): # {{{
|
||||||
|
|
||||||
description = 'Compile various needed calibre resources'
|
description = 'Compile various needed calibre resources'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user