python3-PyQt5: build with sip-build

This commit is contained in:
Đoàn Trần Công Danh 2020-09-27 14:14:53 +07:00
parent 18c02200ae
commit ca41d253f5
2 changed files with 183 additions and 90 deletions

View File

@ -0,0 +1,18 @@
--- project.py.orig 2020-09-27 14:28:27.338774698 +0700
+++ project.py 2020-09-27 14:28:29.317795099 +0700
@@ -51,6 +51,15 @@
_QOpenGLFunctions_2_1, _QOpenGLFunctions_4_1_Core,
_QOpenGLFunctions_ES2, pylupdate, pyrcc]
+ def run_command(self, args, *, fatal=True):
+ """ Run a command and display the output if requested. """
+ qemu_machine = os.environ.get("XBPS_TARGET_QEMU_MACHINE")
+ builddir = os.environ.get("XBPS_BUILDDIR")
+ if qemu_machine and args[0].startswith(os.path.join(builddir, "PyQt5")):
+ qemu = "qemu-{}-static".format(qemu_machine)
+ args.insert(0, qemu)
+ super().run_command(args, fatal=fatal)
+
def apply_user_defaults(self, tool):
""" Set default values where needed. """

View File

@ -1,11 +1,12 @@
# Template file for 'python3-PyQt5'
pkgname=python3-PyQt5
version=5.15.0
revision=1
_sipver=4.19.23
revision=2
_sipver=12.8.0
wrksrc="PyQt5-${version}"
hostmakedepends="pkg-config
python3-devel sip5 python-dbus-devel qt5 qt5-devel qt5-tools-devel
build_helper=qemu
hostmakedepends="pkg-config qscintilla-qt5-devel python3-sip-PyQt5
python3-devel python-dbus-devel qt5 qt5-devel qt5-tools-devel python3-PyQt-builder
qt5-connectivity-devel qt5-declarative-devel qt5-location-devel
qt5-multimedia-devel qt5-qmake qt5-sensors-devel qt5-serialport-devel
qt5-svg-devel qt5-webchannel-devel qt5-webkit-devel qt5-websockets-devel
@ -24,51 +25,151 @@ post_extract() {
rm -rf pyuic/uic/port_v2
}
_cross_configure() {
local qplatformdefs="/usr/lib/qt5/mkspecs/linux-g++/qplatformdefs.h"
mkdir -p "${wrksrc}/.target-spec/linux-g++"
cat >"${wrksrc}/.target-spec/linux-g++/qmake.conf" <<-_EOF
MAKEFILE_GENERATOR = UNIX
CONFIG += incremental
QMAKE_INCREMENTAL_STYLE = sublib
include(/usr/lib/qt5/mkspecs/common/linux.conf)
include(/usr/lib/qt5/mkspecs/common/gcc-base-unix.conf)
include(/usr/lib/qt5/mkspecs/common/g++-unix.conf)
QMAKE_TARGET_CONFIG = ${XBPS_CROSS_BASE}/usr/lib/qt5/mkspecs/qconfig.pri
QMAKE_TARGET_MODULE = ${XBPS_CROSS_BASE}/usr/lib/qt5/mkspecs/qmodule.pri
QMAKE_CC = ${CC}
QMAKE_CXX = ${CXX}
QMAKE_LINK = ${CXX}
QMAKE_LINK_C = ${CC}
QMAKE_LINK_SHLIB = ${CXX}
QMAKE_AR = ${XBPS_CROSS_TRIPLET}-gcc-ar cqs
QMAKE_OBJCOPY = ${OBJCOPY}
QMAKE_NM = ${NM} -P
QMAKE_STRIP = ${STRIP}
QMAKE_CFLAGS = ${CFLAGS}
QMAKE_CXXFLAGS = ${CXXFLAGS}
QMAKE_LFLAGS = ${LDFLAGS}
load(qt_config)
_EOF
ln -sf ${XBPS_CROSS_BASE}$qplatformdefs ${wrksrc}/.target-spec/linux-g++/
mkdir -p "${wrksrc}/.host-spec/linux-g++"
cat > "${wrksrc}/.host-spec/linux-g++/qmake.conf" <<-_EOF
MAKEFILE_GENERATOR = UNIX
CONFIG += incremental
QMAKE_INCREMENTAL_STYLE = sublib
include(/usr/lib/qt5/mkspecs/common/linux.conf)
include(/usr/lib/qt5/mkspecs/common/gcc-base-unix.conf)
include(/usr/lib/qt5/mkspecs/common/g++-unix.conf)
QMAKE_TARGET_CONFIG = ${XBPS_CROSS_BASE}/usr/lib/qt5/mkspecs/qconfig.pri
QMAKE_TARGET_MODULE = ${XBPS_CROSS_BASE}/usr/lib/qt5/mkspecs/qmodule.pri
QMAKE_CC = ${CC_FOR_BUILD}
QMAKE_CXX = ${CXX_FOR_BUILD}
QMAKE_LINK = ${CXX_FOR_BUILD}
QMAKE_LINK_C = ${CC_FOR_BUILD}
QMAKE_LINK_SHLIB = ${CXX_FOR_BUILD}
QMAKE_AR = gcc-ar cqs
QMAKE_OBJCOPY = ${OBJCOPY_FOR_BUILD}
QMAKE_NM = ${NM_FOR_BUILD} -P
QMAKE_STRIP = ${STRIP_FOR_BUILD}
QMAKE_CFLAGS = ${CFLAGS_FOR_BUILD}
QMAKE_CXXFLAGS = ${CXXFLAGS_FOR_BUILD}
QMAKE_LFLAGS = ${LDFLAGS_FOR_BUILD}
load(qt_config)
_EOF
ln -sf $qplatformdefs ${wrksrc}/.host-spec/linux-g++/
cat >"${wrksrc}/qt.conf" <<-_EOF
[Paths]
Sysroot=${XBPS_CROSS_BASE}
Prefix=/usr
ArchData=/usr/lib/qt5
Data=/usr/share/qt5
Documentation=/usr/share/doc/qt5
Headers=${XBPS_CROSS_BASE}/usr/include/qt5
Libraries=${XBPS_CROSS_BASE}/usr/lib
LibraryExecutables=/usr/lib/qt5/libexec
Binaries=/usr/lib/qt5/bin
Tests=${XBPS_CROSS_BASE}/usr/tests
Plugins=/usr/lib/qt5/plugins
Imports=${XBPS_CROSS_BASE}/usr/lib/qt5/imports
Qml2Imports=${XBPS_CROSS_BASE}/usr/lib/qt5/qml
Translations=${XBPS_CROSS_BASE}/usr/share/qt5/translations
Settings=${XBPS_CROSS_BASE}/etc/xdg
Examples=${XBPS_CROSS_BASE}/usr/share/qt5/examples
HostPrefix=/usr
HostData=/usr/lib/qt5
HostBinaries=/usr/lib/qt5/bin
HostLibraries=/usr/lib
Spec=$wrksrc/.host-spec/linux-g++
TargetSpec=$wrksrc/.target-spec/linux-g++
_EOF
case $XBPS_TARGET_MACHINE in
i686*) _qt_arch=i386;;
x86_64*) _qt_arch=x86_64;;
aarch64*) _qt_arch=arm64;;
arm*) _qt_arch=arm;;
mips*) _qt_arch=mips;;
esac
cat >$XBPS_WRAPPERDIR/qmake <<_EOF
#!/bin/sh
export PREFIX=/usr
export QT_INSTALL_PREFIX=/usr
export LIB=/usr/lib
export QT_TARGET_ARCH=$_qt_arch
export PKG_CONFIG_EXECUTABLE=$XBPS_WRAPPERDIR/$PKG_CONFIG
case " \$* " in
" -query ")
/usr/lib/qt5/bin/qmake "\$@" -qtconf $wrksrc/qt.conf |
sed '/^QT_INSTALL_/s,$XBPS_CROSS_BASE,,'
;;
*)
exec /usr/lib/qt5/bin/qmake -qtconf $wrksrc/qt.conf "\$@" ;;
esac
_EOF
chmod +x $XBPS_WRAPPERDIR/qmake
}
do_configure() {
local _sysroot= _configuration= qt_version
if [ "$CROSS_BUILD" ]; then
qt_version=$(qmake -query QT_VERSION)
_sysroot="--sysroot $XBPS_CROSS_BASE"
_configuration="--configuration $wrksrc/pyqt5_${XBPS_CROSS_TRIPLET}.cfg"
cat >pyqt5_${XBPS_CROSS_TRIPLET}.cfg <<EOF
py_platform = linux
py_inc_dir = %(sysroot)/usr/include/python%(py_major).%(py_minor)${py3_abiver}
py_pyshlib = python%(py_major).%(py_minor)${py3_abiver}.so
pyqt_disabled_features = PyQt_Desktop_OpenGL
qt_shared = True
[Qt ${qt_version}]
# _QOpenGLFunctions_ES2 doesn't work
pyqt_modules = QtCore QtGui QtHelp QtMultimedia
QtMultimediaWidgets QtNetwork QtOpenGL QtPrintSupport QtQml QtQuick
QtSql QtSvg QtTest QtWebKit QtWebKitWidgets QtWidgets QtXml
QtXmlPatterns QtDesigner QtDBus QtSensors QtSerialPort
QtX11Extras QtBluetooth QtPositioning QtQuickWidgets QtWebSockets
QtWebChannel QtLocation QtNfc QtNetworkAuth
EOF
_cross_configure
fi
python3 configure.py --confirm-license --assume-shared \
$_sysroot $_configuration \
QMAKE_CC="${CC}" QMAKE_CFLAGS="${CFLAGS}" \
QMAKE_CXX="${CXX}" QMAKE_CXXFLAGS="${CXXFLAGS}" \
QMAKE_LINK="${CXX}" QMAKE_LINK_SHLIB="${CXX}" \
QMAKE_LFLAGS="${LDFLAGS}" QMAKE_STRIP=""
mkdir -p build
sip-build --confirm-license --no-make \
--api-dir /usr/share/qt5/qsci/api/python \
--build-dir build
if [ "$CROSS_BUILD" ]; then
# Fix location of libraries
find . -name Makefile |
xargs sed -i -E "s|(/usr/lib/libQt5[^ ]+so)|${XBPS_CROSS_BASE}\1|g"
find build -name Makefile |
xargs sed -i "
s, \\(/usr/lib/libQt\\), $XBPS_CROSS_BASE\\1,g
s,-L\\(/usr/lib\\),-L$XBPS_CROSS_BASE\\1,g
/INSTALL_ROOT/s,$XBPS_CROSS_BASE,,g
s,-I\\(/usr/include\\),-I$XBPS_CROSS_BASE\\1,g
s,-I\\(/usr/lib\\),-I$XBPS_CROSS_BASE\\1,g
"
fi
}
do_build() {
cd build
make ${makejobs}
}
do_install() {
cd build
make DESTDIR=${DESTDIR} INSTALL_ROOT=${DESTDIR} install
for f in pylupdate5 pyrcc5 pyuic5; do
sed -i '1s,python3[.0-9]*,python3,' ${DESTDIR}/usr/bin/${f}
@ -85,19 +186,16 @@ python3-PyQt5-devel-tools_package() {
pyqt5:pyrcc5:/usr/bin/python3-pyrcc5
pyqt5:pyuic5:/usr/bin/python3-pyuic5"
pkg_install() {
vmove usr/bin/python3-*
vmove ${py3_sitelib}/PyQt5/pylupdate.so
vmove ${py3_sitelib}/PyQt5/pylupdate_main.py
vmove ${py3_sitelib}/PyQt5/pyrcc.so
vmove ${py3_sitelib}/PyQt5/pyrcc_main.py
vmove usr/bin
vmove "${py3_sitelib}/PyQt5/pylupdate*"
vmove "${py3_sitelib}/PyQt5/pyrcc*"
}
}
python3-PyQt5-devel_package() {
depends="sip5 python3-PyQt5-${version}_${revision}"
short_desc+=" - development files"
conflicts="python-PyQt5-devel>=0"
pkg_install() {
vmove usr/share/sip
vmove ${py3_sitelib}/PyQt5/bindings
}
}
python3-PyQt5-dbus_package() {
@ -105,7 +203,7 @@ python3-PyQt5-dbus_package() {
depends="python3-PyQt5-${version}_${revision} python3-dbus"
short_desc="${short_desc} - dbus support"
pkg_install() {
vmove ${py3_sitelib}/dbus/mainloop/pyqt5.so
vmove ${py3_sitelib}/dbus
}
}
python3-PyQt5-connectivity_package() {
@ -113,10 +211,8 @@ python3-PyQt5-connectivity_package() {
depends="python3-PyQt5-${version}_${revision}"
short_desc="${short_desc} - connectivity module"
pkg_install() {
vmove ${py3_sitelib}/PyQt5/QtBluetooth.pyi
vmove ${py3_sitelib}/PyQt5/QtBluetooth.so
vmove ${py3_sitelib}/PyQt5/QtNfc.pyi
vmove ${py3_sitelib}/PyQt5/QtNfc.so
vmove "${py3_sitelib}/PyQt5/QtBluetooth.*"
vmove "${py3_sitelib}/PyQt5/QtNfc.*"
}
}
python3-PyQt5-multimedia_package() {
@ -124,10 +220,8 @@ python3-PyQt5-multimedia_package() {
depends="python3-PyQt5-${version}_${revision}"
short_desc="${short_desc} - multimedia module"
pkg_install() {
vmove ${py3_sitelib}/PyQt5/QtMultimedia.pyi
vmove ${py3_sitelib}/PyQt5/QtMultimedia.so
vmove ${py3_sitelib}/PyQt5/QtMultimediaWidgets.pyi
vmove ${py3_sitelib}/PyQt5/QtMultimediaWidgets.so
vmove "${py3_sitelib}/PyQt5/QtMultimedia.*"
vmove "${py3_sitelib}/PyQt5/QtMultimediaWidgets.*"
}
}
python3-PyQt5-networkauth_package() {
@ -135,8 +229,7 @@ python3-PyQt5-networkauth_package() {
depends="python3-PyQt5-${version}_${revision}"
short_desc="${short_desc} - networkauth module"
pkg_install() {
vmove ${py3_sitelib}/PyQt5/QtNetworkAuth.pyi
vmove ${py3_sitelib}/PyQt5/QtNetworkAuth.so
vmove "${py3_sitelib}/PyQt5/QtNetworkAuth.*"
}
}
python3-PyQt5-opengl_package() {
@ -144,10 +237,9 @@ python3-PyQt5-opengl_package() {
depends="python3-PyQt5-${version}_${revision}"
short_desc="${short_desc} - opengl module"
pkg_install() {
vmove ${py3_sitelib}/PyQt5/QtOpenGL.pyi
vmove ${py3_sitelib}/PyQt5/QtOpenGL.so
vmove "${py3_sitelib}/PyQt5/QtOpenGL.*"
if [ -z "$CROSS_BUILD" ]; then
vmove ${py3_sitelib}/PyQt5/_QOpenGLFunctions_*.so
vmove "${py3_sitelib}/PyQt5/_QOpenGLFunctions_*"
fi
}
}
@ -156,10 +248,8 @@ python3-PyQt5-location_package() {
depends="python3-PyQt5-${version}_${revision}"
short_desc="${short_desc} - location module"
pkg_install() {
vmove ${py3_sitelib}/PyQt5/QtLocation.pyi
vmove ${py3_sitelib}/PyQt5/QtLocation.so
vmove ${py3_sitelib}/PyQt5/QtPositioning.pyi
vmove ${py3_sitelib}/PyQt5/QtPositioning.so
vmove "${py3_sitelib}/PyQt5/QtLocation.*"
vmove "${py3_sitelib}/PyQt5/QtPositioning.*"
}
}
python3-PyQt5-quick_package() {
@ -167,12 +257,9 @@ python3-PyQt5-quick_package() {
depends="python3-PyQt5-${version}_${revision}"
short_desc="${short_desc} - quick module"
pkg_install() {
vmove ${py3_sitelib}/PyQt5/QtQml.pyi
vmove ${py3_sitelib}/PyQt5/QtQml.so
vmove ${py3_sitelib}/PyQt5/QtQuick.pyi
vmove ${py3_sitelib}/PyQt5/QtQuick.so
vmove ${py3_sitelib}/PyQt5/QtQuickWidgets.pyi
vmove ${py3_sitelib}/PyQt5/QtQuickWidgets.so
vmove "${py3_sitelib}/PyQt5/QtQml.*"
vmove "${py3_sitelib}/PyQt5/QtQuick.*"
vmove "${py3_sitelib}/PyQt5/QtQuickWidgets.*"
vmove usr/lib/qt5/plugins/PyQt5/libpyqt5qmlplugin.so
}
}
@ -181,8 +268,7 @@ python3-PyQt5-sensors_package() {
depends="python3-PyQt5-${version}_${revision}"
short_desc="${short_desc} - sensors module"
pkg_install() {
vmove ${py3_sitelib}/PyQt5/QtSensors.pyi
vmove ${py3_sitelib}/PyQt5/QtSensors.so
vmove "${py3_sitelib}/PyQt5/QtSensors.*"
}
}
python3-PyQt5-serialport_package() {
@ -190,8 +276,7 @@ python3-PyQt5-serialport_package() {
depends="python3-PyQt5-${version}_${revision}"
short_desc="${short_desc} - serialport module"
pkg_install() {
vmove ${py3_sitelib}/PyQt5/QtSerialPort.pyi
vmove ${py3_sitelib}/PyQt5/QtSerialPort.so
vmove "${py3_sitelib}/PyQt5/QtSerialPort.*"
}
}
python3-PyQt5-sql_package() {
@ -199,8 +284,7 @@ python3-PyQt5-sql_package() {
depends="python3-PyQt5-${version}_${revision}"
short_desc="${short_desc} - sql module"
pkg_install() {
vmove ${py3_sitelib}/PyQt5/QtSql.pyi
vmove ${py3_sitelib}/PyQt5/QtSql.so
vmove "${py3_sitelib}/PyQt5/QtSql.*"
}
}
python3-PyQt5-svg_package() {
@ -208,8 +292,7 @@ python3-PyQt5-svg_package() {
depends="python3-PyQt5-${version}_${revision}"
short_desc="${short_desc} - svg module"
pkg_install() {
vmove ${py3_sitelib}/PyQt5/QtSvg.pyi
vmove ${py3_sitelib}/PyQt5/QtSvg.so
vmove "${py3_sitelib}/PyQt5/QtSvg.*"
}
}
python3-PyQt5-tools_package() {
@ -217,11 +300,9 @@ python3-PyQt5-tools_package() {
depends="python3-PyQt5-${version}_${revision}"
short_desc="${short_desc} - designer, help modules"
pkg_install() {
vmove ${py3_sitelib}/PyQt5/QtHelp.pyi
vmove ${py3_sitelib}/PyQt5/QtHelp.so
vmove ${py3_sitelib}/PyQt5/QtDesigner.pyi
vmove ${py3_sitelib}/PyQt5/QtDesigner.so
vmove usr/lib/qt5/plugins/designer/libpyqt5.so
vmove "${py3_sitelib}/PyQt5/QtHelp.*"
vmove "${py3_sitelib}/PyQt5/QtDesigner.*"
vmove usr/lib/qt5/plugins/designer
}
}
python3-PyQt5-webchannel_package() {
@ -229,8 +310,7 @@ python3-PyQt5-webchannel_package() {
depends="python3-PyQt5-${version}_${revision}"
short_desc="${short_desc} - webchannel module"
pkg_install() {
vmove ${py3_sitelib}/PyQt5/QtWebChannel.pyi
vmove ${py3_sitelib}/PyQt5/QtWebChannel.so
vmove "${py3_sitelib}/PyQt5/QtWebChannel.*"
}
}
python3-PyQt5-webkit_package() {
@ -238,10 +318,8 @@ python3-PyQt5-webkit_package() {
depends="python3-PyQt5-${version}_${revision}"
short_desc="${short_desc} - webkit module"
pkg_install() {
vmove ${py3_sitelib}/PyQt5/QtWebKit.pyi
vmove ${py3_sitelib}/PyQt5/QtWebKit.so
vmove ${py3_sitelib}/PyQt5/QtWebKitWidgets.pyi
vmove ${py3_sitelib}/PyQt5/QtWebKitWidgets.so
vmove "${py3_sitelib}/PyQt5/QtWebKit.*"
vmove "${py3_sitelib}/PyQt5/QtWebKitWidgets.*"
}
}
python3-PyQt5-websockets_package() {
@ -249,8 +327,7 @@ python3-PyQt5-websockets_package() {
depends="python3-PyQt5-${version}_${revision}"
short_desc="${short_desc} - websockets module"
pkg_install() {
vmove ${py3_sitelib}/PyQt5/QtWebSockets.pyi
vmove ${py3_sitelib}/PyQt5/QtWebSockets.so
vmove "${py3_sitelib}/PyQt5/QtWebSockets.*"
}
}
python3-PyQt5-x11extras_package() {
@ -258,8 +335,7 @@ python3-PyQt5-x11extras_package() {
depends="python3-PyQt5-${version}_${revision}"
short_desc="${short_desc} - x11extras module"
pkg_install() {
vmove ${py3_sitelib}/PyQt5/QtX11Extras.pyi
vmove ${py3_sitelib}/PyQt5/QtX11Extras.so
vmove "${py3_sitelib}/PyQt5/QtX11Extras.*"
}
}
python3-PyQt5-xmlpatterns_package() {
@ -267,7 +343,6 @@ python3-PyQt5-xmlpatterns_package() {
depends="python3-PyQt5-${version}_${revision}"
short_desc="${short_desc} - xmlpatterns module"
pkg_install() {
vmove ${py3_sitelib}/PyQt5/QtXmlPatterns.pyi
vmove ${py3_sitelib}/PyQt5/QtXmlPatterns.so
vmove "${py3_sitelib}/PyQt5/QtXmlPatterns.*"
}
}