aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2021-01-21 19:06:38 +0100
committerChristian Tismer <tismer@stackless.com>2021-02-06 18:20:16 +0100
commit1e501c49bfa0832fd4a36903bc88a20f88565cf7 (patch)
tree243a6acb644385371c5fe4c38f3ea84139811e40 /sources/pyside6
parent408ccdeccf82d114656a3f85d5fe80a5e3dd3c69 (diff)
move "shiboken6/shiboken6" to "shiboken6/Shiboken"
Modifying the paths to work in the new way is a quite ambitious task. But doing so improves the overall project structure and makes imports unambiguous. This patch should not be applied alone but with move "shiboken6/shiboken6" to "shiboken6/Shiboken" temp The reworked version of this patch no longer has different structures in `build` and `install`. Tested with Python 3.6, 3.7, 3.8, 3.9 debug build Python 3.6 debug install Python 3.9 release install Task-number: PYSIDE-1497 Change-Id: Id9d816dd825907f9359651e7e2f69f54e1ba46c9 Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/pyside6')
-rw-r--r--sources/pyside6/PySide6/__init__.py.in13
-rw-r--r--sources/pyside6/PySide6/support/__init__.py2
-rw-r--r--sources/pyside6/PySide6/support/generate_pyi.py2
-rw-r--r--sources/pyside6/cmake/Macros/PySideModules.cmake2
-rw-r--r--sources/pyside6/tests/QtQml/listproperty.py6
-rw-r--r--sources/pyside6/tests/QtWidgets/qlabel_test.py8
-rw-r--r--sources/pyside6/tests/QtWidgets/qstandarditemmodel_test.py5
-rw-r--r--sources/pyside6/tests/registry/init_platform.py6
-rw-r--r--sources/pyside6/tests/support/voidptr_test.py4
9 files changed, 26 insertions, 22 deletions
diff --git a/sources/pyside6/PySide6/__init__.py.in b/sources/pyside6/PySide6/__init__.py.in
index 9b86c1830..a0b9699f2 100644
--- a/sources/pyside6/PySide6/__init__.py.in
+++ b/sources/pyside6/PySide6/__init__.py.in
@@ -54,10 +54,12 @@ def _setupQtDirectories():
os.add_dll_directory(dir)
try:
- import shiboken6
+ # PYSIDE-1497: we use the build dir or install dir or site-packages, whatever the path
+ # setting dictates. There is no longer a difference in path structure.
+ from shiboken6 import Shiboken
except Exception:
paths = ', '.join(sys.path)
- print(f"PySide6/__init__.py: Unable to import shiboken6 from {paths}",
+ print(f"PySide6/__init__.py: Unable to import Shiboken from {paths}",
file=sys.stderr)
raise
@@ -66,16 +68,17 @@ def _setupQtDirectories():
# 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:
+ 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
- "{shiboken6.__file__}".
+ "{fname}".
- Please make sure that this is the real shiboken6 binary and not just a folder.
+ Please make sure that this is the real Shiboken binary and not just a folder.
{stars}
'''), file=sys.stderr)
raise
diff --git a/sources/pyside6/PySide6/support/__init__.py b/sources/pyside6/PySide6/support/__init__.py
index 996acb05a..7d8c808aa 100644
--- a/sources/pyside6/PySide6/support/__init__.py
+++ b/sources/pyside6/PySide6/support/__init__.py
@@ -37,6 +37,6 @@
##
#############################################################################
-from shiboken6 import VoidPtr
+from shiboken6.Shiboken import VoidPtr
#eof
diff --git a/sources/pyside6/PySide6/support/generate_pyi.py b/sources/pyside6/PySide6/support/generate_pyi.py
index 32f43d804..8abab35f0 100644
--- a/sources/pyside6/PySide6/support/generate_pyi.py
+++ b/sources/pyside6/PySide6/support/generate_pyi.py
@@ -145,7 +145,7 @@ class Formatter(Writer):
self.print()
self.print("class Object(object): pass")
self.print()
- self.print("import shiboken6 as Shiboken")
+ self.print("from shiboken6 import Shiboken")
self.print("Shiboken.Object = Object")
self.print()
# This line will be replaced by the missing imports postprocess.
diff --git a/sources/pyside6/cmake/Macros/PySideModules.cmake b/sources/pyside6/cmake/Macros/PySideModules.cmake
index a3bab2164..96fa33a99 100644
--- a/sources/pyside6/cmake/Macros/PySideModules.cmake
+++ b/sources/pyside6/cmake/Macros/PySideModules.cmake
@@ -198,7 +198,7 @@ macro(create_pyside_module)
endif()
set(generate_pyi_options ${module_NAME} --sys-path
"${pysidebindings_BINARY_DIR}"
- "${SHIBOKEN_PYTHON_MODULE_DIR}")
+ "${SHIBOKEN_PYTHON_MODULE_DIR}/..") # use the layer above shiboken6
if (QUIET_BUILD)
list(APPEND generate_pyi_options "--quiet")
endif()
diff --git a/sources/pyside6/tests/QtQml/listproperty.py b/sources/pyside6/tests/QtQml/listproperty.py
index d250b8b3e..ed0705e47 100644
--- a/sources/pyside6/tests/QtQml/listproperty.py
+++ b/sources/pyside6/tests/QtQml/listproperty.py
@@ -26,8 +26,14 @@
##
#############################################################################
+import os
+import sys
import unittest
+sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+from init_paths import init_test_paths
+init_test_paths(False)
+
from PySide6.QtCore import QObject
from PySide6.QtQml import ListProperty
diff --git a/sources/pyside6/tests/QtWidgets/qlabel_test.py b/sources/pyside6/tests/QtWidgets/qlabel_test.py
index bb8d39bcf..b24c08690 100644
--- a/sources/pyside6/tests/QtWidgets/qlabel_test.py
+++ b/sources/pyside6/tests/QtWidgets/qlabel_test.py
@@ -38,7 +38,7 @@ init_test_paths(True)
from PySide6.QtGui import QPixmap
from PySide6.QtWidgets import QLabel
-import shiboken6 as shiboken
+from shiboken6 import Shiboken
from helper.usesqapplication import UsesQApplication
@@ -72,7 +72,7 @@ class QLabelTest(UsesQApplication):
ret_p = self.label.pixmap()
self.assertIsNot(p1, ret_p)
# Save the address of the pointer
- ret_p_addr = shiboken.getCppPointer(ret_p)
+ ret_p_addr = Shiboken.getCppPointer(ret_p)
# Remove the QPixmap
del ret_p
# Set new QPixmap
@@ -81,8 +81,8 @@ class QLabelTest(UsesQApplication):
# There should be no pointers remaining with the same
# address that our QPixmap p1 because it was deleted
# using `del ret_p`
- self.assertTrue(all(shiboken.getCppPointer(o) != ret_p_addr
- for o in shiboken.getAllValidWrappers()))
+ self.assertTrue(all(Shiboken.getCppPointer(o) != ret_p_addr
+ for o in Shiboken.getAllValidWrappers()))
if __name__ == '__main__':
unittest.main()
diff --git a/sources/pyside6/tests/QtWidgets/qstandarditemmodel_test.py b/sources/pyside6/tests/QtWidgets/qstandarditemmodel_test.py
index b252982e0..caf945725 100644
--- a/sources/pyside6/tests/QtWidgets/qstandarditemmodel_test.py
+++ b/sources/pyside6/tests/QtWidgets/qstandarditemmodel_test.py
@@ -36,8 +36,7 @@ init_test_paths(False)
from PySide6.QtGui import QStandardItemModel, QStandardItem
from PySide6.QtWidgets import QWidget
-import shiboken6 as shiboken
-
+from shiboken6 import Shiboken
from helper.usesqapplication import UsesQApplication
@@ -62,7 +61,7 @@ class QStandardItemModelTest(UsesQApplication):
model = QStandardItemModel()
root = model.invisibleRootItem()
model.clear()
- self.assertFalse(shiboken.isValid(root))
+ self.assertFalse(Shiboken.isValid(root))
class QStandardItemModelRef(UsesQApplication):
diff --git a/sources/pyside6/tests/registry/init_platform.py b/sources/pyside6/tests/registry/init_platform.py
index 90a7a21a8..bab75272b 100644
--- a/sources/pyside6/tests/registry/init_platform.py
+++ b/sources/pyside6/tests/registry/init_platform.py
@@ -120,8 +120,6 @@ def set_ospaths(build_dir):
os.environ[ospath_var] = ospath
set_ospaths(all_build_dir)
-sys.path[:0] = [os.path.join(shiboken_build_dir, "shibokenmodule"),
- pyside_build_dir]
import PySide6
@@ -134,9 +132,7 @@ import testbinding
all_modules.append("testbinding")
# Note: This is not the shiboken dir as usual, but the binary.
-import shiboken6 as Shiboken
-Shiboken.__name__ = "Shiboken"
-sys.modules["Shiboken"] = sys.modules.pop("shiboken6")
+from shiboken6 import Shiboken
all_modules.append("Shiboken")
# 'sample/smart' are needed by 'other', so import them first.
diff --git a/sources/pyside6/tests/support/voidptr_test.py b/sources/pyside6/tests/support/voidptr_test.py
index d56f29b68..75692eb84 100644
--- a/sources/pyside6/tests/support/voidptr_test.py
+++ b/sources/pyside6/tests/support/voidptr_test.py
@@ -34,7 +34,7 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from init_paths import init_test_paths
init_test_paths(False)
-import shiboken6 as shiboken
+from shiboken6 import Shiboken
from PySide6.support import VoidPtr
from PySide6.QtCore import QByteArray
@@ -50,7 +50,7 @@ class PySide6Support(unittest.TestCase):
b = b"Hello world"
ba = QByteArray(b)
vp = VoidPtr(ba, ba.size())
- self.assertIsInstance(vp, shiboken.VoidPtr)
+ self.assertIsInstance(vp, Shiboken.VoidPtr)
# Create QByteArray from voidptr byte interpretation
nba = QByteArray(vp.toBytes())