On 23/01/15 at 09:51pm, Chi Hsuan Yen wrote:
Dear Arch enthusiasts,
The package extra/java-runtime-common provides a convenient script archlinux-java to handle co-existing JDK/JRE versions. I can use it to switch between different versions of java implementations to accomplish numerous tasks from testing the compatibilities of my programs to running third party applications targeting on different platforms. Now I hope there's also a simple script for the same thing but for python. On the system, most of the scripts are written for python2 and some other scripts are python3-specific. In most cases it's not a problem because I can fix the scripts or use some tricks like $PATH to ensure the correct execution of the programs. However, in large projects, doing either is time-consuming and costly. Recently I'm building CyanogenMod on Arch Linux. It includes lots of python scripts in the build system, and most of them requires python2. Using the tip provided on the article about Python on ArchWiki prevents lots of problems, but, however, some scripts have the shebang line "#!/usr/bin/env python" or are invoked by some command like "/usr/bin/python ...". I have to change the link /usr/bin/python to pointing to python2 for further progress on building and changed it back for my daily use. If there's an archlinux-python script, lots of time on battling the difference between python2 and python3 does not exist anymore, which I believe lots of users can benefit from it. Any ideas?
Best Regards,
Yen Chi Hsuan
Hi, As I understand, you find a workaround thanks to Borja but I wander why nobody talked about Python VirtualEnv[1] (I thought it was created for such case). In your case (where you want to change python env just for building cyanogen then come back to python3), you can install "python-virtualenvwrapper" from repo then the first time you need to create the virtual env : $source /usr/bin/virtualenvwrapper.sh $mkvirtualenv -p `which python2` cyanogen $workon cyanogen and next time you just need to source the wrapper and change the env: $source /usr/bin/virtualenvwrapper.sh $workon cyanogen You can find more accurate details in [1] on the ArchWiki. Best regard, Fabien [1] https://wiki.archlinux.org/index.php/Python_VirtualEnv