What is a good way of having several versions of a python module installed in parallell?

Steve Holden steve at holdenweb.com
Tue Sep 25 11:55:30 EDT 2007


Diez B. Roggisch wrote:
> Joel Hedlund wrote:
> 
>> Hi!
>>
>> I write, use and reuse a lot of small python programs for variuos purposes
>> in my work. These use a growing number of utility modules that I'm
>> continuously developing and adding to as new functionality is needed.
>> Sometimes I discover earlier design mistakes in these modules, and rather
>> than keeping old garbage I often rewrite the parts that are
>> unsatisfactory. This often breaks backwards compatibility, and since I
>> don't feel like updating all the code that relies on the old (functional
>> but flawed) modules, I'm left with a hack library that depends on halting
>> versions of my utility modules. The way I do it now is that I update the
>> programs as needed when I need them, but this approach makes me feel a bit
>> queasy. It seems to me like I'm thinking about this in the wrong way.
>>
>> Does anyone else recognize this situation in general? How do you handle
>> it?
>>
>> I have a feeling it should be possible to have multiple versions of the
>> modules installed simultaneously, and maybe do something like this:
>>
>> mymodule/
>> + mymodule-1.1.3/
>> + mymodule-1.1.0/
>> + mymodule-0.9.5/
>> - __init__.py
>>
>> and having some kind of magic in __init__.py that let's the programmer
>> choose version after import:
>>
>> import mymodule
>> mymodule.require_version("1.1.3")
>>
>> Is this a good way of thinking about it? What would be an efficient way of
>> implementing it?
> 
> Use setuptools. It can exactly do that - install different versions parallel
> as eggs, and with a pre-import require-statment you require the desired
> one.
> 
> Diez

Of course a much simpler, less formal solution, is to install the 
libraries required by a program along with that program in its own 
directory. This more or less guarantees you will get out of sync.

Otherwise, three words:

   test driven development

regards
  Steve
-- 
Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd           http://www.holdenweb.com
Skype: holdenweb      http://del.icio.us/steve.holden

Sorry, the dog ate my .sigline




More information about the Python-list mailing list