Extensions in windows.

Daniel Dittmar daniel.dittmar at sap.com
Fri Jan 11 09:40:45 EST 2002


> Is there a way to make extensions on Windows which are independent of
> the python version, and if not, what is the best way to handle this
> problem
> in distutils? (I would like to include multiple versions of the same
> extension).

My solution without distutils:

<dir>
    sapdb.py
    python15\__init__.py
    python15\sapdb.pyd
    python20\__init__.py
    python20\sapdb.py
    python21\__init__.py
    python21\sapdb.py
    python22\__init__.py
    python22\sapdb.py

sapdb.py contains the following code
#
#
import sys

_pythonVersion = sys.version [:3]

del sys

if _pythonVersion == "2.2":
    from python22.sapdb import *
elif _pythonVersion == "2.1":
    from python21.sapdb import *
elif _pythonVersion == "2.0":
    from python20.sapdb import *
elif _pythonVersion == "1.5":
    from python15.sapdb import *
else:
    raise "Python version not supported", _pythonVersion

del _pythonVersion
#
# end of file

You can add the directory containing sapdb.py to your PYTHONPATH and should
then be able to do an 'import sapdb' in any of the supported releases.

Daniel






More information about the Python-list mailing list