Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pivy Python 3.10/3.11 compatibility? #88

Closed
hobbes1069 opened this issue Dec 4, 2021 · 16 comments · Fixed by #91
Closed

Pivy Python 3.10/3.11 compatibility? #88

hobbes1069 opened this issue Dec 4, 2021 · 16 comments · Fixed by #91

Comments

@hobbes1069
Copy link

As reported in the FreeCAD forums[1], the guess is that this is a Python compatibility issue...

Excerpt here:

0.19, Dimension013, added view property 'ScaleMultiplier'
Traceback (most recent call last):
  File "/usr/lib64/freecad/Mod/Draft/draftviewproviders/view_dimension.py", line 701, in onChanged
    self.font.size = vobj.FontSize.Value * vobj.ScaleMultiplier
  File "/usr/lib64/python3.10/site-packages/pivy/coin.py", line 3998, in __setattr__
    field = self.getField(name)
  File "/usr/lib64/python3.10/site-packages/pivy/coin.py", line 3873, in getField
    return _coin.SoFieldContainer_getField(self, name)
<class 'SystemError'>: <built-in function SoFieldContainer_getField> returned a result with an exception set
v0.19, Dimension014, added view property 'ScaleMultiplier'

Fedora 35 has Python 3.10 but future Fedora 36 will have Python 3.11...

@looooo
Copy link
Collaborator

looooo commented Dec 4, 2021

Can you try running the privy test?

@hobbes1069
Copy link
Author

Sure, what's the command? I'm using CMake for the build system.

Is it built in, or do I just need to run the test files with python?

@hobbes1069
Copy link
Author

I ran the tests against my installed package and unsurprisingly there are errors:
https://hobbes1069.fedorapeople.org/coin_tests.log

@looooo
Copy link
Collaborator

looooo commented Dec 8, 2021

I am currently stuck with python3.10 update at pyside2. Therefore it most likely need some time until I can test privy with python 3.10.

@hobbes1069
Copy link
Author

Me too. I've worked through some of it though.
https://src.fedoraproject.org/rpms/python-pyside2/blob/rawhide/f/python3.10.patch

I have some more but haven't committed it yet.

