<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-size: 12pt;">Thank you for your response. That makes sense that
</span><font size="2"><span style="font-size: 12pt;">PyImport_ImportModule</span></font><span style="font-size: 12pt;"> would call
</span><font size="2"><span style="font-size: 12pt;">sip_api_export_module</span></font><span style="font-size: 12pt;">. That does not appear to be happening, though. When I add print statements to trace the code, I see PyImport_ImportModule getting called,
then the code proceeds to the search for the module in moduleList without first seeing another entry into
</span><font size="2"><span style="font-size: 12pt;">sip_api_export_module.</span></font></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<font size="2"><span style="font-size: 12pt;"><br>
</span></font></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<font size="2"><span style="font-size: 12pt;">I wonder if the following could be happening...</span></font></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<font size="2"><span style="font-size: 12pt;">PyQt5 on my system is precompiled, and then I am building my own code that references it. Because siplib.c is generated for each project, perhaps the QtCore import is calling a different
<font size="2"><span style="font-size:12pt">sip_api_export_module</span></font> and updating a different moduleList than the one implemented in my project?</span></font></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<font size="2"><span style="font-size: 12pt;"><br>
</span></font></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<font size="2"><span style="font-size: 12pt;">If this is the explanation, is there a solution short of rebuilding PyQt5 as part of my project?<br>
</span></font></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<font size="2"><span style="font-size: 12pt;"><br>
</span></font></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<font size="2"><span style="font-size: 12pt;">If it helps, I have attached my pyproject.toml file and the generated siblib.c source code.</span></font></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<font size="2"><span style="font-size: 12pt;"><br>
</span></font></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<font size="2"><span style="font-size: 12pt;">I appreciate your help with this.</span></font></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<font size="2"><span style="font-size: 12pt;"><br>
</span></font></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<font size="2"><span style="font-size: 12pt;">-ED<br>
</span></font></div>
<br>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div id="appendonsend"></div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt">
<div class="PlainText"><br>
On 14/07/2022 14:04, Edward A. Pier wrote:<br>
> I have C++ code that depends on Qt5 that I wrap into Python using sip.<br>
> I am porting code that worked under Ubuntu 20.04 (sip 4.19.21, PyQt5<br>
> 5.14.1) to run under Ubuntu 22.04 (sip 6.5.1, PyQt5 5.15.6). Now when<br>
> I import the resulting Python module I get the error in the subject<br>
> line:<br>
><br>
> RuntimeError: the PyQt5.QtCore module failed to register with the sip<br>
> module<br>
><br>
> I traced this to the generated file siplib.c in the<br>
> sip_api_export_module function. This function tries to load required<br>
> modules, of which PyQt5.QtCore is the first. It calls<br>
> PyImport_ImportModule and then tries to find the module in a linked<br>
> list kept in the moduleList variable. The problem is that on the first<br>
> call to sip_api_export_module, moduleList=NULL, i.e. the list is<br>
> empty, as it only gets updated at the bottom of sip_api_export_module.<br>
><br>
> So I'm a bit stumped how this could work, unless the first module for<br>
> which sip_api_export_module is called does not have dependencies, or<br>
> sip_api_export_module is called for those dependencies first. I've<br>
> read through the pyproject.toml documentation, but I didn't see any<br>
> way to make either of these things happen.<br>
<br>
PyImport_ImportModule of QtCore will call QtCore's PyInit_QtCore<br>
function which itself calls sip_api_export_module and adds QtCore to<br>
moduleList.<br>
<br>
It sounds like something called QtCore is being successfully imported<br>
but it's not the QtCore extension module.<br>
<br>
> Let me know what additional information might help get to the bottom of<br>
> this.<br>
<br>
The pyproject.toml file might help.<br>
<br>
Phil<br>
</div>
</span></font></div>
</body>
</html>