Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 445842 - dev-vcs/mercurial: hg-ssh doesn't work when python3 is main python interpreter
Summary: dev-vcs/mercurial: hg-ssh doesn't work when python3 is main python interpreter
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Krzysztof Pawlik (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-12-03 19:13 UTC by Fabian Groffen
Modified: 2012-12-04 07:54 UTC (History)
2 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Fabian Groffen gentoo-dev 2012-12-03 19:13:04 UTC
I'm currently going through the "joy" of Python3.  Mercurial seems to build itself only for Python 2, which is fine for me, however it's contrib script hg-ssh uses shebang /usr/bin/env python.  This broke me being able to push with some SyntaxError on except syntax by Python3.  I suggest the simple following sed (possibly in another place) to make sure the script is ran with Python 2:

diff -u -r1.1 mercurial-2.4-r1.ebuild
--- mercurial-2.4-r1.ebuild     24 Nov 2012 22:42:49 -0000      1.1
+++ mercurial-2.4-r1.ebuild     3 Dec 2012 19:10:23 -0000
@@ -73,6 +73,7 @@
 
        dobin hgeditor || die
        dobin contrib/hgk || die
+       sed -i -e '1s/python/python2/' contrib/hg-ssh || die # needs Python 2
        dobin contrib/hg-ssh || die
 
        rm -f contrib/hgk contrib/hg-ssh || die

Just run hg-ssh with python3 to see the SyntaxError.
Comment 1 Dirkjan Ochtman (RETIRED) gentoo-dev 2012-12-03 20:12:06 UTC
Don't we have some function that helps rewrite the shebangs these days?
Comment 2 Fabian Groffen gentoo-dev 2012-12-03 20:15:14 UTC
you'd probably mean python_rewrite_shebangs or something

I lack the experience here.
Comment 3 Dirkjan Ochtman (RETIRED) gentoo-dev 2012-12-03 20:22:17 UTC
Yeah, that would be it. Sorry, I don't have much experience with this, either. Also, my devbox is kinda broken ATM, so I'm not sure when I can get to it. And I think Krzysztof is being retired? Anyway, if you can test with the shebangs thingy, feel free to commit.
Comment 4 Fabian Groffen gentoo-dev 2012-12-03 20:42:29 UTC
This seems to work:

diff -u -r1.1 mercurial-2.4-r1.ebuild
--- mercurial-2.4-r1.ebuild     24 Nov 2012 22:42:49 -0000      1.1
+++ mercurial-2.4-r1.ebuild     3 Dec 2012 20:41:03 -0000
@@ -59,6 +59,7 @@
 
 src_install() {
        distutils_src_install
+       python_convert_shebangs 2 contrib/hg-ssh
 
        newbashcomp contrib/bash_completion ${PN} || die
 
It effectively does nothing more than the sed I did before, with a lot of extra code to check, but ignore the validity of the first argument.
Comment 5 Dirkjan Ochtman (RETIRED) gentoo-dev 2012-12-04 07:48:49 UTC
Sounds about right. Feel free to commit.
Comment 6 Fabian Groffen gentoo-dev 2012-12-04 07:54:38 UTC
done, thanks