$ cat pyside-python310.patch
Index: pyside-setup-opensource-src-5.15.2/sources/shiboken2/libshiboken/basewrap                                     per.cpp
===================================================================
--- pyside-setup-opensource-src-5.15.2.orig/sources/shiboken2/libshiboken/basewr                                     apper.cpp
+++ pyside-setup-opensource-src-5.15.2/sources/shiboken2/libshiboken/basewrapper                                     .cpp
@@ -366,7 +366,7 @@ SbkObjectType *SbkObject_TypeF(void)
     static PyTypeObject *type = nullptr;
     if (!type) {
         type = reinterpret_cast<PyTypeObject *>(SbkType_FromSpec(&SbkObject_Typ                                     e_spec));
-        Py_TYPE(type) = SbkObjectType_TypeF();
+        Py_SET_TYPE(type, SbkObjectType_TypeF());
         Py_INCREF(Py_TYPE(type));
         type->tp_weaklistoffset = offsetof(SbkObject, weakreflist);
         type->tp_dictoffset = offsetof(SbkObject, ob_dict);
@@ -1110,7 +1110,7 @@ introduceWrapperType(PyObject *enclosing
     typeSpec->slots[0].pfunc = reinterpret_cast<void *>(baseType ? baseType : S                                     bkObject_TypeF());

     PyObject *heaptype = SbkType_FromSpecWithBases(typeSpec, baseTypes);
-    Py_TYPE(heaptype) = SbkObjectType_TypeF();
+    Py_SET_TYPE(heaptype, SbkObjectType_TypeF());
     Py_INCREF(Py_TYPE(heaptype));
     auto *type = reinterpret_cast<SbkObjectType *>(heaptype);
 #if PY_VERSION_HEX < 0x03000000

@looooo
Copy link
Collaborator

looooo commented Dec 8, 2021

Great, I will try the patches. Which version of pyside2 / qt are you compiling?

@looooo
Copy link
Collaborator

looooo commented Dec 8, 2021

Not sure if it makes a lot of sense to backport these changes. Maybe it's better to wait for a newer qt / pyside2 version to be packaged for conda-forge. I guess qt6.x and pyside2 6.x will have python 3.10 support.

@hobbes1069
Copy link
Author

Pyside2 5.15.2
Qt 5.15.2

Yes, the first patch was backported from a Pyside2 6.x commit. I don't know how much work they will put into Pyside2 5.x at this point, but is FreeCAD compatible with Qt6? I don't even want to think about migrating all of Fedora :)

@looooo
Copy link
Collaborator

looooo commented Dec 10, 2021

Yep, I see the troubles. I will try to patch pyside 5.13 to work with python 3.10. once done I will come back to this issue.

@hobbes1069
Copy link
Author

Sounds good. I played around with trying to find python related commits from 6.2.2 and try to backport but it became a rabbit hole and I had to give up.

@looooo
Copy link
Collaborator

looooo commented Dec 16, 2021

@hobbes1069 conda-forge is updating to qt5.15 so we can work on the same issue. I asked a question @ gitter. I hope someone takes care of this issue:
https://gitter.im/PySide/pyside2?at=61bb76659a9ec834fbd1c865

@hawkmoth
Copy link

hawkmoth commented Jan 1, 2022

@hobbes1069 It looks like the FreeCAD issue is partly related to Coin3 vs. Coin4. The fc35 pivy is built against Coin4, while the FreeCAD modules seem to be using the Coin3 API (???).

$>dnf repoquery --provides Coin3
Last metadata expiration check: 3:06:45 ago on Fri 31 Dec 2021 07:18:25 PM PST.
Coin3 = 3.1.3-29.fc35
Coin3(x86-32) = 3.1.3-29.fc35
Coin3(x86-64) = 3.1.3-29.fc35
libCoin.so.60
libCoin.so.60()(64bit)**                 <===
$> dnf repoquery --provides Coin4
Last metadata expiration check: 3:08:23 ago on Fri 31 Dec 2021 07:18:25 PM PST.
Coin4 = 4.0.0-9.fc35
Coin4(x86-32) = 4.0.0-9.fc35
Coin4(x86-64) = 4.0.0-9.fc35
libCoin.so.80
libCoin.so.80()(64bit)                    <=== 
dnf repoquery --requires python3-pivy
Last metadata expiration check: 3:09:46 ago on Fri 31 Dec 2021 07:18:25 PM PST.
/usr/bin/python3
libCoin.so.80()(64bit)                    <===
libSoQt.so.20()(64bit)
libc.so.6(GLIBC_2.14)(64bit)
libgcc_s.so.1()(64bit)
libgcc_s.so.1(GCC_3.0)(64bit)
libgcc_s.so.1(GCC_3.3.1)(64bit)
libstdc++.so.6()(64bit)
libstdc++.so.6(CXXABI_1.3)(64bit)
libstdc++.so.6(CXXABI_1.3.8)(64bit)
libstdc++.so.6(CXXABI_1.3.9)(64bit)
libstdc++.so.6(GLIBCXX_3.4)(64bit)
python(abi) = 3.10
rtld(GNU_HASH)

The following works just fine in the FreeCAD Python console:

from pivy import coin
doc = App.newDocument("testpivy")
view = Gui.ActiveDocument.ActiveView 
sg=view.getScenegraph()
sg.addChild(coin.SoCube())

This minimum excerpt from the Draft workbench code produces an error similar to the above:

pick = coin.SoPickStyle()
pick.style.setValue(coin.SoPickStyle.UNPICKABLE)

The issue is that the style attribute does not exist. Which may be due to incompatible APIs between Coin3 and Coin4 (I do not know either one).

@ipatch
Copy link

ipatch commented Jan 1, 2022

a couple of use noticed similar issues on macos as well. those of us who building and install freecad on macos with macos homebrew have seen issues related to python 3.10

it appears shiboken2 v5.15.2 will not compile / build with the latest python 3.10

FreeCAD/homebrew-freecad#267 (comment)

there was a bug reported upstream below,

https://bugreports.qt.io/browse/PYSIDE-1436


i mention all of this because apparently python 3.10 has introduced some changes that aren't compatible with libraries like shiboken2 in its current state unfortunately. and i doubt the upstream qt maintainers are gunna wanna back port fixes to get shiboken2 v5.15.2 and pyside2 v5.15.2 to work with python 3.10

@antonok-edm
Copy link
Contributor

In case anyone here is itching to get back to work on their FreeCAD projects, #91 should do the trick!

@adrianinsaval
Copy link

adrianinsaval commented May 30, 2022

From what version onwards is pivy compatible with python 3.10, is it 0.6.6?

@antonok-edm
Copy link
Contributor

@adrianinsaval it should be in 0.6.7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants