Commit 871a7082 authored by Alvin Wong's avatar Alvin Wong

Change Python libraries install location

This moves the Python libraries install location to
`${LIB_INSTALL_DIR}/krita-python-libs`, separated from the bundled
Python plugins in `share/krita/pykrita`.

Maniphest Tasks: T1625
Differential Revision: https://phabricator.kde.org/D9582
parent 98415f26
......@@ -5,7 +5,6 @@ if (UNIX)
message("WARNING: using system python3!")
SET(PYTHON_EXECUTABLE_PATH python3)
endif()
ExternalProject_Add( ext_pyqt
DOWNLOAD_DIR ${EXTERNALS_DOWNLOAD_DIR}
URL http://files.kde.org/krita/build/dependencies/PyQt5_gpl-5.6.tar.gz
......@@ -30,8 +29,8 @@ elseif(MINGW)
--spec win32-g++
--verbose
--sipdir ${PREFIX_ext_pyqt}/share/sip
--destdir ${PREFIX_ext_pyqt}/share/krita/pykrita
--stubsdir ${PREFIX_ext_pyqt}/share/krita/pykrita/PyQt5
--destdir ${PREFIX_ext_pyqt}/lib/krita-python-libs
--stubsdir ${PREFIX_ext_pyqt}/lib/krita-python-libs/PyQt5
--no-qml-plugin --no-python-dbus --no-qsci-api --no-tools
--disable QtSql --disable QtTest --disable QtWinExtras
)
......
......@@ -23,7 +23,7 @@ elseif (MINGW)
list(APPEND _SIP_conf
--platform win32-g++
-b ${PREFIX_ext_sip}/bin
-d ${PREFIX_ext_sip}/share/krita/pykrita
-d ${PREFIX_ext_sip}/lib/krita-python-libs
-e ${PREFIX_ext_sip}/include
--sipdir ${PREFIX_ext_sip}/share/sip
--target-py-version 3.6
......
......@@ -31,7 +31,7 @@ ELSE(EXISTS PYQT5_VERSION)
if (WIN32)
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_PREFIX_PATH}/share/krita/pykrita" ${PYTHON_EXECUTABLE} ${_find_pyqt5_py} OUTPUT_VARIABLE pyqt5_config)
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_PREFIX_PATH}/lib/krita-python-libs" ${PYTHON_EXECUTABLE} ${_find_pyqt5_py} OUTPUT_VARIABLE pyqt5_config)
else (WIN32)
EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} ${_find_pyqt5_py} OUTPUT_VARIABLE pyqt5_config)
endif (WIN32)
......
......@@ -34,7 +34,7 @@ ELSE(SIP_VERSION)
FIND_FILE(_find_sip_py FindSIP.py PATHS ${CMAKE_MODULE_PATH})
if (WIN32)
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_PREFIX_PATH}/share/krita/pykrita" ${PYTHON_EXECUTABLE} ${_find_sip_py} OUTPUT_VARIABLE sip_config)
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_PREFIX_PATH}/lib/krita-python-libs" ${PYTHON_EXECUTABLE} ${_find_sip_py} OUTPUT_VARIABLE sip_config)
else (WIN32)
EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} ${_find_sip_py} OUTPUT_VARIABLE sip_config)
endif (WIN32)
......
......@@ -593,6 +593,7 @@ for /f "delims=" %%F in ('dir /b "%DEPS_INSTALL_DIR%\translations\qt_*.qm"') do
endlocal
:: Krita plugins
xcopy /Y %KRITA_INSTALL_DIR%\lib\kritaplugins\*.dll %pkg_root%\lib\kritaplugins\
xcopy /Y /S /I %KRITA_INSTALL_DIR%\lib\krita-python-libs %pkg_root%\lib\krita-python-libs
:: Share
xcopy /Y /S /I %KRITA_INSTALL_DIR%\share\color %pkg_root%\share\color
......@@ -680,6 +681,11 @@ for /r "%pkg_root%\share\krita\pykrita\" %%F in (*.pyd) do (
set relpath=!relpath:~%pkg_root_len_plus_one%!
call :split-debug "%%F" !relpath!
)
for /r "%pkg_root%\lib\krita-python-libs\" %%F in (*.pyd) do (
set relpath=%%F
set relpath=!relpath:~%pkg_root_len_plus_one%!
call :split-debug "%%F" !relpath!
)
endlocal
if not "%ARG_PRE_ZIP_HOOK%" == "" (
......
......@@ -35,7 +35,7 @@ install(TARGETS kritapykrita DESTINATION ${KRITA_PLUGIN_INSTALL_DIR})
# Install "built-in" api
install(
DIRECTORY krita
DESTINATION ${DATA_INSTALL_DIR}/krita/pykrita
DESTINATION ${LIB_INSTALL_DIR}/krita-python-libs
FILES_MATCHING PATTERN "*.py"
)
......
......@@ -279,6 +279,33 @@ bool Python::libraryLoad()
return true;
}
namespace
{
QString findKritaPythonLibsPath()
{
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)) {
QDir libDir(entry.absoluteFilePath());
if (libDir.cd("krita-python-libs")) {
return libDir.absolutePath();
} else {
// Handle cases like Linux where libs are placed in a sub-dir
// with the ABI name
Q_FOREACH (const QFileInfo &subEntry, libDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot)) {
QDir subDir(subEntry.absoluteFilePath());
if (subDir.cd("krita-python-libs")) {
return subDir.absolutePath();
}
}
}
}
return QString();
}
} // namespace
bool Python::setPath(const QStringList& scriptPaths)
{
KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(!Py_IsInitialized(), false);
......@@ -292,6 +319,15 @@ bool Python::setPath(const QStringList& scriptPaths)
// Start with the script paths
QStringList paths(scriptPaths);
// Append the Krita libraries path
QString pythonLibsPath = findKritaPythonLibsPath();
if (pythonLibsPath.isEmpty()) {
errScript << "Cannot find krita-python-libs";
return false;
}
dbgScript << "Found krita-python-libs at" << pythonLibsPath;
paths.append(pythonLibsPath);
#ifdef Q_OS_WIN
// Find embeddable Python at <root>/python
QDir pythonDir(KoResourcePaths::getApplicationRoot());
......
......@@ -18,7 +18,7 @@ set(SIP_CONCAT_PARTS 1)
set(SIP_TAGS ALL WS_X11 ${PYQT5_VERSION_TAG})
set(SIP_EXTRA_OPTIONS -g -x PyKDE_QVector)
set(PYTHON_SITE_PACKAGES_INSTALL_DIR ${DATA_INSTALL_DIR}/krita/pykrita/)
set(PYTHON_SITE_PACKAGES_INSTALL_DIR ${LIB_INSTALL_DIR}/krita-python-libs)
file(GLOB PYKRITA_KRITA_sip_files ./krita/*.sip)
set(SIP_EXTRA_FILES_DEPEND ${PYKRITA_KRITA_sip_files})
add_sip_python_module(PyKrita.krita ./krita/kritamod.sip kritalibkis kritaui kritaimage kritalibbrush)
......
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