Commit 35038ec4 authored by Boudewijn Rempt's avatar Boudewijn Rempt

Work harder to find the python libraries on macOS

Now everything is found; however, if not all rpaths are set
correctly, Krita crashes on startup because different python
libraries are mixed.

I'm too tired to fix that right now, though.
parent 8d3c4663
......@@ -8,7 +8,7 @@ if (UNIX)
PATCH_COMMAND ${PATCH_COMMAND} -p1 -i ${CMAKE_CURRENT_SOURCE_DIR}/pyport_osx.diff
CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=${PREFIX_ext_python} ${GLOBAL_AUTOMAKE_PROFILE} --enable-shared
CONFIGURE_COMMAND <SOURCE_DIR>/configure MACOSX_DEPLOYMENT_TARGET=10.11 -prefix=${PREFIX_ext_python} ${GLOBAL_AUTOMAKE_PROFILE} --enable-shared
BUILD_COMMAND make
INSTALL_COMMAND make install
COMMAND ${CMAKE_COMMAND} -E copy ${PREFIX_ext_python}/bin/python3 ${PREFIX_ext_python}/bin/python
......
......@@ -100,7 +100,7 @@ MACRO(ADD_SIP_PYTHON_MODULE MODULE_NAME MODULE_SIP)
DEPENDS ${_abs_module_sip} ${SIP_EXTRA_FILES_DEPEND}
)
# not sure if type MODULE could be uses anywhere, limit to cygwin for now
IF (WIN32 OR CYGWIN)
IF (WIN32 OR CYGWIN OR APPLE)
ADD_LIBRARY(${_logical_name} MODULE ${_sip_output_files} )
ELSE (WIN32 OR CYGWIN)
ADD_LIBRARY(${_logical_name} SHARED ${_sip_output_files} )
......
......@@ -257,7 +257,7 @@ QString Python::lastTraceback() const
bool Python::libraryLoad()
{
// no-op on Windows
#ifndef Q_OS_WIN
#ifdef Q_OS_LINUX
if (!s_pythonLibrary) {
QFileInfo fi(PYKRITA_PYTHON_LIBRARY);
......@@ -307,8 +307,8 @@ namespace
QString findKritaPythonLibsPath(const QString &libdir)
{
QDir rootDir(KoResourcePaths::getApplicationRoot());
//Q_FOREACH (const QFileInfo &entry, rootDir.entryInfoList(QStringList() << "lib*", QDir::Dirs)) {
Q_FOREACH (const QFileInfo &entry, rootDir.entryInfoList(QStringList() << "lib*", QDir::Dirs | QDir::NoDotAndDotDot)) {
QFileInfoList candidates = rootDir.entryInfoList(QStringList() << "lib*", QDir::Dirs | QDir::NoDotAndDotDot) + rootDir.entryInfoList(QStringList() << "Frameworks", QDir::Dirs | QDir::NoDotAndDotDot);
Q_FOREACH (const QFileInfo &entry, candidates) {
QDir libDir(entry.absoluteFilePath());
if (libDir.cd(libdir)) {
return libDir.absolutePath();
......@@ -330,19 +330,26 @@ QString findKritaPythonLibsPath(const QString &libdir)
bool Python::setPath(const QStringList& scriptPaths)
{
KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(!Py_IsInitialized(), false);
KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(!isPythonPathSet, false);
bool runningInBundle = (KoResourcePaths::getApplicationRoot().toLower().contains(".mount_krita") || KoResourcePaths::getApplicationRoot().toLower().contains("krita.app"));
qDebug() << "Python::setPath. Script paths:" << scriptPaths << runningInBundle;
#ifdef Q_OS_WIN
constexpr char pathSeparator = ';';
#else
constexpr char pathSeparator = ':';
#endif
QString originalPath;
// Start with the script paths
QStringList paths(scriptPaths);
// Append the Krita libraries path
QString pythonLibsPath = findKritaPythonLibsPath("krita-python-libs");
qDebug() << "pythonLibsPath (krita-python-libs)" << pythonLibsPath;
if (pythonLibsPath.isEmpty()) {
dbgScript << "Cannot find krita-python-libs";
return false;
......@@ -350,9 +357,10 @@ bool Python::setPath(const QStringList& scriptPaths)
dbgScript << "Found krita-python-libs at" << pythonLibsPath;
paths.append(pythonLibsPath);
#ifdef Q_OS_LINUX
// Append the Krita libraries path
#ifndef Q_OS_WIN
// Append the sip libraries path
pythonLibsPath = findKritaPythonLibsPath("sip");
qDebug() << "pythonLibsPath (sip)" << pythonLibsPath;
if (!pythonLibsPath.isEmpty()) {
dbgScript << "Found sip at" << pythonLibsPath;
paths.append(pythonLibsPath);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment