Merge branch 'py3-monotonic' of https://github.com/flaviut/calibre

This commit is contained in:
Kovid Goyal 2018-09-15 06:13:54 +05:30
commit 8aa1570608
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
4 changed files with 18 additions and 8 deletions

View File

@ -27,6 +27,7 @@ class Extension(object):
self.name = d['name'] = name self.name = d['name'] = name
self.sources = d['sources'] = absolutize(sources) self.sources = d['sources'] = absolutize(sources)
self.needs_cxx = d['needs_cxx'] = bool([1 for x in self.sources if os.path.splitext(x)[1] in ('.cpp', '.c++', '.cxx')]) self.needs_cxx = d['needs_cxx'] = bool([1 for x in self.sources if os.path.splitext(x)[1] in ('.cpp', '.c++', '.cxx')])
self.needs_py2 = d['needs_py2'] = kwargs.get('needs_py2', False)
self.headers = d['headers'] = absolutize(kwargs.get('headers', [])) self.headers = d['headers'] = absolutize(kwargs.get('headers', []))
self.sip_files = d['sip_files'] = absolutize(kwargs.get('sip_files', [])) self.sip_files = d['sip_files'] = absolutize(kwargs.get('sip_files', []))
self.inc_dirs = d['inc_dirs'] = absolutize(kwargs.get('inc_dirs', [])) self.inc_dirs = d['inc_dirs'] = absolutize(kwargs.get('inc_dirs', []))
@ -262,6 +263,8 @@ class Build(Command):
for ext in extensions: for ext in extensions:
if opts.only != 'all' and opts.only != ext.name: if opts.only != 'all' and opts.only != ext.name:
continue continue
if ext.needs_py2 and sys.version_info >= (3,):
continue
if ext.error: if ext.error:
if ext.optional: if ext.optional:
self.warn(ext.error) self.warn(ext.error)

View File

@ -10,7 +10,8 @@
{ {
"name": "monotonic", "name": "monotonic",
"sources": "calibre/utils/monotonic.c", "sources": "calibre/utils/monotonic.c",
"linux_libraries": "rt" "linux_libraries": "rt",
"needs_py2": true
}, },
{ {
"name": "unicode_names", "name": "unicode_names",

View File

@ -168,7 +168,6 @@ class Plugins(collections.Mapping):
'chm_extra', 'chm_extra',
'icu', 'icu',
'speedup', 'speedup',
'monotonic',
'unicode_names', 'unicode_names',
'zlib2', 'zlib2',
'html', 'html',
@ -183,6 +182,10 @@ class Plugins(collections.Mapping):
'certgen', 'certgen',
'lzma_binding', 'lzma_binding',
] ]
if not ispy3:
plugins.extend([
'monotonic',
])
if iswindows: if iswindows:
plugins.extend(['winutil', 'wpd', 'winfonts']) plugins.extend(['winutil', 'wpd', 'winfonts'])
if isosx: if isosx:

View File

@ -1,9 +1,12 @@
# vim:fileencoding=utf-8 # vim:fileencoding=utf-8
from calibre.constants import plugins try:
from time import monotonic
except ImportError:
from calibre.constants import plugins
monotonicp, err = plugins['monotonic'] monotonicp, err = plugins['monotonic']
if err: if err:
raise RuntimeError('Failed to load the monotonic module with error: ' + err) raise RuntimeError('Failed to load the monotonic module with error: ' + err)
monotonic = monotonicp.monotonic monotonic = monotonicp.monotonic
del monotonicp, err del monotonicp, err