4

I'm using the 64-bit version of python 3.3 and cython 0.18 on Windows 7.

I've encountered a problem that is thoroughly described here

One issue that was not discussed in the linked thread was, that the python's distutils called the link command (link.exe) with an option to export (this is only needed on Windows) a symbol named PyInit_[module name] but, if the module name was __init__ the cython-created C file only specified a symbol with name PyInit_[package name] and the linker gave back this error: LINK : error LNK2001: unresolved external symbol.

Fortunately, I managed to fix this issue in the build_ext module.

The problem that remains is that a compiled __init__.pyd module of mypackage containing an import statement like

import math

Throws an

SystemError: Parent module '' not loaded, cannot perform relative import

When mypackage is imported (no matter from where it is imported). Without import statements it works as expected though.

If anyone has a fix, workaround or information that could solve this problem or could explain why it's not (yet) solvable please, share your knowledge.

uzumaki
  • 1,743
  • 17
  • 32
  • Hi! Could you explain how you solved the LNK2001 error? I am having the same problem cythonizing __init__.py files. – SuperGeo Jan 18 '18 at 13:41
  • @ SuperGeo See for example: [How to compile \_\_init\_\_.py file using cython on Windows](https://stackoverflow.com/questions/58797673/how-to-compile-init-py-file-using-cython-on-windows) – ead Aug 12 '20 at 07:59

0 Answers0