PySide migration

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
ulrich1a
Veteran
Posts: 1957
Joined: Sun Jul 07, 2013 12:08 pm

Re: PySide migration

Post by ulrich1a »

Here is the information, you asked for:
I am using FreeCADLibs_8.2_x86_VC9.

Code: Select all

>>> import sip
>>> print sip.__file__
C:\Users\ubrammer\FreeCAD-git\FreeCAD_sf_master\Build\bin\sip.pyd
>>> dir(sip)
['SIP_VERSION', 'SIP_VERSION_STR', '_C_API', '__doc__', '__file__', '__name__', '__package__', '_unpickle_enum', '_unpickle_type', 'cast', 'delete', 'dump', 'getapi', 'isdeleted', 'ispyowned', 'setapi', 'setdeleted', 'settracemask', 'simplewrapper', 'transferback', 'transferto', 'unwrapinstance', 'voidptr', 'wrapinstance', 'wrapper', 'wrappertype']
>>> 
In the file, you gave the link for, I found the following description:

Code: Select all

%define SOQT_MODULE_DOCSTRING
"The soqt module is a wrapper for the SoQt library. The module will try
to import the sip module which is used for PyQt. If found the involved
wrapped Qt structures are converted to ones suitable for PyQt,
otherwise it will fall back to regular SWIG structures."
%enddef
As sip and Swig are both wrappers for interfacing C++ to python, it sounds for me, if we just do not show pivy the sip, it will only use Swig. So my understanding is, a Pivy-Version without sip is needed in the Libpack.
The error-messages were all around sip is complaining to get PySide-structures instead of PyQT-structures.
But my knowledge does not go so far, to be able to build the needed version of Pivy.

Ulrich
ulrich1a
Veteran
Posts: 1957
Joined: Sun Jul 07, 2013 12:08 pm

Re: PySide migration

Post by ulrich1a »

I wrote something missleading. correct is: Pivy delivered in the third party sources has to be build without sip, in order to avoid error-messages complaining about sip getting PySide structures.

Ulrich
wmayer
Founder
Posts: 20319
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: PySide migration

Post by wmayer »

ulrich1a wrote:I wrote something missleading. correct is: Pivy delivered in the third party sources has to be build without sip, in order to avoid error-messages complaining about sip getting PySide structures.
As said above there is no hard dependency to sip. So, if you just remove the file from the LibPack then it should work.
ulrich1a
Veteran
Posts: 1957
Joined: Sun Jul 07, 2013 12:08 pm

Re: PySide migration

Post by ulrich1a »

I followed your advise and deleted the PyQT folder and sip.pyd from the Libpack.
I did also a complete new rebuild. The start of the Draftworkbench gives me the following message:
Error-message at start of Draft workbench
Error-message at start of Draft workbench
no_sip.png (20.07 KiB) Viewed 3218 times
The Draft-Workbench is loaded, despite the message box. But trying to work gives the following error:

Code: Select all

Ersten Punkt auswählen: <type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
('[Draft.todo.tasks] Unexpected error:', <type 'exceptions.KeyError'>, 'in ', <built-in method showDialog of tuple object at 0x125069B8>, '(', <DraftGui.DraftTaskPanel instance at 0x12A2EDB8>, ')')<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
<type 'exceptions.KeyError'>
'unwprapinstance' can be found in:
src/3rdParty/Pivy-0.5/soqt_wrap.cpp
and
src/Gui/WidgetFactory.cpp

I had a Debug-Build. At close of FreeCAD there was a messagebox which said something about an unusual end of the program.
How can this be debuged or fixed?

OS: Windows 7
Platform: 32-bit
Version: 0.14.3044 (Git)
Branch: master
Hash: 843838ec194010197dcaf9e5d83d55f253d2ac03
Python version: 2.6.2
Qt version: 4.5.2
Coin version: 3.1.0
SoQt version: 1.4.1

Ulrich
wmayer
Founder
Posts: 20319
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: PySide migration

Post by wmayer »

But your LibPack has the PySide files? And when looking at WidgetFactory.cpp set a breakpoint at PythonWrapper::toQObject(). Now start the debugger and look which code path it follows. If it goes the block:

