4

There might be something obvious I'm doing wrong, but I just can't get an extension type to derive from another, even in this simple example:

$ cat a.pyx 

from b.py import MyClass

cdef class NewClass(MyClass):
    pass

$ cat b.pyx 

class MyClass(object):
    def __init__(self):
        print("HELLO")

$ cythonize3 a.pyx 
Compiling /home/jonas/test/a.pyx because it changed.
[1/1] Cythonizing /home/jonas/test/a.pyx

Error compiling Cython file:
------------------------------------------------------------
...

from b.py import MyClass

cdef class NewClass(MyClass):
                   ^
------------------------------------------------------------

a.pyx:4:20: First base of 'NewClass' is not an extension type
Traceback (most recent call last):
  File "/usr/bin/cythonize3", line 11, in <module>
    load_entry_point('Cython==0.28.4', 'console_scripts', 'cythonize')()
  File "/usr/lib64/python3.6/site-packages/Cython/Build/Cythonize.py", line 196, in main
    cython_compile(path, options)
  File "/usr/lib64/python3.6/site-packages/Cython/Build/Cythonize.py", line 90, in cython_compile
    **options.options)
  File "/usr/lib64/python3.6/site-packages/Cython/Build/Dependencies.py", line 1026, in cythonize
    cythonize_one(*args)
  File "/usr/lib64/python3.6/site-packages/Cython/Build/Dependencies.py", line 1146, in cythonize_one
    raise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: /home/jonas/test/a.pyx

Does anyone have a clue what I'm doing wrong? Is this not supported for some reason?

E. T.
  • 847
  • 10
  • 26

0 Answers0