Subject: [alpine-devel] [RFC] First draft: add Tkinter to python

From: Isaac Dunham <[email-masked]>
Date: Wed, 3 Sep 2014 13:44:24 -0700

Hello,
I'm trying to get Tkinter in python; while I know that needs to wait for
tk to move to main, I'm not sure how to get the whole thing working right.

The biggest problem is that Tkinter needs Tk, which ultimately needs
libxcb, which in turn has python in makedepends.
But I'm not sure what's a good way to handle that.

Also, this would make quite a few things ultimately depend on X11.

Here is a patch that works to build Tkinter when PYTHON_TK is not set to
"false".

Any recommendations?

Thanks,
Isaac Dunham
commit 9c68991e15c129e02bd3bb5cad62545deb86de12
Author: Isaac Dunham <[email-masked]>
Date:   Wed Sep 3 11:57:57 2014 -0700

    main/python: Build tkinter.
    
    There is a build loop here; I'm not sure how to solve it.

diff --git a/main/python/APKBUILD b/main/python/APKBUILD
index 6acf299..39c6811 100644
--- a/main/python/APKBUILD
+++ b/main/python/APKBUILD
@@ -19,6 +19,17 @@ source="http://www.$pkgname.org/ftp/$pkgname/$pkgver/Python-$pkgver.tar.xz
 	unchecked-ioctl.patch
 	"
 
+# when bringing up a platform, tk will drag in the X11 client libs
+:  ${PYTHON_TK:=true}
+if ${PYTHON_TK}; then
+	echo "Building with Tkinter"
+	makedepends="$makedepends tk-dev"
+	subpackages="$subpackages py-tkinter:tkinter"
+	export TCLLIBS="`pkg-config --libs tk`"
+	export TCLINCS="`pkg-config --cflags tk`"
+	export CONFIGFLAGS='--with-tcltk-libs=${TCLLIBS} --with-tcltk-includes=${TCLINCS}'
+	fi
+
 prepare() {
 	cd "$srcdir/Python-$pkgver"
 	for i in $source; do
@@ -52,6 +63,7 @@ build() {
 		--with-system-expat \
 		--with-system-zlib \
 		--enable-unicode=ucs4 \
+		$CONFIGFLAGS \
 		|| return 1
 	make || return 1
 }
@@ -95,6 +107,12 @@ gdbm() {
 	_mv_files $(find usr/lib -name '*gdbm*')
 }
 
+tkinter() {
+	pkgdesc="Tk interface support for Python"
+	cd "$pkgdir"
+	_mv_files $(find usr/lib -name 'lib-tk' -o -name '_tkinter.so')
+}
+
 md5sums="d235bdfa75b8396942e360a70487ee00  Python-2.7.8.tar.xz
 5d8ca92fa6f187573104593470a9d3d5  find_library.patch
 dada786a50fa332686a9b9260d84c110  unchecked-ioctl.patch"

---

From: Eivind Uggedal <[email-masked]>
Date: Wed, 3 Sep 2014 22:52:41 +0200

You could possibly look at how voidlinux handles the cyclic dependency
by splitting the package:

https://github.com/voidlinux/void-packages/blob/master/srcpkgs/python/template
https://github.com/voidlinux/void-packages/blob/master/srcpkgs/python-tkinter/template

> Here is a patch that works to build Tkinter when PYTHON_TK is not set to

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---

---

From: Natanael Copa <[email-masked]>
Date: Thu, 4 Sep 2014 11:18:03 +0200

On Wed, 3 Sep 2014 22:52:41 +0200

> https://github.com/voidlinux/void-packages/blob/master/srcpkgs/python-tkinter/template

Other option might be to have a special BOOTSTRAP flag to indicate that
we are bootstrapping aports. We have more aports that could use that.

However, I would really prefer to avoid that. Splitting the package as
Eivind suggest would be better. We do similar with poppler and
poppler-qt i think.

-nc

---