mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Allow imports of top level PyQt modules to work from the qt virtual module
This is needed for legacy compat of from PyQt5 import QtCore, QtGui, etc
This commit is contained in:
parent
924625e047
commit
a78d3cd611
@ -0,0 +1,10 @@
|
||||
# autogenerated by __main__.py do not edit
|
||||
top_level_module_names=('QtCore', 'QtGui', 'QtWidgets', 'QtNetwork', 'QtSvg', 'QtPrintSupport', 'QtWebEngineCore', 'QtWebEngineWidgets')
|
||||
|
||||
def __getattr__(name):
|
||||
if name in top_level_module_names:
|
||||
import importlib
|
||||
return importlib.import_module("PyQt6." + name)
|
||||
raise AttributeError(name)
|
||||
|
||||
|
@ -53,5 +53,18 @@ def scan(name):
|
||||
print(')', file=f)
|
||||
|
||||
|
||||
top_level_module_names = ()
|
||||
for name in ('core', 'webengine'):
|
||||
top_level_module_names += module_lists[name]
|
||||
scan(name)
|
||||
with open(f'{base}/__init__.py', 'w') as f:
|
||||
print('# autogenerated by __main__.py do not edit', file=f)
|
||||
print(f'{top_level_module_names=}', file=f)
|
||||
print(f'''
|
||||
def __getattr__(name):
|
||||
if name in top_level_module_names:
|
||||
import importlib
|
||||
return importlib.import_module("{QT_WRAPPER}." + name)
|
||||
raise AttributeError(name)
|
||||
|
||||
''', file=f)
|
||||
|
Loading…
x
Reference in New Issue
Block a user