JonnyJD/python-discid

cygwin: ImportError: dynamic module does not define init function (initdiscid)

JonnyJD opened this issue · 3 comments

On current master (601811c) Cygwin (Python 2.6.8) fails the examples with:

$ ./examples.py
Traceback (most recent call last):
  File "./examples.py", line 6, in <module>
    import discid
ImportError: dynamic module does not define init function (initdiscid)

import discid is not importing discid.py it tried to import discid.dll that was in the same folder Oo.
I had all the different dlls in one folder to check them with one git repository.

EDIT:
It doesn't explicitely tell, but when using the Python API in the C library, one can apparently import the dll directly.
See http://docs.python.org/2/extending/extending.html.

The same thing works on Linux when discid.so is present. Though it is less likely that this happens, because libraries mostly have the lib prefix on linux. (especially libdiscid)

Traceback (most recent call last):
  File "./examples.py", line 6, in <module>
    import discid
ImportError: dynamic module does not define init function (PyInit_discid)

This doesn't happen for Python on Windows directly. Neither opening the file with IDLE, nor using the cmd (example.py) or in MSYS (/C/Python27/python.exe example.py).
Possibly Python for Windows detects this problem and doesn't try to load discid.dll. It would seem weird that the dynamic module feature works on Cygwin, but not on Windows.

In Mac OS X I could reproduce this with discid.so (normally .dylib is used for dynamic libraries):

Traceback (most recent call last):
  File "./examples.py", line 6, in <module>
    import discid
ImportError: dynamic module does not define init function (initdiscid)

There is no way for me to fix this in discid.py since that file is not even loaded.