mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Only take the performance hit of banning PyQt4 imports on non frozen calibre installs
This commit is contained in:
parent
b3b7918e5a
commit
8a758b9c82
@ -16,7 +16,7 @@ __builtin__.__dict__['_'] = lambda s: s
|
|||||||
# immediately translated to the environment language
|
# immediately translated to the environment language
|
||||||
__builtin__.__dict__['__'] = lambda s: s
|
__builtin__.__dict__['__'] = lambda s: s
|
||||||
|
|
||||||
from calibre.constants import iswindows, preferred_encoding, plugins, isosx, islinux
|
from calibre.constants import iswindows, preferred_encoding, plugins, isosx, islinux, isfrozen
|
||||||
|
|
||||||
_run_once = False
|
_run_once = False
|
||||||
winutil = winutilerror = None
|
winutil = winutilerror = None
|
||||||
@ -24,17 +24,18 @@ winutil = winutilerror = None
|
|||||||
if not _run_once:
|
if not _run_once:
|
||||||
_run_once = True
|
_run_once = True
|
||||||
|
|
||||||
# Prevent PyQt4 from being loaded
|
if not isfrozen:
|
||||||
class PyQt4Ban(object):
|
# Prevent PyQt4 from being loaded
|
||||||
|
class PyQt4Ban(object):
|
||||||
|
|
||||||
def find_module(self, fullname, path=None):
|
def find_module(self, fullname, path=None):
|
||||||
if fullname.startswith('PyQt4'):
|
if fullname.startswith('PyQt4'):
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def load_module(self, fullname):
|
def load_module(self, fullname):
|
||||||
raise ImportError('Importing PyQt4 is not allowed as calibre uses PyQt5')
|
raise ImportError('Importing PyQt4 is not allowed as calibre uses PyQt5')
|
||||||
|
|
||||||
sys.meta_path.insert(0, PyQt4Ban())
|
sys.meta_path.insert(0, PyQt4Ban())
|
||||||
|
|
||||||
#
|
#
|
||||||
# Platform specific modules
|
# Platform specific modules
|
||||||
|
Loading…
x
Reference in New Issue
Block a user