aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/PySide6/__init__.py.in
diff options
context:
space:
mode:
Diffstat (limited to 'sources/pyside6/PySide6/__init__.py.in')
-rw-r--r--sources/pyside6/PySide6/__init__.py.in57
1 files changed, 35 insertions, 22 deletions
diff --git a/sources/pyside6/PySide6/__init__.py.in b/sources/pyside6/PySide6/__init__.py.in
index 631cfc1ce..d0a4ecc37 100644
--- a/sources/pyside6/PySide6/__init__.py.in
+++ b/sources/pyside6/PySide6/__init__.py.in
@@ -3,6 +3,7 @@ import sys
from pathlib import Path
from textwrap import dedent
+# __all__ is also corrected below.
__all__ = list("Qt" + body for body in
"@all_module_shortnames@"
.split(";"))
@@ -23,8 +24,11 @@ def _additional_dll_directories(package_dir):
# is executed in the build directory. We need libpyside and Qt in addition.
shiboken6 = Path(root).parent / 'shiboken6' / 'libshiboken'
if not shiboken6.is_dir():
- raise ImportError(shiboken6 + ' does not exist')
+ raise ImportError(str(shiboken6) + ' does not exist')
result = [shiboken6, root / 'libpyside']
+ libpysideqml = root / 'libpysideqml'
+ if libpysideqml.is_dir():
+ result.append(libpysideqml)
for path in os.environ.get('PATH').split(';'):
if path:
if (Path(path) / 'qmake.exe').exists():
@@ -52,7 +56,7 @@ def _setupQtDirectories():
if sys.platform == 'win32' and sys.version_info[0] == 3 and sys.version_info[1] >= 8:
for dir in _additional_dll_directories(pyside_package_dir):
- os.add_dll_directory(dir)
+ os.add_dll_directory(os.fspath(dir))
try:
# PYSIDE-1497: we use the build dir or install dir or site-packages, whatever the path
@@ -64,26 +68,6 @@ def _setupQtDirectories():
file=sys.stderr)
raise
- # Trigger signature initialization.
- try:
- # PYSIDE-829: Avoid non-existent attributes in compiled code (Nuitka).
- # We now use an explicit function instead of touching a signature.
- _init_pyside_extension()
- except (AttributeError, NameError):
- stars = 79 * "*"
- fname = Shiboken.__file__
- print(dedent(f'''\
- {stars}
- PySide6/__init__.py: The `signature` module was not initialized.
- This libshiboken module was loaded from
-
- "{fname}".
-
- Please make sure that this is the real Shiboken binary and not just a folder.
- {stars}
- '''), file=sys.stderr)
- raise
-
if sys.platform == 'win32':
# PATH has to contain the package directory, otherwise plugins
# won't be able to find their required Qt libraries (e.g. the
@@ -108,4 +92,33 @@ def _setupQtDirectories():
finally:
os.environ['PATH'] = path
+
+def _find_all_qt_modules():
+ # Since the wheel split, the __all__ variable cannot be computed statically,
+ # because we don't know all modules in advance.
+
+ # Instead, we look into the file system and quickly build a list of all
+ # existing .pyi files, because importing is not desired and also impossible during import.
+ # By using the initially created list, we can keep some order intact.
+ location = Path(__file__).resolve().parent
+
+ # Note: We should _not_ call this function while still building, but use the existing value!
+ in_build = Path("@CMAKE_BINARY_DIR@") in location.parents
+
+ if in_build:
+ return __all__
+
+ files = os.listdir(location)
+ unordered = set(name[:-4] for name in files if name.startswith("Qt") and name.endswith(".pyi"))
+ ordered_part = __all__
+ result = []
+ for name in ordered_part:
+ if name in unordered:
+ result.append(name)
+ unordered.remove(name)
+ result.extend(unordered)
+ return result
+
+
+__all__ = _find_all_qt_modules()
_setupQtDirectories()