| 1 |
PYTHON setup.py build_ext --inplace |
| 2 |
|
| 3 |
######## setup.py ######## |
| 4 |
|
| 5 |
from Cython.Build import cythonize |
| 6 |
from Cython.Distutils.extension import Extension |
| 7 |
|
| 8 |
import sys |
| 9 |
sys.path.append("path") |
| 10 |
|
| 11 |
ext_modules = [ |
| 12 |
Extension("importer", ["importer.pyx"]), |
| 13 |
] |
| 14 |
|
| 15 |
ext_modules = cythonize(ext_modules, include_path=["include"]) |
| 16 |
|
| 17 |
|
| 18 |
######## pkg/__init__.py ######## |
| 19 |
|
| 20 |
|
| 21 |
######## pkg/a.pxd ######## |
| 22 |
|
| 23 |
cdef class A(object): |
| 24 |
pass |
| 25 |
|
| 26 |
######## importer.pyx ######## |
| 27 |
|
| 28 |
cimport pkg.a |
| 29 |
cimport pkg.a as a |
| 30 |
cimport pkg.a as a_by_another_name |
| 31 |
from pkg cimport a as from_cimported_a |
| 32 |
|
| 33 |
cdef class A1(a.A): |
| 34 |
pass |
| 35 |
|
| 36 |
cdef class A2(a_by_another_name.A): |
| 37 |
pass |
| 38 |
|
| 39 |
cdef class A3(pkg.a.A): |
| 40 |
pass |
| 41 |
|
| 42 |
cdef class A4(from_cimported_a.A): |
| 43 |
pass |