Code: Select all

    Py::Module mainmod(PyImport_AddModule((char*)"sip"));
    Py::Callable func = mainmod.getDict().getItem("unwrapinstance");
    Py::Tuple arguments(1);
    arguments[0] = pyobject; //PyQt pointer
    Py::Object result = func.apply(arguments);
    void* ptr = PyLong_AsVoidPtr(result.ptr());
    return reinterpret_cast<QObject*>(ptr);
then your FreeCAD build doesn't link shiboken and PySide (here we have a hard dependency). Then there must be something wrong with the LibPack.
ulrich1a
Veteran
Posts: 1957
Joined: Sun Jul 07, 2013 12:08 pm

Re: PySide migration

Post by ulrich1a »

I discovered now the cmake-files for windows 32-bit do not contain any definitions for shiboken and pyside. So for me it is no wonder that I every time compile against sip.
I am trying to put this definition from the x64-Libpack into the 8.x Libpack. But I have a problem with the PYSIDE_PYTHONPATH. I did not found the corresponding path in the 8.x Libpack. How should this path be set? Below is the addition I put into the file: \FreeCAD_sf_master\cMake\UseLibPack8x.cmake

Code: Select all

#  SHIBOKEN_INCLUDE_DIR        - Directories to include to use SHIBOKEN
#  SHIBOKEN_LIBRARY            - Files to link against to use SHIBOKEN
#  SHIBOKEN_BINARY             - Executable name

SET(SHIBOKEN_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/shiboken)
SET(SHIBOKEN_LIBRARY     optimized ${FREECAD_LIBPACK_DIR}/lib/shiboken-python2.6.lib debug ${FREECAD_LIBPACK_DIR}/lib/shiboken-python2.6_d.lib)
set(SHIBOKEN_BINARY      ${FREECAD_LIBPACK_DIR}/bin/shiboken)

#  PYSIDE_INCLUDE_DIR   - Directories to include to use PySide
#  PYSIDE_LIBRARY       - Files to link against to use PySide
#  PYSIDE_PYTHONPATH    - Path to where the PySide Python module files could be found
#  PYSIDE_TYPESYSTEMS   - Type system files that should be used by other bindings extending PySide

SET(PYSIDE_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/PySide)
SET(PYSIDE_LIBRARY     optimized ${FREECAD_LIBPACK_DIR}/lib/pyside-python2.6.lib debug ${FREECAD_LIBPACK_DIR}/lib/pyside-python2.6_d.lib)
SET(PYSIDE_PYTHONPATH  ${FREECAD_LIBPACK_DIR}/pyside/Lib/site-packages)
SET(PYSIDE_TYPESYSTEMS ${FREECAD_LIBPACK_DIR}/pyside/share/PySide/typesystems)
Ulrich
ulrich1a
Veteran
Posts: 1957
Joined: Sun Jul 07, 2013 12:08 pm

Re: PySide migration

Post by ulrich1a »

Update: even with partly incomlete change in the file UseLibPack8x.cmake, I can now call the Draft-Workbench without error messages. Can this file be updated in git?

Ulrich
wmayer
Founder
Posts: 20319
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: PySide migration

Post by wmayer »

Does the above change fix your problem or are there further changes required?
ulrich1a
Veteran
Posts: 1957
Joined: Sun Jul 07, 2013 12:08 pm

Re: PySide migration

Post by ulrich1a »

I did also delete the PyQT4 folder in the Libpack. This was remaining from the former tests, in order to solve the problem. So the ship-workbench does not find the module PyQt4. I did not test so far with a complete Libpack and complete copy of the Libpack/bin into Build/bin. But I hope, it will also work with the complete Libpack and complete copy.

I did not change anything else.
What will be the path for PYSIDE_PYTHONPATH?
Ulrich
User avatar
jriegel
Founder
Posts: 3369
Joined: Sun Feb 15, 2009 5:29 pm
Location: Ulm, Germany
Contact:

Re: PySide migration

Post by jriegel »

So far its planed to leave both in the LibPack. Otherwise we can not build older code anymore....
Stop whining - start coding!
Post Reply