1PYTHON setup.py build_ext --inplace 2PYTHON -c "import a" 3 4######## setup.py ######## 5 6 7from Cython.Build import cythonize 8from distutils.core import setup 9 10setup( 11 ext_modules = cythonize("*.pyx"), 12) 13 14######## other.pxd ######## 15 16cdef class A: 17 pass 18 19cdef int foo(int) 20 21######## other.pyx ######## 22 23cdef class A: 24 pass 25 26cdef int foo(int a): 27 return a**2 28 29######## pkg/__init__.py ######## 30 31 32######## pkg/sub.pxd ######## 33 34ctypedef int my_int 35 36######## pkg/subpkg/__init__.py ######## 37 38######## pkg/subpkg/submod.pxd ######## 39 40ctypedef int my_int 41 42######## a.pyx ######## 43 44from other cimport ( 45 A, 46 foo, 47) 48print(A, foo(10)) 49 50cimport other 51 52cdef call_fooptr(int (*fptr)(int)): 53 return fptr(10) 54 55def call_other_foo(): 56 x = other.foo # GH4000 - failed because other was untyped 57 return call_fooptr(x) # check that x is correctly resolved as a function pointer 58 59print(other.A, other.foo(10), call_other_foo()) 60 61from pkg cimport sub 62cdef sub.my_int a = 100 63 64from pkg.subpkg cimport submod 65