Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 509738 - dev-tcltk/tclpython-4.1-r2 - add python 3 support
Summary: dev-tcltk/tclpython-4.1-r2 - add python 3 support
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Development (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: TCL/TK Project
URL:
Whiteboard:
Keywords: PATCH
Depends on:
Blocks:
 
Reported: 2014-05-06 20:59 UTC by Alexander Turenko
Modified: 2014-10-27 17:23 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
tclpython-4.1-r2-python-3.patch (tclpython-4.1-r2-python-3.patch,8.66 KB, patch)
2014-05-06 20:59 UTC, Alexander Turenko
Details | Diff
tclpython-4.1-r2.ebuild (tclpython-4.1-r2.ebuild,1.29 KB, text/plain)
2014-05-06 21:02 UTC, Alexander Turenko
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Turenko 2014-05-06 20:59:13 UTC
Created attachment 376518 [details, diff]
tclpython-4.1-r2-python-3.patch

Patch for python 3 support.

It works for me, not tested properly, possibly contains leaks, and possibly uses not better approaches. I not experienced around python, at all. So if anyone revise this patch, it will be good. I tried to mail to author (Jean-Luc Fontaine), but his e-mail (jfontain@free.fr) blocked due to inactivity.

Patch burned in process to use tclpython for interacting with
pymorphy2 from tcl. That trying was failed. The pymorphy2 behaviour
different under pure python2.7 and under tclpython + python2.7. But
with tclpython + python 3 all seems to be okay.
Comment 1 Alexander Turenko 2014-05-06 21:02:56 UTC
Created attachment 376522 [details]
tclpython-4.1-r2.ebuild

Ebuild with python 2 and 3 compatibility and with EAPI="5".
Comment 2 Jeroen Roovers (RETIRED) gentoo-dev 2014-05-06 22:29:56 UTC
Comment on attachment 376522 [details]
tclpython-4.1-r2.ebuild

--- tclpython-4.1-r2.ebuild     2011-05-30 02:29:56.000000000 +0200
+++ -   2014-05-07 00:29:38.065147146 +0200
@@ -2,10 +2,10 @@
 # Distributed under the terms of the GNU General Public License v2
 # $Header: /var/cvsroot/gentoo-x86/dev-tcltk/tclpython/tclpython-4.1-r2.ebuild,v 1.7 2011/05/23 07:17:52 tomka Exp $
-EAPI="3"
-PYTHON_DEPEND="2"
+EAPI="5"
+PYTHON_COMPAT=( python{2_7,3_{2,3}} )
-inherit multilib python toolchain-funcs
+inherit eutils multilib python toolchain-funcs
 DESCRIPTION="Python package for Tcl"
 HOMEPAGE="http://jfontain.free.fr/tclpython.htm"
@@ -20,11 +20,11 @@
 RDEPEND="${DEPEND}"
 pkg_setup() {
-       python_set_active_version 2
        python_pkg_setup
 }
 src_compile() {
+       epatch "${FILESDIR}/tclpython-4.1-r2-python-3.patch"
        cfile="tclpython tclthread"
        for src in ${cfile}; do
                compile="$(tc-getCC) -shared -fPIC ${CFLAGS} -I$(python_get_includedir) -c ${src}.c"
@@ -39,10 +39,10 @@
 src_install() {
        insinto /usr/$(get_libdir)/tclpython
-       doins tclpython.so.${PV} pkgIndex.tcl || die "tcl"
+       doins tclpython.so.${PV} pkgIndex.tcl
        fperms 775 /usr/$(get_libdir)/tclpython/tclpython.so.${PV}
-       dosym tclpython.so.${PV} /usr/$(get_libdir)/tclpython/tclpython.so || die
+       dosym tclpython.so.${PV} /usr/$(get_libdir)/tclpython/tclpython.so
-       dodoc CHANGES INSTALL README || die
-       dohtml tclpython.htm || die
+       dodoc CHANGES INSTALL README
+       dohtml tclpython.htm
 }
Comment 3 Justin Lecher (RETIRED) gentoo-dev 2014-10-26 18:45:36 UTC
+*tclpython-4.1-r3 (26 Oct 2014)
+
+  26 Oct 2014; Justin Lecher <jlec@gentoo.org> +tclpython-4.1-r3.ebuild,
+  metadata.xml:
+  Bump to EAPI=5 and new python eclasses; add py3 support, #509738
+
Comment 4 Alexander Turenko 2014-10-27 12:47:07 UTC
Justin, thanks for revising the ebuild.

You are forget to commit the patch or it requires a some improvements? Tclpython build without it, but works only with python 2.

Example (for current main portage tree and python 3.4 eselected as default):

$ tclsh
% package require tclpython 4
4.1
% set py [python::interp new]
python0
% $py exec {print 'python 2 syntax'}
python 2 syntax
% $py exec {(a, *rest, b) = range(5)}
python0:   File "<string>", line 1
    (a, *rest, b) = range(5)
        ^
SyntaxError: invalid syntax

$ python3
Python 3.4.2 (default, Oct 19 2014, 06:47:18) 
[GCC 4.8.3] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print 'python 2 syntax'
  File "<stdin>", line 1
    print 'python 2 syntax'
                          ^
SyntaxError: Missing parentheses in call to 'print'
>>> (a, *rest, b) = range(5)
>>> print (rest)
[1, 2, 3]
>>> 

Example (for my ebuild with epatch — only added 3_4 to PYTHON_COMPAT):

$ tclsh
% package require tclpython 4
4.1
% set py [python::interp new]
python0
% $py exec {print 'python 2 syntax'}
  File "<string>", line 1
    print 'python 2 syntax'
                          ^
SyntaxError: Missing parentheses in call to 'print'
python0: 
% $py exec {(a, *rest, b) = range(5)}
% $py exec {print (rest)}
[1, 2, 3]
Comment 5 Justin Lecher (RETIRED) gentoo-dev 2014-10-27 14:23:19 UTC
+*tclpython-4.1-r4 (27 Oct 2014)
+
+  27 Oct 2014; Justin Lecher <jlec@gentoo.org> -tclpython-4.1-r3.ebuild,
+  +tclpython-4.1-r4.ebuild, +files/tclpython-4.1-python-3.patch:
+  Add missing patch, #509738; thanks Alexander Turenko for the backport
+
Comment 6 Alexander Turenko 2014-10-27 16:50:05 UTC
Oh, this patch definitely need more work on it. Main tree ebuild build tclpython, that builds with python 2.7:

$ ldd /usr/lib64/tclpython/tclpython.so.4.1 | grep python
	libpython2.7.so.1.0 => /usr/lib64/libpython2.7.so.1.0 (0x00007fe9eb5b9000)

My flags: PYTHON_SINGLE_TARGET="python2_7 -python3_3 -python3_4" PYTHON_TARGETS="python2_7 python3_4 -python3_3"

For ebuild in attachment 376522 [details] (with 3_4 in PYTHON_COMPAT):

$ ldd /usr/lib64/tclpython/tclpython.so.4.1 | grep python
	libpython3.4.so.1.0 => /usr/lib64/libpython3.4.so.1.0 (0x00007ff20206e000)

So, library build works with one version of python. Likely that linking changeable by flags and usable, but not with comfort.

I not promise, but maybe I will look deeper into problem and solve it more carefully. Anyway, this bug currently fixed; there is ability to compile tclpython with python 3.
Comment 7 Justin Lecher (RETIRED) gentoo-dev 2014-10-27 17:23:56 UTC
(In reply to Alexander Turenko from comment #6)
> Oh, this patch definitely need more work on it. Main tree ebuild build
> tclpython, that builds with python 2.7:
> 
> $ ldd /usr/lib64/tclpython/tclpython.so.4.1 | grep python
> 	libpython2.7.so.1.0 => /usr/lib64/libpython2.7.so.1.0 (0x00007fe9eb5b9000)
> 
> My flags: PYTHON_SINGLE_TARGET="python2_7 -python3_3 -python3_4"
> PYTHON_TARGETS="python2_7 python3_4 -python3_3"
> 
> For ebuild in attachment 376522 [details] (with 3_4 in PYTHON_COMPAT):
> 
> $ ldd /usr/lib64/tclpython/tclpython.so.4.1 | grep python
> 	libpython3.4.so.1.0 => /usr/lib64/libpython3.4.so.1.0 (0x00007ff20206e000)
> 
> So, library build works with one version of python. Likely that linking
> changeable by flags and usable, but not with comfort.

The problem is that we have no functionality to parallel install librarieslinked against different py ABIs.