From: Matthias B. <ba...@ir...> - 2006-12-14 09:51:35
|
Paul Kinnane wrote: > I have a situation where I need to run pyode under 2 versions of python > – 2.1 and 2.4. In order to do this, I need to compile pyODE under > python 2.1 and 2.4, which I have done successfully. However I need to > differentiate to the names of the libraries from the 2 versions (they > both compile as ode.pyd), so I can specifically import one of them > depending on which version of python is running. When I simply rename > ode.pyd to ode21.pyd, the import command does not work (since I guess > there is a naming difference between the compiled C code and the pyd name. Right, the initialization function of the extension module must be called "init<modulename>", in the case of ode it's "initode". If you rename the module to ode21 Python expects the function to be called "initode21", but this function doesn't exist, so the import fails. > So my question is, how can I compile pyODE to produce a filename of > ode21.pyd? Pyrex names the initialization function after the input file, so you would have to rename src/ode.pyx to src/ode21.pyx and update the setup script accordingly so that Pyrex reads the renamed file. Alternatively you could just manually modify the generated source file and rename the init function. But the other question is, why do you keep modules for two separate Python versions in the same directory? You could stick the correct ode.pyd into sub-directories py21 and py24 and either update PYTHONPATH or sys.path so that they point to the correct directory. - Matthias - |