Update on PyKF5 bindings

Shaheed srhaque at theiet.org
Thu Dec 1 15:34:14 UTC 2016


On Thursday, 1 December 2016 16:09:17 GMT Boudewijn Rempt wrote:
> On Thu, 1 Dec 2016, Shaheed Haque wrote:
> > 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.
> 
> Hm... How did that work? Would it take the existing sip and just add
> all functions that aren't blacklisted or something like that?

The sip_generator.py layer's main function is create_sip(). This returns a buffer containing 
the generated code and a list of the includes (actually, a function that can be called to get 
the list).

The sip_bulk_generator.py layers' job was to run create_sip for each of the .h files in a 
directory, and then create a XXXmod.sip for the whole directory that used the returned 
lists to create the needed %Imports. There is a bit of info in the README file that explains 
the original ideas in more details.

Looking at Steve's version of the code, the list of includes is ignored:

        g = SipGenerator(rules, args.verbose)
        body, includes = g.create_sip(args.source, args.include_filename)
        with open(args.output, "w") as outputFile:
            outputFile.write(body)

(This is circa line 1004 at https://github.com/steveire/extra-cmake-modules/blob/master/
find-modules/sip_generation/sip_generator.py). I don't see where the module SIP file is 
created in the Python code, so that may be buried in CMake?

Thanks, Shaheed

> > - 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.
> 
> Actually, it looks like the the XXXmod.sip is also generated at the moment.
> 
> > Does that sound plausible?
> > 
> > On 1 December 2016 at 13:46, Boudewijn Rempt <boud at 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:0ede8c7e56e05bde6f6f4d918301167950819b1
> > > 7
> > > 
> > > * for the same reason, I "ported" the find-package python scripts to
> > > python3:
> > > https://phabricator.kde.org/R37:b508ac4a82a199cb2d475b8eaba8518f618bdcb
> > > c
> > > 
> > > * 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:8aed64565b566598e0c7d61d5043aecba17ff4d
> > > 0> > 
> > > * 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)
> > >       
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-bindings/attachments/20161201/4072fbf0/attachment-0001.html>


More information about the Kde-bindings mailing list