473,378 Members | 1,156 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Dealing with multiple versions of packages...

Hi all,

We've been having a discussion over on the wxPython-users mailing list
about how to deal with multiple versions of wxPython. During the
discussion it came up that this isn't a problem faced only by
wxPython, but would have to be dealt with by virtually all packages.

The root of the problem is what to do when you install a new version
of wxPython, and want to be able to keep using the old one. This
question comes up frequently on the users list, and various schemes
are used by a variety of people. These schemes mostly involve having
some sort of script that re-names or re-links the site-packages/wx
directory, so the chosen version can be used.

This works fine if your goal is to be able to switch back an forth for
testing, and during the process of moving your app(s) to a new
version.

However, my goal (and I don't think I'm alone) is to have both
versions installed and working at the same time, and have the app able
to select between them. I want this because I have a bunch of small
utilities that use wxPython, and I don't want them to break when I
upgrade, forcing me to go back and port all of them to a new
version...if it ain't broke, I don't want to fix it. What I would like
is analogous to using:

#/usr/bin/env python2.2

and

#/usr/bin/env python2.3

at the top of my python programs... I can have all my old 2.2 scripts
work just fine, while I write new ones for 2.3.

The easiest proposal is:

1) wxPython gets installed into:

site-packages/wxXXX (with XXX) being the version number

You could put a link to wx if you want, so as not to change anything
for people who don't want to change.

For this to work, ALL the stuff in the demo and libs would have to
import this way"

import wxXXX as wx

This creates problem when the user needs sub-packages: This won't
work:

import wx251 as wx
import wx.lib.buttons

Which I think points out a problem with the package import mechanism,
but I won't go there at the moment....

Another proposal is:

2) put wx251 deeper in the structure:

from wxPythonVersions.251 import wx
from wxPythonVersions.251 import wx.lib.buttons

wxPythonVersions (or a shorter, catchier name) would live in
site-packages. You could put a symlink:

site-packages/wx --> site-packages/wxPythonVersions/251/wx

for backward compatibility.

I think this would work great, but I also think there will be a strong
push to have a default:

import wx

which would require a symlink, and you can't symlink on Windows.

So ... What have other folks done to deal with this?
Would either of the above methods work well?
What pitfalls am I missing?
Is there a standard Pythonesque way to handle this?

-Chris
Jul 18 '05 #1
3 3986
I haven't heard of a standard way to do it.

I downloaded PyGTK 2.0.x a while back and I remember looking at a
package structure that looked like it was designed to do this. You
might want to check that for ideas. (I don't have it on my machine now.)

Also I was using a python module today that behaved differently upon
import, depending on a property of "sys". Like:

import sys
sys.coinit_flags = 0
import pythoncom # initializes COM with sys.coinit_flags

In your case wx could be a package with an __init__.py that imported
subpackages depending on what version was set (with a default of
course). To import packages based on a string variable you have to use
__import__.

You could also set PYTHONPATH to the version you want. ?

Rob

Jul 18 '05 #2
Chris Barker wrote:
Hi all,

We've been having a discussion over on the wxPython-users mailing list
about how to deal with multiple versions of wxPython. During the
discussion it came up that this isn't a problem faced only by
wxPython, but would have to be dealt with by virtually all packages.

The root of the problem is what to do when you install a new version
of wxPython, and want to be able to keep using the old one. This
question comes up frequently on the users list, and various schemes
are used by a variety of people. These schemes mostly involve having
some sort of script that re-names or re-links the site-packages/wx
directory, so the chosen version can be used.

This works fine if your goal is to be able to switch back an forth for
testing, and during the process of moving your app(s) to a new
version.

However, my goal (and I don't think I'm alone) is to have both
versions installed and working at the same time, and have the app able
to select between them. I want this because I have a bunch of small
utilities that use wxPython, and I don't want them to break when I
upgrade, forcing me to go back and port all of them to a new
version...if it ain't broke, I don't want to fix it. What I would like
is analogous to using:

#/usr/bin/env python2.2

and

#/usr/bin/env python2.3

at the top of my python programs... I can have all my old 2.2 scripts
work just fine, while I write new ones for 2.3.

The easiest proposal is:

1) wxPython gets installed into:

