import wx behaviour on Ubuntu

When I have both python-wxgtk2.6 and python-wxgtk2.8 installed on
ubuntu and I do a normal "import wx", it chooses by default 2.6:
$ python
Python 2.6.2 (release26-maint, Apr 19 2009, 01:58:18)
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.

import wx
wx.VERSION

(2, 6, 3, 2, '')

I would have expected that 2.8 would be the default, but of course
this is debatable. Is this intended behaviour? Is there a way to set
system wide the preference for 2.8 instead of 2.6? Robin, does Ubuntu
implement this differently from upstream wxpython?

Best regards,
Stani

···

--
Phatch Photo Batch Processor - http://photobatch.stani.be
SPE Python IDE - http://pythonide.stani.be

Stani wrote:

I would have expected that 2.8 would be the default, but of course
this is debatable. Is this intended behaviour? Is there a way to set
system wide the preference for 2.8 instead of 2.6? Robin, does Ubuntu
implement this differently from upstream wxpython?

This used to work as expected in Ubuntu < 9.04...

Under Jaunty things are different, because every wxpython package adds a wx-2.[68]-gtk2-unicode.pth to /usr/lib/python2.6/dist-packages, so - if I understand it correctly - on a "import wx" Python chooses alphabetically, thus the 2.6 version..

I worked around it by removing those .pth's and keeping a simple wx.pth containing "wx-2.8-gtk2-unicode".

I don't know if there's an "official" way of doing it :slight_smile:

Bye!

http://wiki.wxpython.org/MultiVersionInstalls

If you want to change the system wide default, I think you can edit
the wx.pth file.

Conrado

···

On Fri, May 22, 2009 at 13:14, Stani <spe.stani.be@gmail.com> wrote:

I would have expected that 2.8 would be the default, but of course
this is debatable. Is this intended behaviour? Is there a way to set
system wide the preference for 2.8 instead of 2.6?

Federico Fanton wrote:

Stani wrote:

I would have expected that 2.8 would be the default, but of course
this is debatable. Is this intended behaviour? Is there a way to set
system wide the preference for 2.8 instead of 2.6? Robin, does Ubuntu
implement this differently from upstream wxpython?

This used to work as expected in Ubuntu < 9.04...

Under Jaunty things are different, because every wxpython package adds a wx-2.[68]-gtk2-unicode.pth to /usr/lib/python2.6/dist-packages, so - if I understand it correctly - on a "import wx" Python chooses alphabetically, thus the 2.6 version..

I worked around it by removing those .pth's and keeping a simple wx.pth containing "wx-2.8-gtk2-unicode".

I don't know if there's an "official" way of doing it :slight_smile:

You're supposed to be able to use update-alternatives to switch between which wx.pth file is installed in [site|dist]-packages, but if Ubuntu has changed how that file is installed and managed then that feature is probably broken.

···

--
Robin Dunn
Software Craftsman

This is strange, the contents of wx.pth is:
wx-2.8-gtk2-unicode

So probably Federico Fanton is right, although I would expect that
alphabetically wx.pth would preceed wx-2.6-gtk2-unicode.pth
alphabetically.

Is there a way to set this as a user instead of system-wide (which
requires root privileges)?
Stani

···

On Fri, May 22, 2009 at 8:10 PM, Conrado Porto Lopes Gouvêa <conradoplg@gmail.com> wrote:

On Fri, May 22, 2009 at 13:14, Stani <spe.stani.be@gmail.com> wrote:

I would have expected that 2.8 would be the default, but of course
this is debatable. Is this intended behaviour? Is there a way to set
system wide the preference for 2.8 instead of 2.6?

MultiVersionInstalls - wxPyWiki

If you want to change the system wide default, I think you can edit
the wx.pth file.

--
Phatch Photo Batch Processor - http://photobatch.stani.be
SPE Python IDE - http://pythonide.stani.be

Could you give the full command? I don't know the argument, eg it is
clearly not:
sudo update-alternatives python-wxgtk

···

On Fri, May 22, 2009 at 11:46 PM, Robin Dunn <robin@alldunn.com> wrote:

Federico Fanton wrote:

Stani wrote:

I would have expected that 2.8 would be the default, but of course
this is debatable. Is this intended behaviour? Is there a way to set
system wide the preference for 2.8 instead of 2.6? Robin, does Ubuntu
implement this differently from upstream wxpython?

This used to work as expected in Ubuntu < 9.04...

Under Jaunty things are different, because every wxpython package adds a
wx-2.[68]-gtk2-unicode.pth to /usr/lib/python2.6/dist-packages, so - if I
understand it correctly - on a "import wx" Python chooses alphabetically,
thus the 2.6 version..

