Correct way to add third-party sip extensions to pyqtdeploy project?

Patrick Stinson patrickkidd at gmail.com
Fri Sep 25 17:22:17 BST 2020


The PyQt, PyQtChart, etc component plugins use sip-install to build static line for those extensions and install them in the sysroot. This makes sense for third-party pyqt extensions that are not being maintained as part of the application.

But I am starting to question the conceptual coherence of this approach for PyQt extensions that are a part of the application itself. It seems clunky to build them statically into the sysyroot, and then rebuild them prior to building the app exe. It is also quite confusing how to implement a quasi-component plugin for the sysroot that actuall is not part of the sysroot. During development sip-build can be run and PYTHONPATH can be set to load the extension from within the app source tree when running python from the command line. The toml project now more or less represents an encapsulated component. Shouldn’t pyqtdeploy be just provided a list of toml projects to be compiled into the static exe? If not, a simple example of a component for an in-app pyqt extension in pyqtdeploy would be worth loads.

> On Sep 25, 2020, at 12:10 AM, Phil Thompson <phil at riverbankcomputing.com> wrote:
> 
> Make it the current directory.
> 
>> On 24/09/2020 22:19, Patrick Stinson wrote:
>> If so, how would I do that?
>>>> On Sep 24, 2020, at 1:19 PM, Patrick Stinson <patrickkidd at gmail.com> wrote:
>>> Ah right. So I am assuming that dealing with the .sip file is in the pyproject.toml.
>>> Mine is currently called pyproject.toml and sits in the folder with the extension source. Maybe I need to tell the component where the folder is so it can find pyproject.toml?
>>>> On Sep 24, 2020, at 1:17 PM, Phil Thompson <phil at riverbankcomputing.com <mailto:phil at riverbankcomputing.com>> wrote:
>>>> pyqtdeploy knows nothing about moc - that's down to qmake.
>>>> The .toml file must be called pyproject.toml - that's specified in PEP 518.
>>>> On 24/09/2020 21:39, Patrick Stinson wrote:
>>>>> I should add that moc is not being run for all of my headers listed in
>>>>> the toml file. Though as per my previous email, I’m not sure if you
>>>>> are suggesting that there is any code in pyqtdeploy that would do such
>>>>> a thing for moc files or for sip-generated sources. I debugged
>>>>> pyqtdeploy-build and didn’t see anything to that effect.
>>>>>> On Sep 24, 2020, at 9:55 AM, Patrick Stinson <patrickkidd at gmail.com <mailto:patrickkidd at gmail.com>> wrote:
>>>>>> OK, I am gathering that do this in my component plugin:
>>>>>>   def install(self):
>>>>>>       pyqt = self.get_component('PyQt')
>>>>>>       pyqt.install_pyqt_component(self)
>>>>>> Now I’m getting unresolved symbols for my extension module, though some moc files are generated so something is happening there.
>>>>>> It looks like install_pyqt_component() loads the project file for the component, though I have no idea how it finds it. Mine is in <APPROOT>/_pkdiagram/_pkdiagram.toml.
>>>>>> My sysroot is in <APPROOT>/vendor/sysroot.toml.
>>>>>> Pyqtdeploy-build doesn’t complain if I rename my pyproject.toml even though the code says it should complain, so I know it isn’t finding the file in order to figure out where the .sip file and other sources are.
>>>>>>> On Sep 24, 2020, at 12:28 AM, Phil Thompson <phil at riverbankcomputing.com <mailto:phil at riverbankcomputing.com><mailto:phil at riverbankcomputing.com <mailto:phil at riverbankcomputing.com>>> wrote:
>>>>>>> On 24/09/2020 06:59, Patrick Stinson wrote:
>>>>>>>> Got it.
>>>>>>>> I’ve now managed to get pyqtdeploy to use my sysroot component plugin
>>>>>>>> to add my app’s extension module source files to the qmake project. Is
>>>>>>>> there any way to tell the ExtensionModule that there is a sip file so
>>>>>>>> it will do what sip-build does by generating the C++ sources and
>>>>>>>> setting up C++ flags correctly? What about generating moc files for .h
>>>>>>>> headers?
>>>>>>>> My extension is starting to get busy with those mangled sip-build file
>>>>>>>> names, and it’s also complaining about sip.h, and I imagine more
>>>>>>>> things if I fix those problems with manual paths.
>>>>>>>> class VedanaComponent(Component):
>>>>>>>>  """ The vedana module component. """
>>>>>>>>  must_install_from_source = False
>>>>>>>>  preinstalls = ['Python', 'PyQt', 'Qt', 'SIP']
>>>>>>>>  provides = {
>>>>>>>>      '_pkdiagram':
>>>>>>>>          ExtensionModule(
>>>>>>>>              deps='PyQt:PyQt5.QtWidgets',
>>>>>>>>              source=[
>>>>>>>>                  "../../../_pkdiagram/unsafearea.cpp",
>>>>>>>>                  "../../../_pkdiagram/_pkdiagram.cpp",
>>>>>>>>                  "../../../_pkdiagram/_pkdiagram_mac.mm",
>>>>>>>>                  "../../../_pkdiagram/build/_pkdiagram/moc_unsafearea.cpp",
>>>>>>>>                  "../../../_pkdiagram/build/_pkdiagram/moc__pkdiagram.cpp",
>>>>>>>> "../../../_pkdiagram/build/_pkdiagram/sip_pkdiagramAppFilter.cpp",
>>>>>>>> "../../../_pkdiagram/build/_pkdiagram/sip_pkdiagramcmodule.cpp",
>>>>>>>> "../../../_pkdiagram/build/_pkdiagram/sip_pkdiagramCUtil.cpp",
>>>>>>>> "../../../_pkdiagram/build/_pkdiagram/sip_pkdiagramFDDocument.cpp",
>>>>>>>> "../../../_pkdiagram/build/_pkdiagram/sip_pkdiagramPathItemBase.cpp",
>>>>>>>> "../../../_pkdiagram/build/_pkdiagram/sip_pkdiagramPathItemDelegate.cpp",
>>>>>>>> "../../../_pkdiagram/build/_pkdiagram/sip_pkdiagramPersonDelegate.cpp",
>>>>>>>> "../../../_pkdiagram/build/_pkdiagram/sip_pkdiagramQMap0100QString0100QString.cpp",
>>>>>>>>              ],
>>>>>>>>              defines=[ "PK_DEBUG_BUILD=0" ],
>>>>>>>>              qmake_qt=[ 'gui', 'widgets' ]
>>>>>>>>          )
>>>>>>>>  }
>>>>>>>>  def get_archive_name(self):
>>>>>>>>      return ''
>>>>>>>>  def install(self):
>>>>>>>>      """ Install for the target. """
>>>>>>> Take a look the AbstractPyQtComponent class in abstract_pyqt_component.py (and the other abstract components in the same directory).
>>>>>>> This is not documented and so is not currently part of the public API (despite what the comments say). However it may be what you are looking for. If so I'll document them properly. In the meantime have a look at the PyQtChart plugin (for example) to see how the methods implemented are used.
>>>>>>> Phil


More information about the PyQt mailing list