Distributing 2 python modules with incompatible API

Diez B. Roggisch deets at nospam.web.de
Wed Jun 4 10:54:43 EDT 2008


mathieu wrote:

> hi there,
> 
>   As far as I understand python is not using the usual UNIX system of
> soname when two libraries provide incompatible API. So let say I have
> a _foo.so version 1.2 and 2.0, all I can (should do) is move them
> underneath a subdirectory in site-package:
> 
>   pythonX.Y/site-package/foo1.2/_foo.so
>   pythonX.Y/site-package/foo1.2/foo.py
> and
>   pythonX.Y/site-package/foo2.0/_foo.so
>   pythonX.Y/site-package/foo2.0/foo.py
> 
> Then a central foo.pth would (sytem-wide) define which one is the
> default version:
> 
>   pythonX.Y/site-package/foo.pth
> 
>   If this is correct ? Is there any documentation that I missed ?

You can use setuptools + pkg_resources to install versions in parallel -
then you need to do an explicit

pkg_resources.require("foo == 1.2")

before importing foo the first time.

Diez



More information about the Python-list mailing list