# 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.
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.
utils/key2pub.py script requires dev-python/m2crypto, which currently supports only Python 2.
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?
(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')
Okay, can you come up with a solution not involving calling python_set_active_version?
(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().
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.
(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
(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? :)
(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.
I have added it to the -r2 ebuild, so it should be fixed now.
Please add build-time dependency on Python 2.
Fixed, it now depends on dev-lang/python:2.7
(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*".
(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 :)