compiling an extension for several versions of python

James Stroud jstroud at mbi.ucla.edu
Wed Sep 12 19:51:25 EDT 2007


mh at pixar.com wrote:
> I don't have access to site-packages, but I would like
> to provide versions of my c-language package compiled against
> python 2.4 and 2.5.
> 
> I "own" a library directory which is included in our site's
> sys.path.  Currently this is where the 2.4 shared libary
> is installed.
> 
> What's the most canonical way of doing this?  This is on linux.
> 
> Many TIA!
> Mark
> 

Normally, you would make 2 different distros which people could 
download, etc. But in this setting, if I get your meaning correctly, 
your best bet would be to wrap them in another module and let people 
import the wrapper module. The wrapper module would then use one the 
following calls to decide which version of your package to import:

py> import sys
py> sys.version
'2.5 (r25:51908, Oct 10 2006, 03:45:47) \n[GCC 4.0.1 (Apple Computer, 
Inc. build 5363)]'
py> sys.version_info
(2, 5, 0, 'final', 0)

James



More information about the Python-list mailing list