Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
aboutsummaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--build_history/blacklist.txt3
-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
-rw-r--r--sources/shiboken6/libshiboken/embed/signature_bootstrap.py9
-rw-r--r--sources/shiboken6/libshiboken/sbkenum.cpp15
-rw-r--r--sources/shiboken6/shibokenmodule/CMakeLists.txt13
-rw-r--r--sources/shiboken6/shibokenmodule/__init__.py.in2
-rw-r--r--sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/mapping.py3
-rw-r--r--sources/shiboken6/shibokenmodule/typesystem_shiboken.xml2
-rw-r--r--sources/shiboken6/tests/minimalbinding/brace_pattern_test.py2
-rw-r--r--sources/shiboken6/tests/otherbinding/objtypehashes_test.py4
-rw-r--r--sources/shiboken6/tests/samplebinding/delete_test.py7
-rw-r--r--sources/shiboken6/tests/samplebinding/objecttype_test.py8
-rw-r--r--sources/shiboken6/tests/samplebinding/privatedtor_test.py4
-rw-r--r--sources/shiboken6/tests/samplebinding/voidholder_test.py4
-rw-r--r--sources/shiboken6/tests/shiboken_paths.py2
-rw-r--r--sources/shiboken6/tests/shibokenmodule/module_test.py62
24 files changed, 88 insertions, 100 deletions
diff --git a/build_history/blacklist.txt b/build_history/blacklist.txt
index 16ad36401..24dee4c2f 100644
--- a/build_history/blacklist.txt
+++ b/build_history/blacklist.txt
@@ -33,9 +33,6 @@
linux
darwin
win32
-[QtWidgets::qstandarditemmodel_test]
- py2
- py3
[QtTest::touchevent_test]
linux
darwin
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())
diff --git a/sources/shiboken6/libshiboken/embed/signature_bootstrap.py b/sources/shiboken6/libshiboken/embed/signature_bootstrap.py
index 287d349b4..548d130af 100644
--- a/sources/shiboken6/libshiboken/embed/signature_bootstrap.py
+++ b/sources/shiboken6/libshiboken/embed/signature_bootstrap.py
@@ -100,12 +100,9 @@ def bootstrap():
sys.exit(-1)
sys.path.remove(support_path)
- try:
- import shiboken6 as root
- except ImportError:
- # uninstalled case without ctest, try only this one which has __init__:
- import shibokenmodule as root
- rp = os.path.realpath(os.path.dirname(root.__file__))
+ import shiboken6 as root
+ path = root.__file__
+ rp = os.path.realpath(os.path.dirname(path))
# This can be the shiboken6 directory or the binary module, so search.
look_for = os.path.join("files.dir", "shibokensupport", "signature", "loader.py")
while not os.path.exists(os.path.join(rp, look_for)):
diff --git a/sources/shiboken6/libshiboken/sbkenum.cpp b/sources/shiboken6/libshiboken/sbkenum.cpp
index 280bcd510..a2e6401ca 100644
--- a/sources/shiboken6/libshiboken/sbkenum.cpp
+++ b/sources/shiboken6/libshiboken/sbkenum.cpp
@@ -390,19 +390,8 @@ extern "C" {
// Initialization
static bool _init_enum()
{
- static PyObject *shiboken_name = Py_BuildValue("s", "shiboken6");
- if (shiboken_name == nullptr)
- return false;
- Shiboken::AutoDecRef shibo(PyImport_GetModule(shiboken_name));
- if (shibo.isNull())
- return false;
- Shiboken::AutoDecRef sub(PyObject_GetAttr(shibo, shiboken_name));
- PyObject *mod = sub.object();
- if (mod == nullptr) {
- // We are in the build dir and already in shiboken.
- PyErr_Clear();
- mod = shibo.object();
- }
+ Shiboken::AutoDecRef shibo(PyImport_ImportModule("shiboken6.Shiboken"));
+ auto mod = shibo.object();
// publish Shiboken.Enum so that the signature gets initialized
if (PyObject_SetAttrString(mod, "Enum", reinterpret_cast<PyObject *>(SbkEnum_TypeF())) < 0)
return false;
diff --git a/sources/shiboken6/shibokenmodule/CMakeLists.txt b/sources/shiboken6/shibokenmodule/CMakeLists.txt
index e6944e942..09d85ab14 100644
--- a/sources/shiboken6/shibokenmodule/CMakeLists.txt
+++ b/sources/shiboken6/shibokenmodule/CMakeLists.txt
@@ -3,7 +3,7 @@ project(shibokenmodule)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/shibokenmodule.txt.in"
"${CMAKE_CURRENT_BINARY_DIR}/shibokenmodule.txt" @ONLY)
-set(sample_SRC ${CMAKE_CURRENT_BINARY_DIR}/shiboken6/shiboken6_module_wrapper.cpp)
+set(sample_SRC ${CMAKE_CURRENT_BINARY_DIR}/Shiboken/shiboken_module_wrapper.cpp)
set(shibokenmodule_TYPESYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_shiboken.xml)
@@ -16,14 +16,15 @@ BYPRODUCTS ${sample_SRC}
COMMAND shiboken6 --project-file=${CMAKE_CURRENT_BINARY_DIR}/shibokenmodule.txt ${GENERATOR_EXTRA_FLAGS}
DEPENDS ${shibokenmodule_TYPESYSTEM}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
-COMMENT "Running generator for 'shiboken6'..."
+COMMENT "Running generator for 'Shiboken'..."
)
add_library(shibokenmodule MODULE ${sample_SRC})
target_include_directories(shibokenmodule PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_SOURCE_DIR})
set_property(TARGET shibokenmodule PROPERTY PREFIX "")
-set_property(TARGET shibokenmodule PROPERTY OUTPUT_NAME "shiboken6${PYTHON_EXTENSION_SUFFIX}")
+# PYSIDE-1497: This `..` is the crucial trick to unify the path location of `Shiboken`.
+set_property(TARGET shibokenmodule PROPERTY OUTPUT_NAME "../Shiboken${PYTHON_EXTENSION_SUFFIX}")
if(WIN32)
set_property(TARGET shibokenmodule PROPERTY SUFFIX ".pyd")
@@ -39,8 +40,9 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/_config.py.in"
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/_config.py"
DESTINATION "${PYTHON_SITE_PACKAGES}/shiboken6")
+# PYSIDE-1497: This `..` is the crucial trick to unify the path location of `Shiboken`.
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/__init__.py.in"
- "${CMAKE_CURRENT_BINARY_DIR}/__init__.py" @ONLY)
+ "${CMAKE_CURRENT_BINARY_DIR}/../__init__.py" @ONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/files.dir/shibokensupport/__feature__.py"
"${CMAKE_CURRENT_BINARY_DIR}/files.dir/shibokensupport/__feature__.py" COPYONLY)
@@ -70,7 +72,8 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/files.dir/shibokensupport/signature/
install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/files.dir"
DESTINATION "${PYTHON_SITE_PACKAGES}/shiboken6")
-install(FILES "${CMAKE_CURRENT_BINARY_DIR}/__init__.py"
+# PYSIDE-1497: This `..` is the crucial trick to unify the path location of `Shiboken`.
+install(FILES "${CMAKE_CURRENT_BINARY_DIR}/../__init__.py"
DESTINATION "${PYTHON_SITE_PACKAGES}/shiboken6")
# Use absolute path instead of relative path, to avoid ninja build errors due to
diff --git a/sources/shiboken6/shibokenmodule/__init__.py.in b/sources/shiboken6/shibokenmodule/__init__.py.in
index e4e978299..3dd59b024 100644
--- a/sources/shiboken6/shibokenmodule/__init__.py.in
+++ b/sources/shiboken6/shibokenmodule/__init__.py.in
@@ -22,7 +22,7 @@ import keyword
import functools
import typing
-from .shiboken6 import *
+from shiboken6.Shiboken import *
# Trigger signature initialization via __builtins__.
_init_pyside_extension()
diff --git a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/mapping.py b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/mapping.py
index 633455829..f3fbd8814 100644
--- a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/mapping.py
+++ b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/mapping.py
@@ -362,9 +362,6 @@ def init_Shiboken():
})
return locals()
-# side effect of different shiboken namings
-init_shiboken6 = init_shiboken6_shiboken6 = init_Shiboken
-
def init_minimal():
type_map.update({
"MinBool": bool,
diff --git a/sources/shiboken6/shibokenmodule/typesystem_shiboken.xml b/sources/shiboken6/shibokenmodule/typesystem_shiboken.xml
index 361db53cf..ca6f497d5 100644
--- a/sources/shiboken6/shibokenmodule/typesystem_shiboken.xml
+++ b/sources/shiboken6/shibokenmodule/typesystem_shiboken.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" ?>
-<typesystem package="shiboken6">
+<typesystem package="Shiboken">
<custom-type name="PyObject" />
<custom-type name="PyType" />
<primitive-type name="bool" />
diff --git a/sources/shiboken6/tests/minimalbinding/brace_pattern_test.py b/sources/shiboken6/tests/minimalbinding/brace_pattern_test.py
index 8fc6aabed..0d21ab983 100644
--- a/sources/shiboken6/tests/minimalbinding/brace_pattern_test.py
+++ b/sources/shiboken6/tests/minimalbinding/brace_pattern_test.py
@@ -46,7 +46,7 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from shiboken_paths import init_paths
init_paths()
-import shiboken6
+from shiboken6 import Shiboken
_init_pyside_extension() # trigger bootstrap
from shibokensupport.signature.lib.tool import build_brace_pattern
diff --git a/sources/shiboken6/tests/otherbinding/objtypehashes_test.py b/sources/shiboken6/tests/otherbinding/objtypehashes_test.py
index dc3ae1eb0..a0bb88618 100644
--- a/sources/shiboken6/tests/otherbinding/objtypehashes_test.py
+++ b/sources/shiboken6/tests/otherbinding/objtypehashes_test.py
@@ -35,7 +35,7 @@ from shiboken_paths import init_paths
init_paths()
from sample import *
from other import *
-import shiboken6 as shiboken
+from shiboken6 import Shiboken
class TestHashFuncs (unittest.TestCase):
@@ -48,7 +48,7 @@ class TestHashFuncs (unittest.TestCase):
self.assertNotEqual(hash1, hash2)
# Now invalidate the object and test its hash. It shouldn't segfault.
- shiboken.invalidate(obj1)
+ Shiboken.invalidate(obj1)
hash1_2 = hash(obj1)
self.assertEqual(hash1_2, hash1)
diff --git a/sources/shiboken6/tests/samplebinding/delete_test.py b/sources/shiboken6/tests/samplebinding/delete_test.py
index 1da66f821..1e6f9b4bc 100644
--- a/sources/shiboken6/tests/samplebinding/delete_test.py
+++ b/sources/shiboken6/tests/samplebinding/delete_test.py
@@ -36,8 +36,9 @@ import unittest
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from shiboken_paths import init_paths
init_paths()
+
import sample
-import shiboken6 as shiboken
+from shiboken6 import Shiboken
class DeleteTest(unittest.TestCase):
def testNonCppWrapperClassDelete(self):
@@ -45,8 +46,8 @@ class DeleteTest(unittest.TestCase):
Python """
obj = sample.ObjectType()
child = obj.createChild(None)
- shiboken.delete(child)
- assert not shiboken.isValid(child)
+ Shiboken.delete(child)
+ assert not Shiboken.isValid(child)
if __name__ == '__main__':
unittest.main()
diff --git a/sources/shiboken6/tests/samplebinding/objecttype_test.py b/sources/shiboken6/tests/samplebinding/objecttype_test.py
index 277606e45..b56112858 100644
--- a/sources/shiboken6/tests/samplebinding/objecttype_test.py
+++ b/sources/shiboken6/tests/samplebinding/objecttype_test.py
@@ -41,7 +41,7 @@ init_paths()
import sys
from sample import ObjectType, Str
-import shiboken6 as shiboken
+from shiboken6 import Shiboken
class ObjectTypeTest(unittest.TestCase):
@@ -95,7 +95,7 @@ class ObjectTypeTest(unittest.TestCase):
child = ObjectType(parent)
next_focus = child.nextInFocusChain()
- shiboken.invalidate(parent)
+ Shiboken.invalidate(parent)
def testNextInFocusChainCycleList(self):
'''As above but in for a list of objects'''
@@ -110,7 +110,7 @@ class ObjectTypeTest(unittest.TestCase):
children.append(child)
focus_chains.append(next_focus)
- shiboken.invalidate(parents)
+ Shiboken.invalidate(parents)
def testClassDecref(self):
# Bug was that class PyTypeObject wasn't decrefed when instance died
@@ -118,7 +118,7 @@ class ObjectTypeTest(unittest.TestCase):
for i in range(1000):
obj = ObjectType()
- shiboken.delete(obj)
+ Shiboken.delete(obj)
after = sys.getrefcount(ObjectType)
diff --git a/sources/shiboken6/tests/samplebinding/privatedtor_test.py b/sources/shiboken6/tests/samplebinding/privatedtor_test.py
index 532555686..3689ff720 100644
--- a/sources/shiboken6/tests/samplebinding/privatedtor_test.py
+++ b/sources/shiboken6/tests/samplebinding/privatedtor_test.py
@@ -40,7 +40,7 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from shiboken_paths import init_paths
init_paths()
-import shiboken6 as shiboken
+from shiboken6 import Shiboken
from sample import PrivateDtor
@@ -93,7 +93,7 @@ class PrivateDtorTest(unittest.TestCase):
for i in range(1000):
obj = PrivateDtor.instance()
- shiboken.invalidate(obj)
+ Shiboken.invalidate(obj)
after = sys.getrefcount(PrivateDtor)
diff --git a/sources/shiboken6/tests/samplebinding/voidholder_test.py b/sources/shiboken6/tests/samplebinding/voidholder_test.py
index 4099d39a4..f3d1f312b 100644
--- a/sources/shiboken6/tests/samplebinding/voidholder_test.py
+++ b/sources/shiboken6/tests/samplebinding/voidholder_test.py
@@ -40,7 +40,7 @@ from shiboken_paths import init_paths
init_paths()
from sample import VoidHolder, Point
-import shiboken6 as shiboken
+from shiboken6 import Shiboken
class VoidHolderTest(unittest.TestCase):
'''Test case for void pointer manipulation.'''
@@ -62,7 +62,7 @@ class VoidHolderTest(unittest.TestCase):
'''Passes a C++ pointer for an object created in Python to be kept by VoidHolder.'''
obj = Point(1, 2)
voidholder = VoidHolder(obj)
- self.assertEqual(shiboken.getCppPointer(obj)[0], int(voidholder.voidPointer()))
+ self.assertEqual(Shiboken.getCppPointer(obj)[0], int(voidholder.voidPointer()))
def testGetNoneObjectFromVoidHolder(self):
'''A VoidHolder created without parameters returns a NULL pointer
diff --git a/sources/shiboken6/tests/shiboken_paths.py b/sources/shiboken6/tests/shiboken_paths.py
index 29535f1b0..50d98358e 100644
--- a/sources/shiboken6/tests/shiboken_paths.py
+++ b/sources/shiboken6/tests/shiboken_paths.py
@@ -108,8 +108,8 @@ def shiboken_paths(include_shiboken_tests=False):
python_dirs = []
if include_shiboken_tests:
python_dirs.append(src_dir) # For shiboken_test_helper
+ python_dirs.append(get_build_dir()) # for toplevel shiboken6 import
shiboken_dir = os.path.join(get_build_dir(), 'shiboken6')
- python_dirs.append(os.path.join(shiboken_dir, 'shibokenmodule'))
lib_dirs = [os.path.join(shiboken_dir, 'libshiboken')]
if include_shiboken_tests:
shiboken_test_dir = os.path.join(shiboken_dir, 'tests')
diff --git a/sources/shiboken6/tests/shibokenmodule/module_test.py b/sources/shiboken6/tests/shibokenmodule/module_test.py
index 0bbfb282a..da4e8c80f 100644
--- a/sources/shiboken6/tests/shibokenmodule/module_test.py
+++ b/sources/shiboken6/tests/shibokenmodule/module_test.py
@@ -34,7 +34,7 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from shiboken_paths import init_paths
init_paths()
-import shiboken6 as shiboken
+from shiboken6 import Shiboken
from sample import *
class MultipleInherited (ObjectType, Point):
@@ -44,35 +44,35 @@ class MultipleInherited (ObjectType, Point):
class TestShiboken(unittest.TestCase):
def testIsValid(self):
- self.assertTrue(shiboken.isValid(object()))
- self.assertTrue(shiboken.isValid(None))
+ self.assertTrue(Shiboken.isValid(object()))
+ self.assertTrue(Shiboken.isValid(None))
bb = BlackBox()
item = ObjectType()
ticket = bb.keepObjectType(item)
bb.disposeObjectType(ticket)
- self.assertFalse(shiboken.isValid(item))
+ self.assertFalse(Shiboken.isValid(item))
def testWrapInstance(self):
addr = ObjectType.createObjectType()
- obj = shiboken.wrapInstance(addr, ObjectType)
- self.assertFalse(shiboken.createdByPython(obj))
+ obj = Shiboken.wrapInstance(addr, ObjectType)
+ self.assertFalse(Shiboken.createdByPython(obj))
obj.setObjectName("obj")
self.assertEqual(obj.objectName(), "obj")
self.assertEqual(addr, obj.identifier())
- self.assertFalse(shiboken.createdByPython(obj))
+ self.assertFalse(Shiboken.createdByPython(obj))
# avoid mem leak =]
bb = BlackBox()
- self.assertTrue(shiboken.createdByPython(bb))
+ self.assertTrue(Shiboken.createdByPython(bb))
bb.disposeObjectType(bb.keepObjectType(obj))
def testIsOwnedByPython(self):
obj = ObjectType()
- self.assertTrue(shiboken.ownedByPython(obj))
+ self.assertTrue(Shiboken.ownedByPython(obj))
p = ObjectType()
obj.setParent(p)
- self.assertFalse(shiboken.ownedByPython(obj))
+ self.assertFalse(Shiboken.ownedByPython(obj))
def testDump(self):
"""Just check if dump doesn't crash on certain use cases"""
@@ -80,44 +80,44 @@ class TestShiboken(unittest.TestCase):
obj = ObjectType(p)
obj2 = ObjectType(obj)
obj3 = ObjectType(obj)
- self.assertEqual(shiboken.dump(None), "Ordinary Python type.")
- shiboken.dump(obj)
+ self.assertEqual(Shiboken.dump(None), "Ordinary Python type.")
+ Shiboken.dump(obj)
model = ObjectModel(p)
v = ObjectView(model, p)
- shiboken.dump(v)
+ Shiboken.dump(v)
m = MultipleInherited()
- shiboken.dump(m)
- self.assertEqual(len(shiboken.getCppPointer(m)), 2)
+ Shiboken.dump(m)
+ self.assertEqual(len(Shiboken.getCppPointer(m)), 2)
# Don't crash even after deleting an object
- shiboken.invalidate(obj)
- shiboken.dump(obj) # deleted
- shiboken.dump(p) # child deleted
- shiboken.dump(obj2) # parent deleted
+ Shiboken.invalidate(obj)
+ Shiboken.dump(obj) # deleted
+ Shiboken.dump(p) # child deleted
+ Shiboken.dump(obj2) # parent deleted
def testDelete(self):
obj = ObjectType()
child = ObjectType(obj)
- self.assertTrue(shiboken.isValid(obj))
- self.assertTrue(shiboken.isValid(child))
+ self.assertTrue(Shiboken.isValid(obj))
+ self.assertTrue(Shiboken.isValid(child))
# Note: this test doesn't assure that the object dtor was really called
- shiboken.delete(obj)
- self.assertFalse(shiboken.isValid(obj))
- self.assertFalse(shiboken.isValid(child))
+ Shiboken.delete(obj)
+ self.assertFalse(Shiboken.isValid(obj))
+ self.assertFalse(Shiboken.isValid(child))
def testVersionAttr(self):
- self.assertEqual(type(shiboken.__version__), str)
- self.assertTrue(len(shiboken.__version__) >= 5)
- self.assertEqual(type(shiboken.__version_info__), tuple)
- self.assertEqual(len(shiboken.__version_info__), 5)
+ self.assertEqual(type(Shiboken.__version__), str)
+ self.assertTrue(len(Shiboken.__version__) >= 5)
+ self.assertEqual(type(Shiboken.__version_info__), tuple)
+ self.assertEqual(len(Shiboken.__version_info__), 5)
def testAllWrappers(self):
obj = ObjectType()
- self.assertTrue(obj in shiboken.getAllValidWrappers())
- shiboken.delete(obj)
- self.assertFalse(obj in shiboken.getAllValidWrappers())
+ self.assertTrue(obj in Shiboken.getAllValidWrappers())
+ Shiboken.delete(obj)
+ self.assertFalse(obj in Shiboken.getAllValidWrappers())
if __name__ == '__main__':
unittest.main()