[arch-general] An archlinux-python package for managing system default python version?

Achilleas Pipinellis axilleas at archlinux.info
Sun Jan 25 16:51:06 UTC 2015


On 01/24/2015 05:27 AM, 杨令 wrote:
>> From: Chi Hsuan Yen <yan12125 at gmail.com>
>> To: General Discussion about Arch Linux <arch-general at archlinux.org>
>> Cc:
>> Date: Fri, 23 Jan 2015 21:51:00 +0800
>> Subject: [arch-general] An archlinux-python package for managing system
> default python version?
>> 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?
> 
> sudo pacman -S python-virtualenv python2-virtualenv python-virtualenvwrapper
> 
> Google how to use them.
> 
> Actually virtualenv itself is enough. virtualenvwrapper is a useful
> wrapper, so I recommend to use them together.
> 
> Here is my virtualenv and virtualenvwrapper configuration in .zshrc. You
> can take a look:
> 
> # Python virtualenvwrapper
> export WORKON_HOME=$HOME/.virtualenvs
> #export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python2
> 
> if [ -f /usr/bin/virtualenvwrapper.sh ]; then
> source /usr/bin/virtualenvwrapper.sh
> fi
> 
> # Python pip -> virtualenv only
> export PIP_REQUIRE_VIRTUALENV=true
> export PIP_RESPECT_VIRTUALENV=true
> 


Correct me if I'm wrong, but virtualenv can support only the python
versions that virtualenv is build on. For example in arch repos there
are the latest 2 and 3 python versions.

In ruby, rvm/rbenv you can install **any** ruby version and use that per
project or globally, etc.

Now, in python there is pyenv[0] which is as the author states, a fork
of rbenv ported to python.


[0] https://github.com/yyuu/pyenv

-- 
GPG : 0x3A7DDABC985EDC6E
Blog: http://axilleas.me


More information about the arch-general mailing list