Another attempt trying to fix the DLL load issue for pya on Windows - force-load all DLL that are needed by pyacore into the app before importing the module

This commit is contained in:
Matthias Koefferlein 2023-03-28 00:39:32 +02:00
parent 5c57f5ddf8
commit 1cfe7b10ba
5 changed files with 85 additions and 61 deletions

View File

@ -65,6 +65,8 @@
# include "gsiQtDesignerExternals.h"
# include "gsiQtUiToolsExternals.h"
// pulls in the Qt GSI binding modules - need to be force loaded so they are available
// the pya Python module (Python >= 3.8 does not recognize DLL paths on Windows)
FORCE_LINK_GSI_QTCORE
FORCE_LINK_GSI_QTGUI
FORCE_LINK_GSI_QTWIDGETS

View File

@ -25,52 +25,3 @@ INCLUDEPATH += $$DOC_INC $$ICONS_INC $$QTBASIC_INC
DEPENDPATH += $$DOC_INC $$ICONS_INC $$QTBASIC_INC
LIBS += -lklayout_doc -lklayout_icons
equals(HAVE_QTBINDINGS, "1") {
LIBS += -lklayout_qtbasic -lklayout_QtGui
!equals(HAVE_QT_XML, "0") {
LIBS += -lklayout_QtXml
}
!equals(HAVE_QT_NETWORK, "0") {
LIBS += -lklayout_QtNetwork
}
!equals(HAVE_QT_SQL, "0") {
LIBS += -lklayout_QtSql
}
!equals(HAVE_QT_DESIGNER, "0") {
LIBS += -lklayout_QtDesigner
}
!equals(HAVE_QT_UITOOLS, "0") {
LIBS += -lklayout_QtUiTools
}
greaterThan(QT_MAJOR_VERSION, 4) {
LIBS += -lklayout_QtWidgets
!equals(HAVE_QT_MULTIMEDIA, "0") {
LIBS += -lklayout_QtMultimedia
}
!equals(HAVE_QT_PRINTSUPPORT, "0") {
LIBS += -lklayout_QtPrintSupport
}
!equals(HAVE_QT_SVG, "0") {
LIBS += -lklayout_QtSvg
}
!equals(HAVE_QT_XML, "0") {
LIBS += -lklayout_QtXmlPatterns
}
}
greaterThan(QT_MAJOR_VERSION, 5) {
LIBS += -lklayout_QtCore5Compat
LIBS -= -lklayout_QtXmlPatterns
LIBS -= -lklayout_QtDesigner
}
}

View File

@ -326,18 +326,6 @@ PythonInterpreter::PythonInterpreter (bool embedded)
tl::warn << tl::to_string (tr ("Unable to find built-in Python module library path"));
}
// Supply a DLL load path for certain Python versions and on Windows
define_variable ("__klayout_dll_path", tl::dirname (app_path));
// NOTE: there is no API I know of ...
eval_string (
"import os\n"
"try:\n"
" global __klayout_dll_path\n"
" os.add_dll_directory(__klayout_dll_path)\n"
"except:\n"
" pass\n" // on Windows or older versions of Python
);
// Import the pya module
PyObject *pya_module = PyImport_ImportModule (pya_module_name);
if (pya_module == NULL) {

View File

@ -80,6 +80,40 @@
# include "lvsForceLink.h"
#endif
#if defined(HAVE_QTBINDINGS)
// pulls in the Qt GSI binding modules - need to be force loaded so they are available
// the pya Python module (Python >= 3.8 does not recognize DLL paths on Windows)
# include "gsiQtGuiExternals.h"
# include "gsiQtWidgetsExternals.h"
# include "gsiQtCoreExternals.h"
# include "gsiQtMultimediaExternals.h"
# include "gsiQtPrintSupportExternals.h"
# include "gsiQtXmlExternals.h"
# include "gsiQtXmlPatternsExternals.h"
# include "gsiQtSqlExternals.h"
# include "gsiQtSvgExternals.h"
# include "gsiQtNetworkExternals.h"
# include "gsiQtDesignerExternals.h"
# include "gsiQtUiToolsExternals.h"
FORCE_LINK_GSI_QTCORE
FORCE_LINK_GSI_QTGUI
FORCE_LINK_GSI_QTWIDGETS
FORCE_LINK_GSI_QTMULTIMEDIA
FORCE_LINK_GSI_QTPRINTSUPPORT
FORCE_LINK_GSI_QTXML
FORCE_LINK_GSI_QTXMLPATTERNS
FORCE_LINK_GSI_QTDESIGNER
FORCE_LINK_GSI_QTNETWORK
FORCE_LINK_GSI_QTSQL
FORCE_LINK_GSI_QTSVG
FORCE_LINK_GSI_QTUITOOLS
#else
# define QT_EXTERNAL_BASE(x)
#endif
static int main_cont (int &argc, char **argv);
#ifdef _WIN32 // for VC++

View File

@ -29,6 +29,55 @@ equals(HAVE_PYTHON, "1") {
LIBS += -lklayout_pyastub
}
equals(HAVE_QTBINDINGS, "1") {
LIBS += -lklayout_qtbasic -lklayout_QtGui
!equals(HAVE_QT_XML, "0") {
LIBS += -lklayout_QtXml
}
!equals(HAVE_QT_NETWORK, "0") {
LIBS += -lklayout_QtNetwork
}
!equals(HAVE_QT_SQL, "0") {
LIBS += -lklayout_QtSql
}
!equals(HAVE_QT_DESIGNER, "0") {
LIBS += -lklayout_QtDesigner
}
!equals(HAVE_QT_UITOOLS, "0") {
LIBS += -lklayout_QtUiTools
}
greaterThan(QT_MAJOR_VERSION, 4) {
LIBS += -lklayout_QtWidgets
!equals(HAVE_QT_MULTIMEDIA, "0") {
LIBS += -lklayout_QtMultimedia
}
!equals(HAVE_QT_PRINTSUPPORT, "0") {
LIBS += -lklayout_QtPrintSupport
}
!equals(HAVE_QT_SVG, "0") {
LIBS += -lklayout_QtSvg
}
!equals(HAVE_QT_XML, "0") {
LIBS += -lklayout_QtXmlPatterns
}
}
greaterThan(QT_MAJOR_VERSION, 5) {
LIBS += -lklayout_QtCore5Compat
LIBS -= -lklayout_QtXmlPatterns
LIBS -= -lklayout_QtDesigner
}
}
equals(HAVE_RUBY, "1") {
# DRC is only available with Ruby
INCLUDEPATH += $$DRC_INC $$LVS_INC