# -*- coding: utf-8 -*- # tag: py3, pep489 PYTHON setup.py build_ext --inplace PYTHON -m mydoctest ########### mydoctest.py ####### import doctest import from_py val = doctest.testmod(from_py)[0] import from_cy val += doctest.testmod(from_cy)[0] exit(val) ########### setup.py ######## # -*- coding: utf-8 -*- from __future__ import unicode_literals from Cython.Build import cythonize files = ["mymoð.pyx", "from_cy.pyx", "测试.py" ] modules = cythonize(files) from distutils.core import setup setup( ext_modules = modules ) ############ mymoð.pyx ######### def f(): return True cdef public api void cdef_func(): pass ############ pxd_moð.pxd ########## cdef struct S: int x cdef public api void cdef_func() # just to test generation of headers ############ 测试.py ############# def g(): return 1 ############ from_py.py ######### # -*- coding: utf-8 -*- import mymoð from mymoð import f import 测试 __doc__ = """ >>> mymoð.f() True >>> f() True >>> 测试.g() 1 """ ######### from_cy.pyx ########## # -*- coding: utf-8 -*- import mymoð from mymoð import f import 测试 cimport pxd_moð from pxd_moð cimport S def test_imported(): """ >>> test_imported() True """ return mymoð.f() and f() # True and True def test_imported2(): """ >>> test_imported2() 1 """ return 测试.g() def test_cimported(): """ >>> test_cimported() 3 """ cdef pxd_moð.S v1 v1.x = 1 cdef S v2 v2.x = 2 return v1.x + v2.x