blob: b292e44c1ae5c0e9f57565f1c44458951978b1e5 (
plain)
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
|
PYTHON -c "import basic_test; basic_test.test()"
######## basic_test.py ########
import os.path
import pyximport
pyximport.DEBUG_IMPORT = True
pyximport.install(build_dir=os.path.join(os.path.dirname(__file__), "TEST_TMP"))
def test():
import mymodule
assert mymodule.test_string == "TEST"
assert mymodule.header_value == 5
assert not mymodule.__file__.rstrip('oc').endswith('.py'), mymodule.__file__
######## mymodule.pyxbld ########
def make_ext(modname, pyxfilename):
from distutils.extension import Extension
return Extension(name = modname,
sources=[pyxfilename],
include_dirs=['./headers'] )
######## mymodule.pyx ########
cdef extern from "myheader.h":
int test_value
header_value = test_value
test_string = "TEST"
######## headers/myheader.h ########
static int test_value = 5;
|