site-packages/wxXXX (with XXX) being the version number

You could put a link to wx if you want, so as not to change anything
for people who don't want to change.

For this to work, ALL the stuff in the demo and libs would have to
import this way"

import wxXXX as wx

This creates problem when the user needs sub-packages: This won't
work:

import wx251 as wx
import wx.lib.buttons

Which I think points out a problem with the package import mechanism,
but I won't go there at the moment....

Another proposal is:

2) put wx251 deeper in the structure:

from wxPythonVersions.251 import wx
from wxPythonVersions.251 import wx.lib.buttons

wxPythonVersions (or a shorter, catchier name) would live in
site-packages. You could put a symlink:

site-packages/wx --> site-packages/wxPythonVersions/251/wx

for backward compatibility.

I think this would work great, but I also think there will be a strong
push to have a default:

import wx

which would require a symlink, and you can't symlink on Windows.

So ... What have other folks done to deal with this?
Would either of the above methods work well?
What pitfalls am I missing?
Is there a standard Pythonesque way to handle this?

-Chris


How about introducing some new syntax:

import wx where wx.version >= "2.5"

Then we just need a means of determining the version.
You could use a directory name of wx-2.5 for the package rather than wx
Or maybe have an enhanced version of .pth files that specifies package
attributes.

It would be nice if the above could be combined with the Python Package
Index to automatically fetch packages...

Davod
Jul 18 '05 #3
Ch**********@noaa.gov (Chris Barker) wrote in message news:<62*************************@posting.google.c om>...
Hi all,

We've been having a discussion over on the wxPython-users mailing list
about how to deal with multiple versions of wxPython. During the
discussion it came up that this isn't a problem faced only by
wxPython, but would have to be dealt with by virtually all packages.


Check out Pmw (pmw.sourceforge.net) for ideas. It stores stuff under a
root of Pmw, but then has separate directories under that for each version.
Ie., Pmw_1_1, Pmw_1_2, etc. The __init__.py in the root is then a special
lazy loader which by default uses the latest version, but you can specify
a specific version by using a setversion() method. Whatever version you
end up using, everything is still referenced as Pmw.SomeClass rather
than having to hard code the version everywhere.
Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Edwin Young | last post by:
Hi, I'm developing an application which is primarily in Python but has some C-coded extension modules. These modules aren't really useful to anyone other than the main application. The app works...
1
by: rzantow | last post by:
I currently have both 2.3 and 2.4 on my Win2k computer. For the most part, I've been able to run each version, but I'm not configured completely correctly and I've run into a snafu. I downloaded...
4
by: Nicolas Fleury | last post by:
Hi, I'm trying to support two Python versions at the same time and I'm trying to find effective mechanisms to support modules compiled in C++ transparently. All my code in under a single...
1
by: bdj | last post by:
Hello! Can anyone tell me where to read more about best practices about this: Should I put data in a seperate scheme for tables, packages in anoter schema and create a lot of users that have...
2
by: Andreas Håkansson | last post by:
Seeing how my previous post seem to have fallen between the cracks, I thought I would have a second, more direct, go at it. So my question is "Is it possible to group (Muenchian method) over...
2
by: Marcus | last post by:
I have seen many posts of people with the same problem as me (attached below), but I have yet to see any solutions posted. Has anyone figured out how to deploy an Asp.net web site to the webserver...
3
by: Richard Lewis Haggard | last post by:
We are having a lot of trouble with problems relating to failures relating to 'The located assembly's manifest definition with name 'xxx' does not match the assembly reference" but none of us here...
0
by: Gabriel Genellina | last post by:
En Sat, 10 May 2008 01:38:24 -0300, Banibrata Dutta <banibrata.dutta@gmail.comescribió: Packages containing only .py modules ("pure" packages) are OK; packages using C extensions (.dll, .pyd)...
0
by: norseman | last post by:
mercado mercado wrote: ========================================================== Yes, but you may not like it. I do what you do. Prod and devel subdirs. I store the paths in a var at the top...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.