[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-bindings
Subject: Re: Update on PyKF5 bindings
From: Shaheed Haque <srhaque () theiet ! org>
Date: 2016-12-01 14:44:49
Message-ID: CAHAc2jdtoHvvHmt0sZBygniZq8O3hQZEpOrJGt7jPmmMqJmsaw () mail ! gmail ! com
[Download RAW message or body]
We may need Steve to chime in, but pending that...
- My original code in sip_bulk_generator.py took a "--sips" argument
where you could specify pre-existing SIP files to use. The code also
looked at any #includes in the C++ code to try to figure out what to
%Import, generating the XXXmod.sip module file directly.
- I believe Steve preferred to use sip_generator.py directly instead,
which does not generate the mpodule sip file. I *think* his idea was
that you would need to generate the XXXmod.sip file yourself, and
%Import whatever was needed.
Does that sound plausible?
On 1 December 2016 at 13:46, Boudewijn Rempt <boud@valdyas.org> wrote:
> Okay, I've made some progress. It's not working for me yet, but here's what I did \
> until now:
> * because python-clang is only 3.8 on OpenSuse Leap 42.1 and not available on 42.2, \
> I had to build my own llvm: \
> https://phabricator.kde.org/source/krita/browse/rempt%252FT1625-python-scripting/3rdparty/ext_llvm/CMakeLists.txt
>
> * because my setup is python3-only, I made my own llvcm 3.9 tarball with the port \
> to python3 of clang: \
> https://phabricator.kde.org/R37:0ede8c7e56e05bde6f6f4d918301167950819b17
> * for the same reason, I "ported" the find-package python scripts to python3: \
> https://phabricator.kde.org/R37:b508ac4a82a199cb2d475b8eaba8518f618bdcbc
> * for some weird reason, builting PyQt5 against Qt 5.6.1 doesn't add 5.6.1 to the \
> timeline, so I removed that check from FindPythonModuleGeneration.cmake: \
> https://phabricator.kde.org/R37:8aed64565b566598e0c7d61d5043aecba17ff4d0
> * then I even after I added a rules set (the rules set in \
> https://github.com/steveire/kcoreaddons/blob/master/cmake/rules_PyKF5.py is \
> outdated, it has a named includes method that no longer seems to be used?), I still \
> had problems generating sip files from header files that use QObject:
> [ 93%] Generating sip/krita/PyKrita/Action.sip
> _fn_get qt_check_for_QOBJECT_macro
> _fn_get metaObject
> _fn_get qt_metacast
> _fn_get qt_metacall
> _fn_get tr
> Traceback (most recent call last):
> File "/home/boud/dev/deps/share/ECM/find-modules/sip_generator.py", line 688, in \
> main body, includes = g.create_sip(args.source, args.include_filename)
> File "/home/boud/dev/deps/share/ECM/find-modules/sip_generator.py", line 127, in \
> create_sip body = self._container_get(self.tu.cursor, -1, h_file, include_filename)
> File "/home/boud/dev/deps/share/ECM/find-modules/sip_generator.py", line 202, in \
> _container_get decl = self._container_get(member, level + 1, h_file, \
> include_filename) File \
> "/home/boud/dev/deps/share/ECM/find-modules/sip_generator.py", line 180, in \
> _container_get decl = self._fn_get(container, member, level + 1)
> File "/home/boud/dev/deps/share/ECM/find-modules/sip_generator.py", line 392, in \
> _fn_get "init": self._fn_get_parameter_default(function, child),
> File "/home/boud/dev/deps/share/ECM/find-modules/sip_generator.py", line 549, in \
> _fn_get_parameter_default return _get_param_value(text, parameterType)
> File "/home/boud/dev/deps/share/ECM/find-modules/sip_generator.py", line 500, in \
> _get_param_value if not "::" in parameterType.spelling:
> TypeError: argument of type 'NoneType' is not iterable
>
> plugins/extensions/pykrita/CMakeFiles/generate_PyKrita_sip_files.dir/build.make:88: \
> recipe for target 'plugins/extensions/pykrita/sip/krita/PyKrita/Action.sip' failed \
> make[2]: *** [plugins/extensions/pykrita/sip/krita/PyKrita/Action.sip] Error 255
> I added a check for None, and now the sip files are being generated:
>
> @@ -494,6 +495,8 @@ class SipGenerator(object):
> return result
>
> def _get_param_value(text, parameterType):
> + if not parameterType.spelling:
> + return text
> if text == "0":
> return text
> if not "::" in parameterType.spelling:
>
> * Now the sip files are being generated. I discovered that having Qt/Qtmod.sip in \
> the SIP_DEPENDS gave an error: Qtmod.sip:3: A %CompositeModule cannot be %Imported \
> -- not sure why I added that, but anyways.
> * I'm now at the stage where the sip files are generated, and where I probably need \
> to write real rules, because it still doesn't build. I have a number of classes in \
> my C++ wrapper library that are based on classes in other libraries. For instance:
> #include <KoCanvasObserverBase.h>
>
> /**
> * DockWidget
> */
> class KRITALIBKIS_EXPORT DockWidget : public QDockWidget, public \
> KoCanvasObserverBase {
> };
>
> #endif // LIBKIS_DOCKWIDGET_H
>
> KoCanvasObserverBase is in another library. The old, handwritten sip code looks \
> like this:
> %Import QtCore/QtCoremod.sip
> %Import QtGui/QtGuimod.sip
> %Import QtWidgets/QtWidgetsmod.sip
>
> class DockWidget : public QDockWidget /NoDefaultCtors/
> {
> %TypeHeaderCode
> #include "DockWidget.h"
> %End
>
> public:
> explicit DockWidget();
> protected:
> virtual void canvasChanged(Canvas *canvas) = 0;
>
> };
>
> And the generated sip code like this:
>
> // Discarded CLASS_DECL on line 28 'KoCanvasBase'
> class DockWidget: QDockWidget, KoCanvasObserverBase
> {
> %TypeHeaderCode
> #include <dockwidget.h>
> %End
> // Discarded FUNCTION_TEMPLATE on line 35 'qt_check_for_QOBJECT_macro'
> // Discarded VAR_DECL on line 35 'staticMetaObject'
> // Discarded CXX_METHOD on line 35 'metaObject'
> // Discarded CXX_METHOD on line 35 'qt_metacast'
> // Discarded CXX_METHOD on line 35 'qt_metacall'
> // Discarded CXX_METHOD on line 35 'tr'
> // Discarded CXX_METHOD on line 35 'trUtf8'
> DockWidget(const DockWidget & __0);
> public:
> DockWidget();
> virtual ~DockWidget();
> protected Q_SLOTS:
> virtual void setCanvas(KoCanvasBase* canvas);
> virtual void unsetCanvas();
> protected Q_SLOTS:
> Canvas * canvas() const;
> virtual void canvasChanged(Canvas* canvas) = 0;
> private:
> };
>
> This doesn't build, of course:
>
> [ 57%] Generating pybuild/krita/PyKrita/unifiedPyKrita.cpp
> sip: KoCanvasObserverBase has not been defined
> plugins/extensions/pykrita/CMakeFiles/sip_generated_PyKrita_files.dir/build.make:64: \
> recipe for target 'plugins/extensions/pykrita/pybuild/krita/PyKrita/unifiedPyKrita.cpp' \
> failed make[2]: *** \
> [plugins/extensions/pykrita/pybuild/krita/PyKrita/unifiedPyKrita.cpp] Error 1 \
> CMakeFiles/Makefile2:25209: recipe for target \
> 'plugins/extensions/pykrita/CMakeFiles/sip_generated_PyKrita_files.dir/all' failed \
> make[1]: *** [plugins/extensions/pykrita/CMakeFiles/sip_generated_PyKrita_files.dir/all] \
> Error 2 Makefile:127: recipe for target 'all' failed
> make: *** [all] Error 2
>
> But I cannot figure out how to use the rules to get the generator to do what I \
> want...
> --
> Boudewijn Rempt | http://www.krita.org, http://www.valdyas.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic