Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 389851 - net-wireless/crda-1.1.2-r1 does not build if python is python3
Summary: net-wireless/crda-1.1.2-r1 does not build if python is python3
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Bjarke Istrup Pedersen (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on: 385117
Blocks:
  Show dependency tree
 
Reported: 2011-11-08 02:42 UTC by Alexandre Rostovtsev (RETIRED)
Modified: 2011-11-14 13:12 UTC (History)
3 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 Alexandre Rostovtsev (RETIRED) gentoo-dev 2011-11-08 02:42:48 UTC
# eselect python set python3.2
# emerge crda
[...]
>>> Compiling source in /var/tmp/portage/net-wireless/crda-1.1.2-r1/work/crda-1.1.2 ...
make -j1 UDEV_RULE_DIR=/etc/udev/rules.d/ USE_OPENSSL=1 CC=x86_64-pc-linux-gnu-gcc all_noverify 
  GEN  keys-ssl.c
  Trusted pubkeys: pubkeys/linville.key.pub.pem
  File "./utils/key2pub.py", line 6
    except ImportError, e:
                      ^
SyntaxError: invalid syntax
make: *** [keys-ssl.c] Error 1
 * ERROR: net-wireless/crda-1.1.2-r1 failed (compile phase):
 *   emake failed


Note: crda builds successfully if python is python2.
Comment 1 Bjarke Istrup Pedersen (RETIRED) gentoo-dev 2011-11-09 09:32:12 UTC
Python team, any of you have an idea of what has to be changed so it builds with both python 2 and 3?

I could force it to use python 2, but I would prefer to make it work with both, since setting the active python version breaks when overriding the $ROOT variable, which I'm using a lot for cross-compiling.
Comment 2 Arfrever Frehtes Taifersar Arahesis 2011-11-10 01:42:12 UTC
utils/key2pub.py script requires dev-python/m2crypto, which currently supports only Python 2.
Comment 3 Bjarke Istrup Pedersen (RETIRED) gentoo-dev 2011-11-10 11:17:14 UTC
I haven't been able to find any info regarding m2crypto not being supported on python 3 (I did find some blog posts from 2008 mentioning that the only part of m2crypto that didn't work on python 3 was the python 2 unit tests...)

So, how much would it require to get m2crypto on python 3?
Comment 4 Alexandre Rostovtsev (RETIRED) gentoo-dev 2011-11-10 17:17:11 UTC
(In reply to comment #1)
> Python team, any of you have an idea of what has to be changed so it builds
> with both python 2 and 3?

Well, besides the fact that Gentoo's dev-python/m2crypto does not support python3, you would also need to convert all the traditional python2 syntax in key2pub.py to python3, and then check which (if any) versions of python2 the converted version is still compatible with. For example, I believe that "except ImportError as e" will only work with python-2.6 and higher.

$ 2to3 utils/key2pub.py 
RefactoringTool: Skipping implicit fixer: buffer
RefactoringTool: Skipping implicit fixer: idioms
RefactoringTool: Skipping implicit fixer: set_literal
RefactoringTool: Skipping implicit fixer: ws_comma
RefactoringTool: Refactored utils/key2pub.py
--- utils/key2pub.py	(original)
+++ utils/key2pub.py	(refactored)
@@ -3,7 +3,7 @@
 import sys
 try:
        from M2Crypto import RSA
-except ImportError, e:
+except ImportError as e:
        sys.stderr.write('ERROR: Failed to import the "M2Crypto" module: %s\n' % e.message)
        sys.stderr.write('Please install the "M2Crypto" Python module.\n')
        sys.stderr.write('On Debian GNU/Linux the package is called "python-m2crypto".\n')
@@ -79,7 +79,7 @@
 
 static struct pubkey keys[] = {
 ''')
-    for n in xrange(n + 1):
+    for n in range(n + 1):
         output.write('	KEYS(e_%d, n_%d),\n' % (n, n))
     output.write('};\n')
     pass
@@ -115,7 +115,7 @@
 
 static const struct key_params keys[] = {
 ''')
-    for n in xrange(n + 1):
+    for n in range(n + 1):
         output.write('	KEYS(e_%d, n_%d),\n' % (n, n))
     output.write('};\n')
     
@@ -133,7 +133,7 @@
     mode = None
 
 if not mode in modes:
-    print 'Usage: %s [%s] input-file... output-file' % (sys.argv[0], '|'.join(modes.keys()))
+    print('Usage: %s [%s] input-file... output-file' % (sys.argv[0], '|'.join(list(modes.keys()))))
     sys.exit(2)
 
 output = open(outfile, 'w')
Comment 5 Bjarke Istrup Pedersen (RETIRED) gentoo-dev 2011-11-10 20:41:32 UTC
Okay, can you come up with a solution not involving calling python_set_active_version?
Comment 6 Arfrever Frehtes Taifersar Arahesis 2011-11-10 20:46:33 UTC
(In reply to comment #3)

https://bugzilla.osafoundation.org/show_bug.cgi?id=12853

(In reply to comment #5)

I would suggest to backport the fix for python_set_active_version().
Comment 7 Bjarke Istrup Pedersen (RETIRED) gentoo-dev 2011-11-10 21:04:59 UTC
I'm not that good at python I must admin, but I'm marking this bug as depending on the other bug, so we can keep track of things.
Comment 8 Alexandre Rostovtsev (RETIRED) gentoo-dev 2011-11-10 22:56:09 UTC
(In reply to comment #5)
> Okay, can you come up with a solution not involving calling
> python_set_active_version?

python_convert_shebangs 2 utils/key2pub.py
Comment 9 Bjarke Istrup Pedersen (RETIRED) gentoo-dev 2011-11-11 07:50:59 UTC
(In reply to comment #8)
> (In reply to comment #5)
> > Okay, can you come up with a solution not involving calling
> > python_set_active_version?
> 
> python_convert_shebangs 2 utils/key2pub.py

Just out of curiosity, what does python_convert_shebangs do? :)
Comment 10 Alexandre Rostovtsev (RETIRED) gentoo-dev 2011-11-13 00:27:18 UTC
(In reply to comment #9)
> Just out of curiosity, what does python_convert_shebangs do? :)

It converts python script shebang lines to call a specific python version instead of /usr/bin/python. In other words, if a python script starts with something like "#!/usr/bin/env python" or "#!/usr/bin/python", then you can use "python_convert_shebangs 2" to convert it to "#!/usr/bin/env python2" or "#!/usr/bin/python2".

Converting shebangs is almost always required for executable python scripts that are going to be installed on the user's hard drive. In many cases you can also use converting shebangs as an alternative to python_set_active_version for build-time scripts.
Comment 11 Bjarke Istrup Pedersen (RETIRED) gentoo-dev 2011-11-14 09:07:54 UTC
I have added it to the -r2 ebuild, so it should be fixed now.
Comment 12 Arfrever Frehtes Taifersar Arahesis 2011-11-14 11:51:45 UTC
Please add build-time dependency on Python 2.
Comment 13 Bjarke Istrup Pedersen (RETIRED) gentoo-dev 2011-11-14 12:05:55 UTC
Fixed, it now depends on dev-lang/python:2.7
Comment 14 Arfrever Frehtes Taifersar Arahesis 2011-11-14 12:50:31 UTC
(In reply to comment #13)
> Fixed, it now depends on dev-lang/python:2.7

You added this dependency in net-wireless/iw-3.2, but this bug is about net-wireless/crda.

Until the fix for bug #323311 is backported to gentoo-x86, please use explicit dependency on "=dev-lang/python-2*".
Comment 15 Bjarke Istrup Pedersen (RETIRED) gentoo-dev 2011-11-14 13:12:49 UTC
(In reply to comment #14)
> (In reply to comment #13)
> > Fixed, it now depends on dev-lang/python:2.7
> 
> You added this dependency in net-wireless/iw-3.2, but this bug is about
> net-wireless/crda.
> 
> Until the fix for bug #323311 is backported to gentoo-x86, please use explicit
> dependency on "=dev-lang/python-2*".

Dohh, hehe, have been messing around with net-wireless too much lately it seems :)
crda-1.1.2-r2 has been updated to depend on python 2 :)