1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
PYTHON setup.py build_ext --inplace
PYTHON -c "import a; a.test()"
######## setup.py ########
from Cython.Build.Dependencies import cythonize
from distutils.core import setup
setup(
ext_modules=cythonize("a.py"),
)
######## a.py ########
class ExtTypePass(object):
pass
class ExtTypePxdDocstring(object):
pass
class ExtTypeDocstring(object):
"""huhu!""" # this should override the .pxd docstring
class ExtTypeAttributes(object):
"""
>>> x = ExtTypeAttributes()
>>> x.b
[1, 2, 3]
"""
def __init__(self):
self.a = 123
self.b = [1, 2, 3]
def test():
import os.path
assert 'a.py' not in os.path.basename(__file__), __file__
assert not ExtTypePass().__doc__, ExtTypePass().__doc__
assert ExtTypeDocstring().__doc__ == "huhu!", ExtTypeDocstring().__doc__
assert ExtTypePxdDocstring().__doc__ == "ho, ho, ho!", ExtTypePxdDocstring().__doc__
import doctest
doctest.testmod(verbose=True)
######## a.pxd ########
cdef class ExtTypePass:
pass
cdef class ExtTypePxdDocstring:
"""ho, ho, ho!"""
cdef class ExtTypeAttributes:
cdef int a
cdef readonly list b
|