Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #10318 > unrolled thread

Re: ActivePython: multiple versions on OSX?

Started byNed Deily <nad@acm.org>
First post2011-07-25 19:18 -0700
Last post2011-07-26 11:41 -0700
Articles 5 — 4 participants

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: ActivePython: multiple versions on OSX? Ned Deily <nad@acm.org> - 2011-07-25 19:18 -0700
    Re: ActivePython: multiple versions on OSX? John Roth <johnroth1@gmail.com> - 2011-07-26 05:00 -0700
      Re: ActivePython: multiple versions on OSX? Web Dreamer <webdreamer@nospam.fr> - 2011-07-26 17:53 +0200
        Re: ActivePython: multiple versions on OSX? Chris Angelico <rosuav@gmail.com> - 2011-07-27 03:07 +1000
        Re: ActivePython: multiple versions on OSX? Ned Deily <nad@acm.org> - 2011-07-26 11:41 -0700

#10318 — Re: ActivePython: multiple versions on OSX?

FromNed Deily <nad@acm.org>
Date2011-07-25 19:18 -0700
SubjectRe: ActivePython: multiple versions on OSX?
Message-ID<mailman.1482.1311646720.1164.python-list@python.org>
In article <j0l14e$cuh$1@dough.gmane.org>, Robert <sigzero@gmail.com> 
wrote:

> Is it possible to install the 2 and 3 series side by side?

Probably.  On Mac OS X, t's certainly possible to install any python.org 
versions side by side, even multiple versions of 2 and 3.  That's one of 
the advantages of the Python framework build layout on OS X, which is 
used by both the python.org installers and, I believe, the ActiveState 
installers.

http://www.python.org/download/

-- 
 Ned Deily,
 nad@acm.org

[toc] | [next] | [standalone]


#10327

FromJohn Roth <johnroth1@gmail.com>
Date2011-07-26 05:00 -0700
Message-ID<75342033-abbb-4d59-9654-96d5031dcb62@r28g2000prb.googlegroups.com>
In reply to#10318
On Jul 25, 8:18 pm, Ned Deily <n...@acm.org> wrote:
> In article <j0l14e$cu...@dough.gmane.org>, Robert <sigz...@gmail.com>
> wrote:
>
> > Is it possible to install the 2 and 3 series side by side?
>
> Probably.  On Mac OS X, t's certainly possible to install any python.org
> versions side by side, even multiple versions of 2 and 3.  That's one of
> the advantages of the Python framework build layout on OS X, which is
> used by both the python.org installers and, I believe, the ActiveState
> installers.
>
> http://www.python.org/download/
>
> --
>  Ned Deily,
>  n...@acm.org

When you do, you might also want to look at PEP 394:
http://www.python.org/dev/peps/pep-0394/

It can simplify writing scripts which select the version you want.

John Roth

[toc] | [prev] | [next] | [standalone]


#10339

FromWeb Dreamer <webdreamer@nospam.fr>
Date2011-07-26 17:53 +0200
Message-ID<4e2ee2dd$0$7291$426a74cc@news.free.fr>
In reply to#10327
John Roth a écrit ce mardi 26 juillet 2011 14:00 dans <75342033-
abbb-4d59-9654-96d5031dcb62@r28g2000prb.googlegroups.com> :

> On Jul 25, 8:18 pm, Ned Deily <n...@acm.org> wrote:
>> In article <j0l14e$cu...@dough.gmane.org>, Robert <sigz...@gmail.com>
>> wrote:
>>
>> > Is it possible to install the 2 and 3 series side by side?
[...]
> When you do, you might also want to look at PEP 394:
> http://www.python.org/dev/peps/pep-0394/
> 
> It can simplify writing scripts which select the version you want.

http://www.python.org/dev/peps/pep-0394/#impact-on-python-environment-variables
What would be a nice feature would be having:
PYTHONPATH (and PYTHONHOME, etc) referring to all versions, and to allow 
having PYTHON2PATH, PYTHON2HOME (and PYTHON3PATH, PYTHON3HOME), etc... for 
the specific versions.
This would allow having global variables for all versions, and special 
variables for specific versions, to allow more flexibility.
Or would it be silly?

