Loading multiple versions of the same package at the same time

2008-11-27 Thread della
Hi all,

I've got some pickled files representing graphs (using networkx,
http://networkx.lanl.gov if you're interested) that were produced
using version 0.36 of the library.

Now, they have released a new version of the library which is
incompatible with respect to pickled files, so what I'd like to do is
to write a script that loads the two versions of the library at once,
unpickles with the old one, creates a new object with the new version
and re-pickles it with the new version.

So, I installed the two versions of the package using easy_install -m,
but it looks like I can't import the two versions at once:

>>> from pkg_resources import require
>>> require('networkx==0.36')
[networkx 0.36 (/usr/lib/python2.5/site-packages/networkx-0.36-
py2.5.egg)]
>>> import networkx as nx_old
>>> require('networkx==1.0')
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python2.5/site-packages/pkg_resources.py", line 626,
in require
needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python2.5/site-packages/pkg_resources.py", line 528,
in resolve
raise VersionConflict(dist,req) # XXX put more info here
pkg_resources.VersionConflict: (networkx 0.36 (/usr/lib/python2.5/site-
packages/networkx-0.36-py2.5.egg), Requirement.parse('networkx==1.0'))

Any ideas?
Thanks a lot
matteo
--
http://mail.python.org/mailman/listinfo/python-list


Re: Loading multiple versions of the same package at the same time

2008-11-27 Thread della
On 27 Nov, 11:21, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:

> You can't do that. How should python distinguish between the two modules
> with the same name?

That's why I was trying to import them with different names :)

> What you can do is
>
>  - import the old package
>  - unpickle
>  - convert to some neutral exchange format, simple dicts, lists, tuples
>  - pickle that
>
>  - import the new package
>  - unpickle the exchange data
>  - stuff it into the new classes

Thanks, this is what I did.

matteo
--
http://mail.python.org/mailman/listinfo/python-list


Re: Loading multiple versions of the same package at the same time

2008-11-28 Thread della
On 27 Nov, 21:34, Terry Reedy <[EMAIL PROTECTED]> wrote:

> > But in the interpreters module dict, foo it is, and stays.
>
> But giving the modules different names on the disk should work, no?

Yes, but -- for what I've understood -- that wouldn't solve my
original problem with pickle, since I would need to carry around a
module with the new name forever :)

matteo
--
http://mail.python.org/mailman/listinfo/python-list