diff options
author | Matus Valo <matusvalo@users.noreply.github.com> | 2021-12-14 14:34:52 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-14 14:34:52 +0100 |
commit | ed6478f85d63f36ca9f396150781087a032aecdb (patch) | |
tree | 3a961397e305515acef6c0d64f2b4b6515dd9fc0 /tests/pyximport | |
parent | 98fc9f1a47fb3585cd03eff5c7672ce4ae9d7f1f (diff) | |
download | cython-ed6478f85d63f36ca9f396150781087a032aecdb.tar.gz |
Use cythonize() in pyximport (GH-4339)
Closes https://github.com/cython/cython/issues/2304
Diffstat (limited to 'tests/pyximport')
-rw-r--r-- | tests/pyximport/pyximport_pyimport_only.srctree | 19 | ||||
-rw-r--r-- | tests/pyximport/pyximport_pyxbld.srctree | 35 |
2 files changed, 54 insertions, 0 deletions
diff --git a/tests/pyximport/pyximport_pyimport_only.srctree b/tests/pyximport/pyximport_pyimport_only.srctree new file mode 100644 index 000000000..63e8ae996 --- /dev/null +++ b/tests/pyximport/pyximport_pyimport_only.srctree @@ -0,0 +1,19 @@ + +PYTHON -c "import pyimport_test; pyimport_test.test()" + +######## pyimport_test.py ######## + +import os.path +import pyximport + +pyximport.install(pyximport=False, pyimport=True, + build_dir=os.path.join(os.path.dirname(__file__), "TEST_TMP")) + +def test(): + import mymodule + assert mymodule.test_string == "TEST" + assert not mymodule.__file__.rstrip('oc').endswith('.py'), mymodule.__file__ + +######## mymodule.py ######## + +test_string = "TEST" diff --git a/tests/pyximport/pyximport_pyxbld.srctree b/tests/pyximport/pyximport_pyxbld.srctree new file mode 100644 index 000000000..b277111a0 --- /dev/null +++ b/tests/pyximport/pyximport_pyxbld.srctree @@ -0,0 +1,35 @@ + +PYTHON -c "import basic_test; basic_test.test()" + +######## basic_test.py ######## + +import os.path +import pyximport + +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; |