-- 
Web Dreamer

[toc] | [prev] | [next] | [standalone]


#10340

FromChris Angelico <rosuav@gmail.com>
Date2011-07-27 03:07 +1000
Message-ID<mailman.1500.1311700055.1164.python-list@python.org>
In reply to#10339
On Wed, Jul 27, 2011 at 2:33 AM, Melton Low <softw.devl@gmail.com> wrote:
> It's probably impractical.  You would need a pair for each version of Python
> installed, ie. (PYTHON26PATH,PYTHON26HOME) for 2.6.x,
> (PYTHON27PATH,PYTHON27HOME) for 2.7.x, .... for 3.1.x, for 3.2.x, etc).

You could set up a script for each version that looks for environment
variables in the right order, stopping when it finds one. Version
3.2.1 would look for PYTHON321PATH, then PYTHON32PATH, then
PYTHON3PATH, finally falling back on PYTHONPATH. It could then put the
appropriate path into PYTHONPATH (not overwriting the external
variable of the same name - if your shell doesn't do that for you,
just save it to restore later), and invoke Python.

Still seems fairly cumbersome, and doesn't handle the possibility of
having two separate installs of the same version number (different
builds of 3.3, or 32-bit and 64-bit Pythons, or something). It may be
easier to simply create some scripts that set up the environment
explicitly, and then invoke Python. Name 'em according to what you
want of them.

ChrisA

[toc] | [prev] | [next] | [standalone]


#10346

FromNed Deily <nad@acm.org>
Date2011-07-26 11:41 -0700
Message-ID<mailman.1506.1311705683.1164.python-list@python.org>
In reply to#10339
In article 
<CAL_Nh-xfr50Unhz-5otoNa6qai1P+8_+z0cJfrLXF1tbNgP21w@mail.gmail.com>,
 Melton Low <softw.devl@gmail.com> wrote:
[...]
> On Mac OS X, a link is automatically installed in /usr/local/bin for each
> version of the Python executables, ie python2.7 for the 2.7.x  and python3.2
> for 3.2.x.  Just invoke your script with the appropriate Python version.
>  eg. python3.2 yourscript to run 'yourscript'.