I worked around it by removing those .pth's and keeping a simple wx.pth
containing "wx-2.8-gtk2-unicode".

I don't know if there's an "official" way of doing it :slight_smile:

You're supposed to be able to use update-alternatives to switch between
which wx.pth file is installed in [site|dist]-packages, but if Ubuntu has
changed how that file is installed and managed then that feature is probably
broken.

--
Phatch Photo Batch Processor - http://photobatch.stani.be
SPE Python IDE - http://pythonide.stani.be

Stani wrote:

···

On Fri, May 22, 2009 at 8:10 PM, Conrado Porto Lopes Gouvêa > <conradoplg@gmail.com> wrote:

On Fri, May 22, 2009 at 13:14, Stani <spe.stani.be@gmail.com> wrote:

I would have expected that 2.8 would be the default, but of course
this is debatable. Is this intended behaviour? Is there a way to set
system wide the preference for 2.8 instead of 2.6?

MultiVersionInstalls - wxPyWiki

If you want to change the system wide default, I think you can edit
the wx.pth file.

This is strange, the contents of wx.pth is:
wx-2.8-gtk2-unicode

So probably Federico Fanton is right, although I would expect that
alphabetically wx.pth would preceed wx-2.6-gtk2-unicode.pth
alphabetically.

Is there a way to set this as a user instead of system-wide (which
requires root privileges)?

I think dirs in the PYTHONPATH env variable are put in the sys.path before dirs specified in .pth files.

--
Robin Dunn
Software Craftsman

Stani wrote:

Federico Fanton wrote:

Stani wrote:

I would have expected that 2.8 would be the default, but of course
this is debatable. Is this intended behaviour? Is there a way to set
system wide the preference for 2.8 instead of 2.6? Robin, does Ubuntu
implement this differently from upstream wxpython?

This used to work as expected in Ubuntu < 9.04...

Under Jaunty things are different, because every wxpython package adds a
wx-2.[68]-gtk2-unicode.pth to /usr/lib/python2.6/dist-packages, so - if I
understand it correctly - on a "import wx" Python chooses alphabetically,
thus the 2.6 version..

I worked around it by removing those .pth's and keeping a simple wx.pth
containing "wx-2.8-gtk2-unicode".

I don't know if there's an "official" way of doing it :slight_smile:

You're supposed to be able to use update-alternatives to switch between
which wx.pth file is installed in [site|dist]-packages, but if Ubuntu has
changed how that file is installed and managed then that feature is probably
broken.

Could you give the full command? I don't know the argument, eg it is
clearly not:
sudo update-alternatives python-wxgtk

It should be something like:

     sudo update-alternatives --set NAME DEST

Where NAME is some link in /etc/alternatives (used to be just wx.pth, but now I think it is something like wx$PYVER.pth) and DEST is the file that it should be linked to. My packages install the DEST files in /usr/lib/wx/python$PYVER/wx$WXVER.pth. I'm not sure if the Ubuntu packages follow the same pattern any more, or even if they are still using update-alternatives for that .pth file. (And I don't have an untweaked Ubuntu box handy to check.)

···

On Fri, May 22, 2009 at 11:46 PM, Robin Dunn <robin@alldunn.com> wrote:

--
Robin Dunn
Software Craftsman

Well, very strange, if I do:
$ ls /etc/alternatives | grep wx
wx2.5.pth
wx2.6.pth

$ sudo update-alternatives --config wx2.6.pth
[sudo] password for stani:

Er zijn 2 alternatieven die 'wx2.6.pth' voorzien.

  Selectie Alternatieven

···

On Sat, May 23, 2009 at 12:14 AM, Robin Dunn <robin@alldunn.com> wrote:

It should be something like:

sudo update-alternatives --set NAME DEST

Where NAME is some link in /etc/alternatives (used to be just wx.pth, but
now I think it is something like wx$PYVER.pth) and DEST is the file that it
should be linked to. My packages install the DEST files in
/usr/lib/wx/python$PYVER/wx$WXVER.pth. I'm not sure if the Ubuntu packages
follow the same pattern any more, or even if they are still using
update-alternatives for that .pth file. (And I don't have an untweaked
Ubuntu box handy to check.)

-----------------------------------------------
*+ 1 /usr/lib/wx/python/wx2.8.pth
          2 /usr/lib/wx/python/wx2.6.pth

It shows that 2.8 is already the default for wx2.6.pth

I noticed a bug, that in sys.path both 2.6 and 2.8 were present, so I
reported it here: