From 2edd90452032d104a470c860a01b49a58fbb3da8 Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Sun, 5 Dec 2010 01:45:57 -0800 Subject: [PATCH] C++ cythonize test. --- Cython/Build/Dependencies.py | 2 +- Cython/Compiler/Main.py | 2 +- tests/build/cpp_cythonize.srctree | 27 +++++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 tests/build/cpp_cythonize.srctree diff --git a/Cython/Build/Dependencies.py b/Cython/Build/Dependencies.py index cdbe4e86..07a23ea2 100644 --- a/Cython/Build/Dependencies.py +++ b/Cython/Build/Dependencies.py @@ -426,7 +426,7 @@ def create_extension_list(patterns, ctx=None, aliases=None): def cythonize(module_list, nthreads=0, aliases=None, **options): c_options = CompilationOptions(options) cpp_options = CompilationOptions(options); cpp_options.cplus = True - ctx = options.create_context() + ctx = c_options.create_context() module_list = create_extension_list(module_list, ctx=ctx, aliases=aliases) deps = create_dependency_tree(ctx) to_compile = [] diff --git a/Cython/Compiler/Main.py b/Cython/Compiler/Main.py index 51d0a081..2c46202e 100644 --- a/Cython/Compiler/Main.py +++ b/Cython/Compiler/Main.py @@ -564,7 +564,7 @@ def create_default_resultobj(compilation_source, options): def run_pipeline(source, options, full_module_name = None): # Set up context - context = optons.create_context() + context = options.create_context() # Set up source object cwd = os.getcwd() diff --git a/tests/build/cpp_cythonize.srctree b/tests/build/cpp_cythonize.srctree new file mode 100644 index 00000000..88c21f79 --- /dev/null +++ b/tests/build/cpp_cythonize.srctree @@ -0,0 +1,27 @@ +PYTHON setup.py build_ext --inplace +PYTHON -c "import a; a.use_vector([1,2,3])" + +######## setup.py ######## + +from Cython.Build.Dependencies import cythonize + +from distutils.core import setup + +setup( + ext_modules = cythonize("*.pyx"), +) + +######## a.pyx ######## + +# distutils: language = c++ + +from libcpp.vector cimport vector + +def use_vector(L): + try: + v = new vector[int]() + for a in L: + v.push_back(a) + return v.size() + finally: + del v -- 2.26.2