Yes, the default action for the python.org OS X installers is to install 
the /usr/local/bin version specific links.  However, that is not a 
complete solution for managing framework versions.   The main problem is 
that, again by default, Distutils-packaged scripts are installed into 
the framework bin directory.  This means there is no ambiguity or 
conflict among the same package/script installed in different versions 
of Python - a good thing - but it also means the proper way to manage 
which Python is invoked by `python` or by `python3` (and `python2 in the 
future when PEP 394 is approved and implemented) is by ensuring the 
desired "primary" version's framework bin directory comes first on the 
shell PATH environment variable.  The python.org installers provide a 
script to do that, although somewhat crudely.

Let's say I've used the python.org 2.6, 2.7, and 3.2 installers (and 
deselected the option to automatically update the shell scripts) and 
then use Distribute to install easy_install into those instances.  There 
is also an Apple-supplied Python 2.6 and easy_install (and 
easy_install-2.6) in /usr/bin.

$ curl -O http://python-distribute.org/distribute_setup.py
$/usr/local/bin/python2.6 distribute_setup.py
$/usr/local/bin/python2.7 distribute_setup.py
$/usr/local/bin/python3.2 distribute_setup.py
$ echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
$ which python python2.6 python2.7
/usr/bin/python
/usr/bin/python2.6
/usr/local/bin/python2.7
$ which easy_install easy_install-2.6 easy_install-2.7
/usr/bin/easy_install
/usr/bin/easy_install-2.6
# note that there is no access to the easy_install-2.7
#    nor to the correct easy_install-2.6 for the python.org 2.6

$ open /Applications/Python\ 2.6/Update\ Shell\ Profile.command
$ bash -l
$ echo $PATH
/Library/Frameworks/Python.framework/Versions/2.6/bin:/usr/bin:/bin:/usr/
sbin:/sbin:/usr/local/bin:/usr/X11/bin
$ which python python2.6 python2.7
/Library/Frameworks/Python.framework/Versions/2.6/bin/python
/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6
/usr/local/bin/python2.7
$ which easy_install easy_install-2.6 easy_install-2.7
/Library/Frameworks/Python.framework/Versions/2.6/bin/easy_install
/Library/Frameworks/Python.framework/Versions/2.6/bin/easy_install-2.6

$ open /Applications/Python\ 2.7/Update\ Shell\ Profile.command
$ bash -l
$ echo $PATH
/Library/Frameworks/Python.framework/Versions/2.7/bin:/Library/Frameworks
/Python.framework/Versions/2.6/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/loc
al/bin:/usr/X11/bin
$ which python python2.6 python2.7
/Library/Frameworks/Python.framework/Versions/2.7/bin/python
/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6
/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
$ which easy_install easy_install-2.6 easy_install-2.7
/Library/Frameworks/Python.framework/Versions/2.7/bin/easy_install
/Library/Frameworks/Python.framework/Versions/2.6/bin/easy_install-2.6
/Library/Frameworks/Python.framework/Versions/2.7/bin/easy_install-2.7

# Now "easy_install" refers to the 2.7 version just as "python" does.

Python 3 instances work similarly although, since Apple does not yet 
ship a system Python 3, there is no conflict with /usr/bin and the 
Python 3 framework bin directories include "python3" links instead of 
"python" ones, so there is also no conflict with Python 2 instances.

$ open /Applications/Python\ 3.2/Update\ Shell\ Profile.command
$ bash -l
$ echo $PATH
/Library/Frameworks/Python.framework/Versions/3.2/bin:/Library/Frameworks
/Python.framework/Versions/2.7/bin:/Library/Frameworks/Python.framework/V
ersions/2.6/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
$ which python python2.6 python2.7 python3 python3.2
/Library/Frameworks/Python.framework/Versions/2.7/bin/python
/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6
/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
/Library/Frameworks/Python.framework/Versions/3.2/bin/python3
/Library/Frameworks/Python.framework/Versions/3.2/bin/python3.2
$ which easy_install easy_install-2.6 easy_install-2.7 easy_install-3.2
/Library/Frameworks/Python.framework/Versions/3.2/bin/easy_install
/Library/Frameworks/Python.framework/Versions/2.6/bin/easy_install-2.6
/Library/Frameworks/Python.framework/Versions/2.7/bin/easy_install-2.7
/Library/Frameworks/Python.framework/Versions/3.2/bin/easy_install-3.2

But here is a potential gotcha!  Distribute does not provide a 
"easy_install3" link when installing into a Python 3 instance so now the 
unversioned "easy_install" command refers to the Python 3.2 version, 
which may not be what you expected.  You can change the search order of 
PATH:

$ export 
PATH=/Library/Frameworks/Python.framework/Versions/2.7/bin:/Library/Frame
works/Python.framework/Versions/2.6/bin:/Library/Frameworks/Python.framew
ork/Versions/3.2/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X1
1/bin
$ which easy_install easy_install-2.6 easy_install-2.7 
easy_install-3.2/Library/Frameworks/Python.framework/Versions/2.7/bin/eas
y_install
/Library/Frameworks/Python.framework/Versions/2.6/bin/easy_install-2.6
/Library/Frameworks/Python.framework/Versions/2.7/bin/easy_install-2.7
/Library/Frameworks/Python.framework/Versions/3.2/bin/easy_install-3.2

To make this change permanent, you would need to edit the appropriate 
shell startup file, for example, .bash_profile.  Or be careful about the 
order in which you run the Update Shell Profile commands in the first 
place.

When in doubt, you can always use the version-specific name (in this 
case that works but most Python packages do not provide version specific 
links) or you can use an absolute path.  There are, of course, other 
strategies for dealing with the third-party packages in case of 
ambiguities, for example using virtualenvs or using Distutils alternate 
installation options, like --home.

The situation gets more complex if you have installed Pythons from 
distributors other than python.org;  these may be installed in the same 
or in different locations and may or may not be framework builds.  But 
the general principles still apply.

The current state is not ideal, especially for new users of Python.  I'm 
hoping we can make life a bit easier by the time 3.3 is released next 
year.

-- 
 Ned Deily,
 nad@acm.org

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web