Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 411603 - app-portage/esearch misbehaves when python3 is used as system python
Summary: app-portage/esearch misbehaves when python3 is used as system python
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Third-Party Tools (show other bugs)
Hardware: All Linux
: Normal minor (vote)
Assignee: Portage Tools Team
Keywords: PATCH
Depends on:
Blocks: 308257
  Show dependency tree
Reported: 2012-04-11 15:00 UTC by Mira Ressel
Modified: 2012-04-20 18:42 UTC (History)
0 users

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


Note You need to log in before you can comment on or make changes to this bug.
Description Mira Ressel 2012-04-11 15:00:26 UTC
app-portage/esearch doesn't work well with python3 being used for the symlink /usr/bin/python: #esync fails completely, and $esearch shows very strange size informations i #eupdatedb ran under python3 (eg. 20,3.7,958,984,375 kB instead of 203 kB).

This could be fixed by changing the shebang line in the scripts from 'python' to 'python2'. A patch for the ebuild is below.
Comment 1 Mira Ressel 2012-04-11 15:01:06 UTC
--- a/app-portage/esearch/esearch-1.0-r2.ebuild
+++ b/app-portage/esearch/esearch-1.0-r2.ebuild
@@ -4,7 +4,7 @@
-RESTRICT_PYTHON_ABIS="2.[45] 2.7-pypy-* *-jython"
+RESTRICT_PYTHON_ABIS="3.* 2.[45] 2.7-pypy-* *-jython"
@@ -42,8 +42,8 @@ src_compile() {
 src_install() {
-       python_convert_shebangs -r "" build-*/scripts-*
+       python_convert_shebangs -r "2" "$D"
        dodoc eupdatedb.cron || die "dodoc failed"
Comment 2 Brian Dolbec gentoo-dev 2012-04-11 15:24:50 UTC
How exactly does esync fail?  The -l, --layman-sync will not work in py3 unless it  runs layman in a terminal, layman is py2 only so still.  I don't recall if I put a py3 check in there, I'll look later.  Need to go to work now.
Comment 3 Paul Varner (RETIRED) gentoo-dev 2012-04-11 15:51:45 UTC
esearch is intended to work properly with python3, so we need to find and fix the issues instead of working around them by specifying python 2.
Comment 4 Mira Ressel 2012-04-11 17:54:32 UTC
Ok, so this are the problems I found with esearch/py3:
* esearch itself works fine, but if eupdatedb ran under py3, the file sizes are displayed very strange, as already mentioned above

* esync doesn't work: It first calls emerge --sync  and eupdatedb, which both run without problems. But then, in the phase "Searching for changes", it aborts with this error message:
   Traceback (most recent call last):
     File "/usr/bin/esync", line 5, in <module>
     File "/usr/lib64/python3.2/site-packages/esearch/", line 291, in main
       success = sync(config)
     File "/usr/lib64/python3.2/site-packages/esearch/", line 247, in sync
       items.sort(lambda x, y: cmp(x[0], y[0]))
   TypeError: must use keyword argument for key function
Comment 5 Mira Ressel 2012-04-11 18:01:37 UTC
The codeline causing the problem:
items.sort(lambda x, y: cmp(x[0], y[0]))
Comment 6 Mira Ressel 2012-04-11 18:26:01 UTC
I solved the esync issue by replacing this line with
items.sort(key=lambda x: x[0])

Looks like this syntax also works for python2, so you can just change it in the src, fuzzyray. I created a pull request at github for fixing the issue.

Now, let's look at the file size problem.
Comment 7 Paul Varner (RETIRED) gentoo-dev 2012-04-11 19:01:12 UTC
I merged the pull request in github.  The size issue is going to be caused by nit using floor division.  Something similar to the following fix:
Comment 8 Mira Ressel 2012-04-11 19:13:33 UTC
Yes, I also found this and created a pull request again, only a few minutes ago. I'm surprised that I as a total python noob was able to find that :)
Comment 9 Mira Ressel 2012-04-11 20:25:39 UTC
Both fixes are in the git repo now, which is available via the esearch-9999 ebuild. But as most users won't use this, maybe it's time for a new release?
Comment 10 Mira Ressel 2012-04-20 18:42:51 UTC
esearch-1.1, available in portage since April 13, fixes the issue.