Subject: [PATCH] testing/mlt: modernize and add py3 subpackage

From: Bart Ribbers <[email-masked]>
Date: Mon, 15 Jul 2019 19:54:20 +0200

---
 testing/mlt/APKBUILD      | 32 ++++++++++++++++++++++----------
 testing/mlt/python3.patch | 19 +++++++++++++++++++
 2 files changed, 41 insertions(+), 10 deletions(-)
 create mode 100644 testing/mlt/python3.patch

diff --git a/testing/mlt/APKBUILD b/testing/mlt/APKBUILD
index 92f4ab13c3..6cf13f1303 100644
--- a/testing/mlt/APKBUILD
+++ b/testing/mlt/APKBUILD
@@ -2,22 +2,21 @@
 # Maintainer: Kevin Daudt <[email-masked]>
 pkgname=mlt
 pkgver=6.16.0
-pkgrel=0
+pkgrel=1
 pkgdesc="MLT Multimedia Framework"
 url="https://www.mltframework.org/"
 arch="all !s390x" # depends on fftw which does not work on s390x
-license="LGPL-2.1"
-makedepends="python ffmpeg-dev libsamplerate-dev sox-dev jack-dev
+license="GPL-2.0-or-later AND LGPL-2.1-or-later AND GPL-3.0-or-later"
+makedepends="python3-dev ffmpeg-dev libsamplerate-dev sox-dev jack-dev
 	gtk+2.0-dev sdl_image-dev frei0r-plugins-dev libxml2-dev fftw-dev
-	sdl-dev libexif-dev bsd-compat-headers"
-subpackages="$pkgname-dev"
+	sdl-dev libexif-dev bsd-compat-headers swig"
+subpackages="$pkgname-dev py3-$pkgname:py3"
 source="https://github.com/mltframework/mlt/releases/download/v$pkgver/mlt-$pkgver.tar.gz
 	musl-locale.patch
+	python3.patch
 	"
-builddir="$srcdir/mlt-$pkgver"
 
 build() {
-	cd "$builddir"
 	./configure \
 		--build=$CBUILD \
 		--host=$CHOST \
@@ -30,14 +29,27 @@ build() {
 		--enable-gpl \
 		--enable-gpl3 \
 		--disable-kde \
-		--disable-rtaudio
+		--disable-rtaudio \
+		--swig-languages=python
 	make
 }
 
 package() {
-	cd "$builddir"
 	make DESTDIR="$pkgdir" install
 }
 
+py3() {
+	pkgdesc="$pkgdesc (Python bindings)"
+	depends="python3"
+
+	_pythonpath=`python3 -c "from sysconfig import get_path; print(get_path('platlib'))"`
+
+	cd "$builddir"/src/swig/python
+	mkdir -p "$subpkgdir/$_pythonpath"
+	install -m755 mlt.py "$subpkgdir/$_pythonpath"
+	install -m755 _mlt.so "$subpkgdir/$_pythonpath"
+}
+
 sha512sums="554e8b9baa7a8578cc52315fe0583c61762bf6fbbcdd4a1e4f25753846d92f013e7d74745498625fcc781de993aa0526fd761920450b4314e67105783b9bde26  mlt-6.16.0.tar.gz
-dfa4c192ce6121a3c86141c46a08eaf6cd6bd81c120786bdb1ef564bf7878dcb44031280b34609048409c3d09e8c0e1bd430dae1fe777ef030daf09b1dfd90a3  musl-locale.patch"
+dfa4c192ce6121a3c86141c46a08eaf6cd6bd81c120786bdb1ef564bf7878dcb44031280b34609048409c3d09e8c0e1bd430dae1fe777ef030daf09b1dfd90a3  musl-locale.patch
+f354662b818d7e8f75e69cb48ae4bb79ff4e708d845736aed1ce70f025941f36b605dfe04831e68c7256bb6edf6fe163a69d47793810458748780387cafe2316  python3.patch"
diff --git a/testing/mlt/python3.patch b/testing/mlt/python3.patch
new file mode 100644
index 0000000000..ac32c9011d
--- /dev/null
+++ b/testing/mlt/python3.patch
@@ -0,0 +1,19 @@
+diff --git a/src/swig/python/build b/src/swig/python/build
+index db31e16..4eb69e2 100755
+--- a/src/swig/python/build
++++ b/src/swig/python/build
+@@ -8,12 +8,12 @@ then
+ 	exit 0
+ fi
+ 
+-path=`which python 2> /dev/null`
++path=`which python3 2> /dev/null`
+ 
+ if [ $? = 0 ]
+ then
+ 	# Change this as needed
+-	export PYTHON_INCLUDE=`python -c "import sys;print(\"{}/include/python{}.{}\".format(sys.prefix,*sys.version_info))"`
++	export PYTHON_INCLUDE=`python3 -c "import sys;print(\"{}/include/python{}.{}m\".format(sys.prefix,*sys.version_info))"`
+ 
+ 	[ ! -d "$PYTHON_INCLUDE" ] && echo python development missing && exit 1
+ 
-- 
2.22.0