Commit 32d09e73 authored by Amyspark's avatar Amyspark
Browse files

macOS: add PyQt5/SIP v5 support

This needed the following additional changes:

- Python needs full OpenSSL support for distutil/setuptools
- Enable ensurepip so that sipbuild can install its dependencies
- Python.framework ignores PYTHONPATH, so add our site-packages to sitecustomize
- Synchronize all OSX deployment target versions
- Ensure make install runs with j1 (install race conditions)
- Point the site-packages symlink to the Framework directory
- osxdeploy: Fix the site-packages paths and also trim pip, PyQt_builder, and sipbuild.
parent 1186c1cb
......@@ -198,6 +198,7 @@ if (MINGW)
endif ()
# this list must be dependency-ordered
add_subdirectory( ext_openssl )
if (ENABLE_PYTHON_DEPS OR NOT MINGW)
add_subdirectory( ext_python )
endif ()
......@@ -223,7 +224,6 @@ add_subdirectory( ext_expat ) # for exiv2
add_subdirectory( ext_exiv2 )
add_subdirectory( ext_lcms2 )
add_subdirectory( ext_openexr )
add_subdirectory( ext_openssl )
add_subdirectory( ext_vc )
add_subdirectory( ext_gsl )
add_subdirectory( ext_fftw3 )
......
SET(PREFIX_ext_pyqt "${EXTPREFIX}" )
if (APPLE)
SET(PYTHON_EXECUTABLE_PATH ${PREFIX_ext_pyqt}/bin/python3)
if(NOT EXISTS ${PYTHON_EXECUTABLE_PATH})
message("WARNING: using system python3!")
SET(PYTHON_EXECUTABLE_PATH python3)
endif()
list(APPEND _PYQT_conf
--confirm-license
--qmake ${PREFIX_ext_pyqt}/bin/qmake
--sip ${PREFIX_ext_pyqt}/bin/sip
--sip-incdir ${PREFIX_ext_pyqt}/include
--sipdir ${PREFIX_ext_pyqt}/share/sip
)
ExternalProject_Add( ext_pyqt
DOWNLOAD_DIR ${EXTERNALS_DOWNLOAD_DIR}
URL https://files.kde.org/krita/build/dependencies/PyQt5_gpl-5.13.1.tar.gz
URL_MD5 c77af2f4e230b0053fd22bc2ece2e6c0
CONFIGURE_COMMAND ${PYTHON_EXECUTABLE_PATH} <SOURCE_DIR>/configure.py ${_PYQT_conf}
BUILD_COMMAND make
# force single-threaded installation to avoid
# race conditions in post-install .py script
INSTALL_COMMAND make -j1 install
BUILD_IN_SOURCE 1
UPDATE_COMMAND ""
)
elseif(UNIX)
if(UNIX)
SET(PYTHON_EXECUTABLE_PATH ${PREFIX_ext_pyqt}/bin/python3)
if(NOT EXISTS ${PYTHON_EXECUTABLE_PATH})
message("WARNING: using system python3!")
......@@ -57,7 +27,7 @@ elseif(UNIX)
URL https://pypi.python.org/packages/source/P/PyQt5/PyQt5-5.15.4.tar.gz
URL_HASH SHA256=2a69597e0dd11caabe75fae133feca66387819fc9bc050f547e5551bce97e5be
CONFIGURE_COMMAND sip-build --confirm-license --no-designer-plugin --no-qml-plugin --no-dbus-python --no-tools --no-make --jobs ${SUBMAKE_JOBS}
CONFIGURE_COMMAND ${PREFIX_ext_pyqt}/bin/sip-build --confirm-license --no-designer-plugin --no-qml-plugin --no-dbus-python --no-tools --no-make --jobs ${SUBMAKE_JOBS}
BUILD_COMMAND ${CMAKE_COMMAND} -E chdir <SOURCE_DIR>/build make -j${SUBMAKE_JOBS}
......@@ -81,10 +51,11 @@ elseif(UNIX)
BUILD_COMMAND ${PYTHON_EXECUTABLE_PATH} <SOURCE_DIR>/setup.py build ${_compiler} -j ${SUBMAKE_JOBS}
# distutils already specifies the full path to the AppImage root
# it trims the first path separator and appends the rest to the root below
# if this is not set, it doesn't install the egg within site-packages
INSTALL_COMMAND ${PYTHON_EXECUTABLE_PATH} <SOURCE_DIR>/setup.py install --root=/
# Here we need a flat-egg installation, otherwise the egg is deployed
# inside its own directory in site-packages.
# So we set as root our 3rdparty layout, and a sufficiently dud prefix.
# See https://github.com/msys2/MINGW-packages/blob/8a4066591cf1e023971526c55bf2d5fe0c7aa84a/mingw-w64-pyqt5-sip/PKGBUILD
INSTALL_COMMAND ${PYTHON_EXECUTABLE_PATH} <SOURCE_DIR>/setup.py install --prefix "." --root=${PREFIX_ext_pyqt} --optimize=1
BUILD_IN_SOURCE 1
......
......@@ -9,13 +9,14 @@ if (UNIX)
PATCH_COMMAND ${PATCH_COMMAND} -p1 -i ${CMAKE_CURRENT_SOURCE_DIR}/osx_fixappinstall.diff
CONFIGURE_COMMAND <SOURCE_DIR>/configure MACOSX_DEPLOYMENT_TARGET=10.13 --prefix=${PREFIX_ext_python} ${GLOBAL_AUTOMAKE_PROFILE}
--without-ensurepip --enable-framework=${PREFIX_ext_python}/lib --enable-optimizations
# Setuptools needs OpenSSL 1.1, the stock libssl isn't enough
CONFIGURE_COMMAND <SOURCE_DIR>/configure MACOSX_DEPLOYMENT_TARGET=10.13 --prefix=${PREFIX_ext_python} ${GLOBAL_AUTOMAKE_PROFILE} --with-openssl=${PREFIX_ext_python}
--enable-framework=${PREFIX_ext_python}/lib --enable-optimizations
BUILD_COMMAND make
INSTALL_COMMAND make install
INSTALL_COMMAND make -j1 install
COMMAND ${CMAKE_COMMAND} -E copy ${PREFIX_ext_python}/bin/python3 ${PREFIX_ext_python}/bin/python
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/sitecustomize.py ${PREFIX_ext_python}/lib/Python.framework/Versions/Current/lib/python${PYTHON_VERSION}/
COMMAND ${CMAKE_COMMAND} -E create_symlink ./lib/python${PYTHON_VERSION}/site-packages ${PREFIX_ext_python}/lib/Python.framework/Versions/Current/site-packages
COMMAND ${CMAKE_COMMAND} -E create_symlink ${PREFIX_ext_python}/lib/Python.framework/Versions/Current/lib/python${PYTHON_VERSION} ${PREFIX_ext_python}/lib/python${PYTHON_VERSION}
# CMake FindPythonLib can't find framework libraries, lack of maintainer for Python
COMMAND find ${PREFIX_ext_python}/lib/Python.framework/Versions/Current/lib -type l -d 1
| grep -o "[^/]*$"
......@@ -23,6 +24,8 @@ if (UNIX)
UPDATE_COMMAND ""
ALWAYS 0
DEPENDS ext_openssl
)
else()
......
import os
import site
import sysconfig
framework_path = os.path.dirname(os.path.abspath(__file__))
data_path = sysconfig.get_paths()['data']
site.addsitedir(os.path.join(data_path, 'site-packages'))
site.addsitedir(os.path.join(framework_path,'site-packages'))
site.addsitedir(os.path.join(framework_path,'site-packages', 'PyQt5'))
SET(PREFIX_ext_sip "${EXTPREFIX}" )
if (UNIX)
if(NOT APPLE)
SET(PYTHON_EXECUTABLE_PATH ${PREFIX_ext_sip}/bin/python3)
if(NOT EXISTS ${PYTHON_EXECUTABLE_PATH})
message("WARNING: using system python3!")
SET(PYTHON_EXECUTABLE_PATH python3)
endif()
ExternalProject_Add( ext_sip
DOWNLOAD_DIR ${EXTERNALS_DOWNLOAD_DIR}
URL https://pypi.python.org/packages/source/s/sip/sip-6.1.0.tar.gz
URL_HASH SHA256=f069d550dd819609e019e5dc58fc5193e081c7f3fb4f7dc8f9be734e34d4e56e
CONFIGURE_COMMAND ""
BUILD_COMMAND ${PYTHON_EXECUTABLE_PATH} <SOURCE_DIR>/setup.py build -j ${SUBMAKE_JOBS}
INSTALL_COMMAND ${PYTHON_EXECUTABLE_PATH} <SOURCE_DIR>/setup.py install --skip-build --prefix=${PREFIX_ext_sip} --optimize=1
BUILD_IN_SOURCE 1
set(PYTHON_EXECUTABLE_PATH ${PREFIX_ext_sip}/bin/python3)
if(NOT EXISTS ${PYTHON_EXECUTABLE_PATH})
message("WARNING: using system python3!")
set(PYTHON_EXECUTABLE_PATH python3)
endif()
UPDATE_COMMAND ""
)
else(APPLE)
if(NOT PYTHONINTERP_FOUND)
SET(PYTHON_EXECUTABLE ${PREFIX_ext_sip}/bin/python3)
if(NOT EXISTS "${PYTHON_EXECUTABLE}")
message("WARNING: using system python3!")
SET(PYTHON_EXECUTABLE python3)
endif()
endif()
ExternalProject_Add( ext_sip
DOWNLOAD_DIR ${EXTERNALS_DOWNLOAD_DIR}
URL https://pypi.python.org/packages/source/s/sip/sip-6.1.0.tar.gz
URL_HASH SHA256=f069d550dd819609e019e5dc58fc5193e081c7f3fb4f7dc8f9be734e34d4e56e
ExternalProject_Add( ext_sip
DOWNLOAD_DIR ${EXTERNALS_DOWNLOAD_DIR}
URL https://files.kde.org/krita/build/dependencies/sip-4.19.19.tar.gz
URL_MD5 98111479309dc472410f26080d6d4a88
CONFIGURE_COMMAND ""
CMAKE_ARGS -DPYTHON_INCLUDE_DIR=${PREFIX_ext_sip}/lib/Python.framework/Headers
CONFIGURE_COMMAND ${PYTHON_EXECUTABLE} <SOURCE_DIR>/configure.py --deployment-target=10.11
-b ${PREFIX_ext_sip}/bin -d ${PREFIX_ext_sip}/lib/Python.framework/Versions/Current/site-packages/
-e ${PREFIX_ext_sip}/include --sipdir ${PREFIX_ext_sip}/share/sip --target-py-version 3.8 --sip-module PyQt5.sip
BUILD_COMMAND make
BUILD_COMMAND ${PYTHON_EXECUTABLE_PATH} <SOURCE_DIR>/setup.py build -j ${SUBMAKE_JOBS}
# force single-threaded installation to avoid
# race conditions in post-install .py script
INSTALL_COMMAND make -j1 install
# COMMAND ${CMAKE_COMMAND} -E create_symlink ./PyQt5/sip.so ${PREFIX_ext_sip}/lib/Python.framework/Versions/Current/site-packages/sip.so
# COMMAND ${CMAKE_COMMAND} -E create_symlink ./PyQt5/sip.pyi ${PREFIX_ext_sip}/lib/Python.framework/Versions/Current/site-packages/sip.pyi
INSTALL_COMMAND ${PYTHON_EXECUTABLE_PATH} <SOURCE_DIR>/setup.py install --skip-build --prefix=${PREFIX_ext_sip} --optimize=1
BUILD_IN_SOURCE 1
BUILD_IN_SOURCE 1
UPDATE_COMMAND ""
)
endif()
UPDATE_COMMAND ""
)
elseif (WIN32)
if(MINGW)
set(_compiler -c mingw32)
......
......@@ -94,7 +94,7 @@ export LIBRARY_PATH=${KIS_INSTALL_DIR}/lib:/usr/lib:${LIBRARY_PATH}
export FRAMEWORK_PATH=${KIS_INSTALL_DIR}/lib/
# export PYTHONHOME=${KIS_INSTALL_DIR}
# export PYTHONPATH=${KIS_INSTALL_DIR}/sip:${KIS_INSTALL_DIR}/lib/python3.8/site-packages:${KIS_INSTALL_DIR}/lib/python3.8
# export PYTHONPATH=${KIS_INSTALL_DIR}/sip:${KIS_INSTALL_DIR}/lib/python3.9/site-packages:${KIS_INSTALL_DIR}/lib/python3.9
# This will make the debug output prettier
export KDE_COLOR_DEBUG=1
......
......@@ -373,6 +373,9 @@ strip_python_dmginstall() {
cd "${PythonFrameworkBase}/Versions/${PY_VERSION}/lib/python${PY_VERSION}"
rm -rf distutils tkinter ensurepip venv lib2to3 idlelib turtledemo
cd "${PythonFrameworkBase}/Versions/${PY_VERSION}/lib/python${PY_VERSION}/site-packages"
rm -rf pip* PyQt_builder* setuptools* sip* easy-install.pth
cd "${PythonFrameworkBase}/Versions/${PY_VERSION}/Resources"
rm -rf Python.app
}
......@@ -417,7 +420,7 @@ fix_python_framework() {
# Fix rpaths from Python.Framework
find "${PythonFrameworkBase}" -type f -perm 755 | delete_install_rpath
find "${PythonFrameworkBase}/Versions/Current/site-packages/PyQt5" -type f -name "*.so" | delete_install_rpath
find "${PythonFrameworkBase}/Versions/Current/lib/python${PY_VERSION}/site-packages/PyQt5" -type f -name "*.so" | delete_install_rpath
}
# Checks for macdeployqt
......
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