SIP real library wrapping

Phil Thompson phil at riverbankcomputing.com
Wed Jan 13 14:52:48 GMT 2021


On 13/01/2021 14:31, ZephOne wrote:
> Hello,
> 
> migrating from SIP v4 build system to SIP v5 build system I'm trying
> to build wheel for a simple PyQt extension written in C++, a custom
> event filters.
> 
> The pyproject.toml is like this :
> 
> [build-system]
> requires = ["sip >=5, <7", "PyQt-builder", "PyQt5"]
> buid-backend = "sipbuild.api"
> 
> [tool.sip.metadata]
> name = "customeventfilters"
> version = "0.7.0"
> description = "Custom PyQt5 event filters"
> author = "ZephOne"
> author-email = "zephone at protonmail.com"
> license='BSD'
> requires-dist = "PyQt5"
> 
> [tool.sip.project]
> sdist-excludes = [
>   ".git/*",
>   ".git/*/*",
>   ".git/*/*/*",
>   ".git/*/*/*/*",
>   ".git/*/*/*/*/*",
>   ".git/*/*/*/*/*/*",
>   ".git/*/*/*/*/*/*/*"
> ]
> 
> 
> And the project.py which is used only to specify the location of the
> C++ library is like this:
> 
> """The build configuration file for CustomEventFilters, used by sip."""
> 
> import os
> 
> from pyqtbuild import PyQtBindings, PyQtProject
> from sipbuild import Option
> 
> class CustomEventFilters(PyQtProject):
>     """The Project class."""
> 
>     def __init__(self):
>         """ Initialise the project. """
> 
>         super().__init__()
> 
>         self.bindings_factories = [MyEventFilters]
> 
> class MyEventFilters(PyQtBindings):
>     """ My event filters bindings. """
> 
>     def __init__(self, project):
>         """ Initialise the bindings. """
> 
>         super().__init__(
>             project,
>             "MyEventFilters",
>             sip_file='myeventfilters.sip'
>         )
> 
>     def apply_user_defaults(self, tool):
>         """ Set default values for user options that haven't been set 
> yet. """
> 
>         if self.myeventfilters_include_dir is not None:
>             self.include_dirs.append(
>                 os.path.abspath(
>                     self.myeventfilters_include_dir
>                 )
>             )
> 
>         if self.myeventfilters_library_dir is not None:
>             self.include_dirs.append(
>                 os.path.abspath(
>                     self.myeventfilters_library_dir
>                 )
>             )
> 
>         super().apply_user_defaults(tool)
> 
>     def get_options(self):
>         """ Return the list of configurable options. """
> 
>         options = super().get_options()
> 
>         options.append(
>             Option(
>                 "myeventfilters_include_dir",
>                 help="the my event filters include file directory is in 
> DIR",
>                 metavar="DIR"
>             )
>         )
> 
>         options.append(
>             Option(
>                 "myeventfilters_library_dir",
>                 help="the my event filters library is in DIR",
>                 metavar="DIR"
>             )
>         )
> 
>         return options
> 
> I think there's no problem with the C++ library (I had no problem 
> SIP4).
> 
> With these two files I have no problem building the the wheel, using 
> sip-wheel.
> But when I try to import it in a python console I've got this error:
> 
> ImportError:
> /venvdir/customeventfilters/lib/python3.9/site-packages/customeventfilters.cpython-39-x86_64-linux-gnu.so:
> undefined symbol: _ZTI18GenericEventFilter
> 
> GenericEventFilter is a class defined in the C++ library.
> 
> Did I miss something binding the C++ extension ?

If your C++ library is installed in a non-standard location then I'd 
look at the rpath.

I'd also compare the .pro files generated by v4 and v5.

Phil


More information about the PyQt mailing list