diff options
Diffstat (limited to 'tests/run/different_package_names.srctree')
-rw-r--r-- | tests/run/different_package_names.srctree | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/run/different_package_names.srctree b/tests/run/different_package_names.srctree new file mode 100644 index 000000000..f70699012 --- /dev/null +++ b/tests/run/different_package_names.srctree @@ -0,0 +1,43 @@ +# mode: run +# tag: import,cimport,packages + +PYTHON setup.py build_ext --inplace +PYTHON -c "import pkg_py" +PYTHON -c "import pkg_py.pkg_pyx" +PYTHON -c "import pkg_py.pkg_pyx.module as module; module.run_test()" + +######## setup.py ######## + +from distutils.core import setup +from Cython.Build import cythonize + +setup( + ext_modules=cythonize('**/*.pyx', language_level=3), +) + + +######## pkg_py/__init__.py ######## + +TYPE = 'py' + +######## pkg_py/pkg_pyx/__init__.pyx ######## + +TYPE = 'pyx' + +######## pkg_py/pkg_pyx/pkg_pxd/__init__.pxd ######## + +# Not what Python would consider a package, but Cython can use it for cimports. +from libc.math cimport fabs + +######## pkg_py/pkg_pyx/module.pyx ######## + +from pkg_py.pkg_pyx.pkg_pxd cimport fabs + +def run_test(): + import pkg_py + assert pkg_py.TYPE == 'py' + + import pkg_py.pkg_pyx + assert pkg_py.pkg_pyx.TYPE == 'pyx' + + assert fabs(-2.0) == 2.0 |