C++ cythonize test.
authorRobert Bradshaw <robertwb@math.washington.edu>
Sun, 5 Dec 2010 09:45:57 +0000 (01:45 -0800)
committerRobert Bradshaw <robertwb@math.washington.edu>
Sun, 5 Dec 2010 09:45:57 +0000 (01:45 -0800)
Cython/Build/Dependencies.py
Cython/Compiler/Main.py
tests/build/cpp_cythonize.srctree [new file with mode: 0644]

index cdbe4e863251a33fbd7a5ebeec801888e338bc65..07a23ea24a846ccbc4bfd698aa63cfd2667953e1 100644 (file)
@@ -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 = []
index 51d0a08143e47e2b6b14a540fad06586857f673d..2c46202ee47d8c08a25cd0b5aeaf2aad83e0dc97 100644 (file)
@@ -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 (file)
index 0000000..88c21f7
--- /dev/null
@@ -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