Giter Site home page Giter Site logo

autowrap's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

autowrap's Issues

Wrapping `struct`s

Sometimes it can be handy to wrap C-style structs for use with Python. These match pretty closely to Python's dataclass, which Cython recently added an implementation of in master ( cython/cython#3400 ). Alternatively they could work as normal extension types. Curious on people's thoughts about wrapping these 🙂

Example doesn't work

I tried to follow the minimal example in the README. However, after executing the command autowrap --out py_int_holder.pyx int_holder.pxd, I got the following error:

Error compiling Cython file:
------------------------------------------------------------
...
from cython.operator cimport dereference as deref, preincrement as inc, address as address
from py_int_holder cimport IntHolder as _IntHolder
cdef extern from "autowrap_tools.hpp":
    char * _cast_const_away(char *) 

cdef class IntHolder:
    ^
------------------------------------------------------------

py_int_holder.pyx:16:5: 'IntHolder' redeclared

Parsing of AttributeNodes in template argument fails

I have the following code:
IteratorWrapper[(libcpp_set[ DataProcessingSoftware].iterator)] software_ref
which leads to autowrap crashing since AttributeNodes are not handled in PXDParser _extract_type. I've tried to make changes to the handler (adding a case to handle AttributeNodes) but I cannot figure out how to update the CppType object to be an iterator of the above type.

How to wrap returned references?

I think currently we always copy because of memory safety. Would be nice to have an opt-in, if people really really want to reference into another object, even if it is very dangerous.

Templated instances defined by wrap-instances are not resolved by PXDParser

Defining a templated class with instances specified by wrap-instances in a PXD file does not make the instanced type available for template resolution in another PXD file.

Example:
in file a.pxd:

    cdef cppclass IteratorWrapper[Iterator]:
      # wrap-instances:
      #  ScoreTypeRef := IteratorWrapper[libcpp_set[ ScoreType ].iterator]
...

in file b.pxd:
libcpp_vector[ ScoreTypeRef ] assigned_scores
results in:
b.pxd:XX:YY: unknown type in template argument

Looking at the pyx code generated by a ScoreTypeRef is properly generated, in b however the templated type is just error.

[autowrap 0.6.0] Tests not generated and failed with Python3

Hi all.

There are some tests not generated under Python3.4

gcc -pthread -Wno-unused-result -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -I/usr/include/boost -fPIC -I/home/sagitter/rpmbuild/BUILD/python3-autowrap-0.6.0-1.20150121git75e9a5.fc21/autowrap/data_files/boost -I/home/sagitter/rpmbuild/BUILD/python3-autowrap-0.6.0-1.20150121git75e9a5.fc21/autowrap/data_files -I/home/sagitter/rpmbuild/BUILD/python3-autowrap-0.6.0-1.20150121git75e9a5.fc21/tests/test_files -I/usr/include/python3.4m -c shared_ptr_test.cpp -o build/temp.linux-x86_64-3.4/shared_ptr_test.o -Wno-unused-but-set-variable
g++ -pthread -shared -Wl,-z,relro -I/usr/include/boost build/temp.linux-x86_64-3.4/shared_ptr_test.o -L/usr/lib64 -lpython3.4m -o /tmp/tmp5thjld4a/m.cpython-34m.so
ok
tests.test_code_generator.test_libcpp ... ERROR
tests.test_code_generator.test_stl_libcpp ... ERROR
tests.test_code_generator.test_minimal ... ERROR
tests.test_code_generator.test_templated ... ERROR
tests.test_cython_build_process.testBuildExt ... running build_ext
cythoning itertest.pyx to itertest.cpp

Full log (starting from line #393): http://fpaste.org/183011/

Static method wrapped as instance method

I added the following static function to the IntHolder class:

static void dec(int& i) {
  i -= 1;
}

and the following declaration to int_holder.pxd:

@staticmethod
void dec(int & i)

This should be valid Cython. However, autowrap apparently ignores the decorator and generates an instance method from it:

def dec(self,  i ):
  assert isinstance(i, (int, long)), 'arg i wrong type'

  self.inst.get().dec((<int &>i))

[autowrap 0.6.1] using "const" keyword gives errors

Tested with commit d0e9a5 (Feb 9, 2015).
Usage of "const" causes autowrap to raise an exception.

Test code:

cdef extern from "<string>" namespace "std":
    cdef cppclass string:
        string()
        const char* c_str()

Autowrap raises following exception:

Traceback (most recent call last):
File "/usr/bin/autowrap", line 9, in <module>
    load_entry_point('autowrap==0.6.0', 'console_scripts', 'autowrap')()
File "/usr/lib/python2.7/site-packages/autowrap/Main.py", line 67, in main
    _main(sys.argv[1:])
File "/usr/lib/python2.7/site-packages/autowrap/Main.py", line 121, in _main
    run(pxds, addons, converters, out)
File "/usr/lib/python2.7/site-packages/autowrap/Main.py", line 200, in run
    decls, instance_map = autowrap.parse(pxds, ".")
File "/usr/lib/python2.7/site-packages/autowrap/__init__.py", line 51, in parse
    return DeclResolver.resolve_decls_from_files(files, root)
File "/usr/lib/python2.7/site-packages/autowrap/DeclResolver.py", line 171, in resolve_decls_from_files
    decls.extend(PXDParser.parse_pxd_file(full_path))
File "/usr/lib/python2.7/site-packages/autowrap/PXDParser.py", line 461, in parse_pxd_file
    result.append(handler(body, lines, path))
File "/usr/lib/python2.7/site-packages/autowrap/PXDParser.py", line 264, in parseTree
    decl = MethodOrAttributeDecl.parseTree(att, lines, pxd_path)
File "/usr/lib/python2.7/site-packages/autowrap/PXDParser.py", line 348, in parseTree
    result_type = _extract_type(node.base_type, decl)
File "/usr/lib/python2.7/site-packages/autowrap/PXDParser.py", line 188, in _extract_type
    return CppType(base_type.name, template_parameters, is_ptr, is_ref, is_unsigned, is_long, is_const=is_const)
AttributeError: 'CConstTypeNode' object has no attribute 'name'

Omitting the "const" keyword solves the problem,
however, then it doesn't follow the exact C definition.

License clarifications

Hi Uwe.

Many source files haven't got own license headers in the latest commit. Please, fix them as soon as possible or confirm that they are released with a BSD license.
autowrap is under review to be included in Fedora.

Thanks.

[autowrap 0.6.1] reference variables not supported as function return values

Tested with commit d0e9a5 (Feb 9, 2015).
It's impossible to wrap a C++ function returning a reference variable (even when "&" is omitted),
because the generated ".pyx"-file is invalid.
(Autowrap succeeds to generate the ".pyx"-file, but Cython fails to compile it.)

Test code:

cdef extern from "<string>" namespace "std":
    cdef cppclass string:
        string()
        string& assign (string&)

and the result:

<snip>
Autwrap has wrapped 1 classes, 2 methods and 0 enums

Error compiling Cython file:
------------------------------------------------------------
...
        self.inst = shared_ptr[_string](new _string())

    def assign(self, string in_0 ):
        assert isinstance(in_0, string), 'arg in_0 wrong type'

        cdef _string & * _r = new _string &(self.inst.get().assign((deref(in_0.inst.get()))))
                                                                                            ^
------------------------------------------------------------

something.pyx:30:93: Expected ')', found 'NEWLINE'

And if the "&" is omitted, such that the code becomes:

cdef extern from "<string>" namespace "std":
    cdef cppclass string:
        string()
        string assign (string&)

then the result becomes:

<snip>
Autwrap has wrapped 1 classes, 2 methods and 0 enums

Error compiling Cython file:
------------------------------------------------------------
...
        self.inst = shared_ptr[_string](new _string())

    def assign(self, string in_0 ):
        assert isinstance(in_0, string), 'arg in_0 wrong type'

        cdef _string * _r = new _string(self.inst.get().assign((deref(in_0.inst.get()))))
                                      ^
------------------------------------------------------------

something.pyx:30:39: Call with wrong number of arguments (expected 0, got 1)

DeclResolver.test_singular fails [Python3]

Hi.

autowrap tests fail with Python3 (not with Python2.7). Error log:

+ export CPPFLAGS=-I/usr/include/boost
+ CPPFLAGS=-I/usr/include/boost
+ export CXXFLAGS=-I/usr/include/boost
+ CXXFLAGS=-I/usr/include/boost
+ nosetests-3.3 -v --py3where=tests
tests.import_test.testImport ... ok
tests.testCode.test ... ok
tests.testCodeGenerator.test_number_conv ... running build_ext
cythoning number_conv.pyx to number_conv.cpp
warning: number_conv.pyx:18:0: Overriding cdef method with def method.
warning: number_conv.pyx:25:0: Overriding cdef method with def method.
warning: number_conv.pyx:32:0: Overriding cdef method with def method.
building 'number_conv' extension
creating build
creating build/temp.linux-x86_64-3.3
gcc -pthread -Wno-unused-result -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -I/usr/include/boost -fPIC -I/home/sagitter/rpmbuild/BUILD/python3-autowrap-0.4.0-4.20140602gitebde9f.fc20/autowrap/data_files/boost -I/home/sagitter/rpmbuild/BUILD/python3-autowrap-0.4.0-4.20140602gitebde9f.fc20/autowrap/data_files -I/home/sagitter/rpmbuild/BUILD/python3-autowrap-0.4.0-4.20140602gitebde9f.fc20/tests/test_files -I/usr/include/python3.3m -c number_conv.cpp -o build/temp.linux-x86_64-3.3/number_conv.o -Wno-unused-but-set-variable
g++ -pthread -shared -Wl,-z,relro -I/usr/include/boost build/temp.linux-x86_64-3.3/number_conv.o -L/usr/lib64 -lpython3.3m -o /tmp/tmp3a_5b0/number_conv.cpython-33m.so
ok
tests.testCodeGenerator.test_shared_ptr ... running build_ext
cythoning shared_ptr_test.pyx to shared_ptr_test.cpp
building 'm' extension
creating build
creating build/temp.linux-x86_64-3.3
gcc -pthread -Wno-unused-result -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -I/usr/include/boost -fPIC -I/home/sagitter/rpmbuild/BUILD/python3-autowrap-0.4.0-4.20140602gitebde9f.fc20/autowrap/data_files/boost -I/home/sagitter/rpmbuild/BUILD/python3-autowrap-0.4.0-4.20140602gitebde9f.fc20/autowrap/data_files -I/home/sagitter/rpmbuild/BUILD/python3-autowrap-0.4.0-4.20140602gitebde9f.fc20/tests/test_files -I/usr/include/python3.3m -c shared_ptr_test.cpp -o build/temp.linux-x86_64-3.3/shared_ptr_test.o -Wno-unused-but-set-variable
g++ -pthread -shared -Wl,-z,relro -I/usr/include/boost build/temp.linux-x86_64-3.3/shared_ptr_test.o -L/usr/lib64 -lpython3.3m -o /tmp/tmpk50pd5/m.cpython-33m.so
ok
tests.testCodeGenerator.test_libcpp ... running build_ext
cythoning libcpp_test.pyx to libcpp_test.cpp
building 'libcpp' extension
creating build
creating build/temp.linux-x86_64-3.3
gcc -pthread -Wno-unused-result -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -I/usr/include/boost -fPIC -I/home/sagitter/rpmbuild/BUILD/python3-autowrap-0.4.0-4.20140602gitebde9f.fc20/autowrap/data_files/boost -I/home/sagitter/rpmbuild/BUILD/python3-autowrap-0.4.0-4.20140602gitebde9f.fc20/autowrap/data_files -I/home/sagitter/rpmbuild/BUILD/python3-autowrap-0.4.0-4.20140602gitebde9f.fc20/tests/test_files -I/usr/include/python3.3m -c libcpp_test.cpp -o build/temp.linux-x86_64-3.3/libcpp_test.o -Wno-unused-but-set-variable
In file included from libcpp_test.cpp:349:0:
/home/sagitter/rpmbuild/BUILD/python3-autowrap-0.4.0-4.20140602gitebde9f.fc20/tests/test_files/libcpp_test.hpp: In constructor 'LibCppTest::LibCppTest()':
/home/sagitter/rpmbuild/BUILD/python3-autowrap-0.4.0-4.20140602gitebde9f.fc20/tests/test_files/libcpp_test.hpp:31:15: warning: 'LibCppTest::integer_ptr' will be initialized after [-Wreorder]
         Int * integer_ptr;
               ^
/home/sagitter/rpmbuild/BUILD/python3-autowrap-0.4.0-4.20140602gitebde9f.fc20/tests/test_files/libcpp_test.hpp:30:28: warning:   'std::vector<Int>* LibCppTest::integer_vector_ptr' [-Wreorder]
         std::vector<Int> * integer_vector_ptr;
                            ^
/home/sagitter/rpmbuild/BUILD/python3-autowrap-0.4.0-4.20140602gitebde9f.fc20/tests/test_files/libcpp_test.hpp:24:9: warning:   when initialized here [-Wreorder]
         LibCppTest(): i(0), integer_ptr(0), integer_vector_ptr(0) { };
         ^
g++ -pthread -shared -Wl,-z,relro -I/usr/include/boost build/temp.linux-x86_64-3.3/libcpp_test.o -L/usr/lib64 -lpython3.3m -o /tmp/tmp_gnvpl/libcpp.cpython-33m.so
ok
tests.testCodeGenerator.test_minimal ... running build_ext
cythoning minimal_wrapper.pyx to minimal_wrapper.cpp
building 'wrapped' extension
creating build
creating build/temp.linux-x86_64-3.3
gcc -pthread -Wno-unused-result -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -I/usr/include/boost -fPIC -I/home/sagitter/rpmbuild/BUILD/python3-autowrap-0.4.0-4.20140602gitebde9f.fc20/autowrap/data_files/boost -I/home/sagitter/rpmbuild/BUILD/python3-autowrap-0.4.0-4.20140602gitebde9f.fc20/autowrap/data_files -I/home/sagitter/rpmbuild/BUILD/python3-autowrap-0.4.0-4.20140602gitebde9f.fc20/tests/test_files -I/usr/include/python3.3m -c minimal_wrapper.cpp -o build/temp.linux-x86_64-3.3/minimal_wrapper.o -Wno-unused-but-set-variable
gcc -pthread -Wno-unused-result -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -I/usr/include/boost -fPIC -I/home/sagitter/rpmbuild/BUILD/python3-autowrap-0.4.0-4.20140602gitebde9f.fc20/autowrap/data_files/boost -I/home/sagitter/rpmbuild/BUILD/python3-autowrap-0.4.0-4.20140602gitebde9f.fc20/autowrap/data_files -I/home/sagitter/rpmbuild/BUILD/python3-autowrap-0.4.0-4.20140602gitebde9f.fc20/tests/test_files -I/usr/include/python3.3m -c minimal.cpp -o build/temp.linux-x86_64-3.3/minimal.o -Wno-unused-but-set-variable
g++ -pthread -shared -Wl,-z,relro -I/usr/include/boost build/temp.linux-x86_64-3.3/minimal_wrapper.o build/temp.linux-x86_64-3.3/minimal.o -L/usr/lib64 -lpython3.3m -o /tmp/tmpx3et8x/wrapped.cpython-33m.so
ok
tests.testCodeGenerator.test_templated ... running build_ext
cythoning templated_wrapper.pyx to templated_wrapper.cpp
building 'twrapped' extension
creating build
creating build/temp.linux-x86_64-3.3
gcc -pthread -Wno-unused-result -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -I/usr/include/boost -fPIC -I/home/sagitter/rpmbuild/BUILD/python3-autowrap-0.4.0-4.20140602gitebde9f.fc20/autowrap/data_files/boost -I/home/sagitter/rpmbuild/BUILD/python3-autowrap-0.4.0-4.20140602gitebde9f.fc20/autowrap/data_files -I/home/sagitter/rpmbuild/BUILD/python3-autowrap-0.4.0-4.20140602gitebde9f.fc20/tests/test_files -I/usr/include/python3.3m -c templated_wrapper.cpp -o build/temp.linux-x86_64-3.3/templated_wrapper.o -Wno-unused-but-set-variable
g++ -pthread -shared -Wl,-z,relro -I/usr/include/boost build/temp.linux-x86_64-3.3/templated_wrapper.o -L/usr/lib64 -lpython3.3m -o /tmp/tmp6rwnpo/twrapped.cpython-33m.so
ok
tests.testCythonBuildProcess.testBuildExt ... running build_ext
cythoning itertest.pyx to itertest.cpp
building 'itertest' extension
creating build
creating build/temp.linux-x86_64-3.3
gcc -pthread -Wno-unused-result -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -I/usr/include/boost -fPIC -I/usr/include/python3.3m -c itertest.cpp -o build/temp.linux-x86_64-3.3/itertest.o -Wno-unused-but-set-variable
g++ -pthread -shared -Wl,-z,relro -I/usr/include/boost build/temp.linux-x86_64-3.3/itertest.o -L/usr/lib64 -lpython3.3m -o /tmp/tmpmgrp38/itertest.cpython-33m.so
ok
tests.testCythonBuildProcess.testSimplePyx ... running build_ext
cythoning int_container_class.pyx to int_container_class.cpp
building 'ics' extension
creating build
creating build/temp.linux-x86_64-3.3
gcc -pthread -Wno-unused-result -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -I/usr/include/boost -fPIC -I/home/sagitter/rpmbuild/BUILD/python3-autowrap-0.4.0-4.20140602gitebde9f.fc20/tests/test_files -I/usr/include/python3.3m -c int_container_class.cpp -o build/temp.linux-x86_64-3.3/int_container_class.o -Wno-unused-but-set-variable
g++ -pthread -shared -Wl,-z,relro -I/usr/include/boost build/temp.linux-x86_64-3.3/int_container_class.o -L/usr/lib64 -lpython3.3m -o /tmp/tmp02jqmr/ics.cpython-33m.so
    cons called with 0x1ad82b0 3
    cons called with 0x1ad5f00 4
    cons called with 0x1ada110 7
    cons called with 0x18e9b70 0
    copy cons called with 0x1acd870 0x18e9b70 0
ok
tests.testDeclResolver.test_cycle_detection_in_class_hierarchy0__exception_wrapped ... ok
tests.testDeclResolver.test_cycle_detection_in_class_hierarchy1__exception_wrapped ... ok
tests.testDeclResolver.test_cycle_detection_in_class_hierarchy2__exception_wrapped ... ok
tests.testDeclResolver.test_inst_decl_parser ... ok
tests.testDeclResolver.test_function_resolution ... ok
tests.testDeclResolver.test_method_resolution ... ok
tests.testDeclResolver.test_method_resolution_in_template_class ... ok
tests.testDeclResolver.test_simple ... ok
tests.testDeclResolver.test_singular ... FAIL
tests.testDeclResolver.test_multi_inherit ... ok
tests.testDeclResolver.test_nested_templates ... ok
tests.testDeclResolver.test_non_template_class_with_annotation ... ok
tests.testDeclResolver.test_template_class_with_ptrtype ... ok
tests.testDeclResolver.test_multi_decls_in_one_file ... ok
tests.testDeclResolver.test_int_container ... ok
tests.testDeclResolver.test_typedef_with_fun ... ok
tests.testDeclResolver.test_typedef_chaining ... ok
tests.testDeclResolver.test_typedef_with_class ... ok
tests.testDeclResolver.test_typedef_with_class2 ... ok
tests.testDeclResolver.test_typedef_with_class3 ... ok
tests.testDeclResolver.test_without_header ... ok
tests.testDeclResolver.test_method_return_values ... ok
tests.testDeclResolver.test_class_and_enum ... ok
tests.testDeclResolver.test_copy_cons_decl_for_templated_class ... ok
tests.testMain.test_from_command_line ... ok
tests.testMain.test_run ... running build_ext
building 'out' extension
creating build
creating build/temp.linux-x86_64-3.3
gcc -pthread -Wno-unused-result -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -I/usr/include/boost -fPIC -I/home/sagitter/rpmbuild/BUILD/python3-autowrap-0.4.0-4.20140602gitebde9f.fc20/autowrap/data_files/boost -I/home/sagitter/rpmbuild/BUILD/python3-autowrap-0.4.0-4.20140602gitebde9f.fc20/autowrap/data_files -I/home/sagitter/rpmbuild/BUILD/python3-autowrap-0.4.0-4.20140602gitebde9f.fc20/tests/test_files/pxds -I/home/sagitter/rpmbuild/BUILD/python3-autowrap-0.4.0-4.20140602gitebde9f.fc20/tests/test_files/includes -I/usr/include/python3.3m -c out.cpp -o build/temp.linux-x86_64-3.3/out.o -Wno-unused-but-set-variable
g++ -pthread -shared -Wl,-z,relro -I/usr/include/boost build/temp.linux-x86_64-3.3/out.o -L/usr/lib64 -lpython3.3m -o /tmp/tmptgjd69/out.cpython-33m.so
ok
tests.testPXDParser.test_doubleptr__exception_wrapped ... ok
tests.testPXDParser.test_long ... ok
tests.testPXDParser.test_multiline_annotations ... ok
tests.testPXDParser.test_minimal ... ok
tests.testPXDParser.test_int_container_pxd_parsing ... ok
tests.testPXDParser.test_ref ... ok
tests.testPXDParser.test_ptr ... ok
tests.testPXDParser.test_enum ... ok
tests.testPXDParser.test_class_and_enum ... ok
tests.testPXDParser.test_multi_enum ... ok
tests.testPXDParser.test_multi_mixed ... ok
tests.testPXDParser.test_multi_classes_in_one_file ... ok
tests.testPXDParser.test_typedef ... ok
tests.testPXDParser.test_typedef2 ... ok
tests.testPXDParser.test_aliased_ptr ... ok
tests.testPXDParser.test_multi_alias ... ok
tests.testPXDParser.test_function ... ok
tests.testPXDParser.test_inner_unsigned ... ok
tests.testPXDParser.test_static ... ok
tests.testPXDParser.test_free_function ... ok
tests.testPXDParser.test_attributes ... ok
tests.testPXDParser.test_annotation_typical_error_detection ... ok
tests.testPXDParser.test_annotations ... ok
tests.testPXDParser.test_parsing_of_nested_template_args ... ok
tests.testTypes.testTypeParse ... ok
tests.testTypes.test_check_for_recursion ... ok
tests.testTypes.test_base_type_collecting ... ok
tests.testTypes.test_transform ... ok
tests.testTypes.test_inv_transform ... ok
tests.testUtils.test_hierarchy_detector0 ... ok
tests.testUtils.test_hierarchy_detector1 ... ok
tests.testUtils.test_hierarchy_detector2 ... ok
tests.testUtils.test_hierarchy_detector3 ... ok
tests.testUtils.test_nested_mapping_flattening ... ok

======================================================================
FAIL: tests.testDeclResolver.test_singular
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.3/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/home/sagitter/rpmbuild/BUILD/python3-autowrap-0.4.0-4.20140602gitebde9f.fc20/tests/testDeclResolver.py", line 162, in test_singular
    assert res0.name == "TemplatesInt", res0.name
nose.proxy.AssertionError: TemplatesMixed
-------------------- >> begin captured logging << --------------------
root: INFO: parse /home/sagitter/rpmbuild/BUILD/python3-autowrap-0.4.0-4.20140602gitebde9f.fc20/tests/test_files/templates.pxd
root: INFO: start resolving decls
root: INFO: resolve_inheritance for Templates
root: INFO: resolve class decl Templates
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: void Templates (['A a', 'B b'])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: A getA ([])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: B getB ([])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: A overloaded ([])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: B overloaded ([])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: void convert (['list[A] arg0', 'list[B] & arg1'])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: Templates[int,int] r0 (['Templates[int,float] '])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: Templates[int,float] r1 (['Templates[int,int] '])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: Templates[double,float] r2 ([])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: Templates[A,B] r3 (['A ', 'B '])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: void Templates (['A a', 'B b'])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: A getA ([])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: B getB ([])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: A overloaded ([])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: B overloaded ([])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: void convert (['list[A] arg0', 'list[B] & arg1'])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: Templates[int,int] r0 (['Templates[int,float] '])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: Templates[int,float] r1 (['Templates[int,int] '])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: Templates[double,float] r2 ([])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: Templates[A,B] r3 (['A ', 'B '])'
--------------------- >> end captured logging << ---------------------

----------------------------------------------------------------------
Ran 69 tests in 44.357s

FAILED (failures=1)

Conversion: lib_cpp[libcpp_utf8_string] and ["s1", "s2", ...]

Hi Uwe,
if we wrap a function:

void addTags(libcpp_utf8_string key, libcpp_vector[libcpp_utf8_string] tags) nogil except +
following works: p.addTags(k, [b"", b"c"])
but: p.addTags(k, ["", "c"]) fails
 File "/home/sachsenb/miniconda3/lib/python3.8/site-packages/nose/case.py", line 197, in runTest
   self.test(*self.arg)
 File "/home/sachsenb/OMS/OpenMS/openms-build/pyOpenMS/tests/unittests/test000.py", line 32, in wrapper
   f(*a, **kw)
 File "/home/sachsenb/OMS/OpenMS/openms-build/pyOpenMS/tests/unittests/test000.py", line 1556, in testCompNovoIdentification
   _testParam(p)
 File "/home/sachsenb/OMS/OpenMS/openms-build/pyOpenMS/tests/unittests/test000.py", line 32, in wrapper
   f(*a, **kw)
 File "/home/sachsenb/OMS/OpenMS/openms-build/pyOpenMS/tests/unittests/test000.py", line 1429, in _testParam
   p.addTags(k, ["", "c"])
 File "pyopenms/pyopenms_3.pyx", line 6188, in pyopenms.pyopenms_3.Param.addTags
 File "stringsource", line 48, in vector.from_py.__pyx_convert_vector_from_py_std_3a__3a_string
 File "stringsource", line 15, in string.from_py.__pyx_convert_string_from_py_std__in_string
TypeError: expected bytes, str found

with an internal cython error.
Any hints what needs to be done here?
Best,
the OpenMS guys

Problems with included boost files

Autowrap includes its own set of boost files in autowrap/autowrap/data_files/boost. This leads to problems if other boost libraries are present on the system

I opt to remove those boost files or at least put them in a separate repository. Currently we have an issue at OpenMS that we can only compile pyOpenMS if we first remove those files OpenMS/OpenMS#1207

wrap-instances ignores "sub-type" of templated class

      # wrap-instances:
      #  ScoreTypeRef := IteratorWrapper[ libcpp_set[ ScoreType ].clearly_bullshit ]```
generated CPP code with ScoreTypeRef defined as:
```OpenMS::IdentificationDataInternal::IteratorWrapper<std::set<OpenMS::IdentificationDataInternal::ScoreType> > ``` dropping the `clearly_bullshit` suffix.

Compilation Error Example: "Previous declaration is here"

The compilation of the int_holder fails with the error "Previous declaration is here". I checked already Issue 34, but that seems unrelated. I've installed latest Cython Version Cython-0.29.10 with Python 3.6.8

(base) paul@paul-XPS-15-9560:~/PycharmProjects/doxa_cython$ autowrap --out doxa/int_holder.pyx doxa/int_holder.pxd


STATUS:
       1 pxd input files to parse
       0 add on files to process
       0 type converter files to consider


Level 25:root:parsing progress 0 out of 1
/home/paul/.local/lib/python3.6/site-packages/Cython/Compiler/Main.py:367: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: /home/paul/PycharmProjects/doxa_cython/doxa/int_holder.pxd
  tree = Parsing.p_module(s, pxd, full_module_name)
INFO:root:start resolving decls
INFO:root:resolve_inheritance for IntHolder
INFO:root:resolve class decl IntHolder
INFO:root:resolve method decl: 'CppMethodOrFunctionDecl: void IntHolder (['int i'])'
INFO:root:resolve method decl: 'CppMethodOrFunctionDecl: void IntHolder (['IntHolder & i'])'
INFO:root:resolve method decl: 'CppMethodOrFunctionDecl: int add (['IntHolder o'])'
INFO:root:register <autowrap.ConversionProvider.IntegerConverter object at 0x7f879aaf1d30>
INFO:root:register <autowrap.ConversionProvider.FloatConverter object at 0x7f879ae9c550>
INFO:root:register <autowrap.ConversionProvider.DoubleConverter object at 0x7f879ae9c588>
INFO:root:register <autowrap.ConversionProvider.ConstCharPtrConverter object at 0x7f879ae9c668>
INFO:root:register <autowrap.ConversionProvider.CharPtrConverter object at 0x7f879aaff320>
INFO:root:register <autowrap.ConversionProvider.CharConverter object at 0x7f879aaffef0>
INFO:root:register <autowrap.ConversionProvider.StdStringConverter object at 0x7f879ab07630>
INFO:root:register <autowrap.ConversionProvider.StdStringUnicodeConverter object at 0x7f879ab166d8>
INFO:root:register <autowrap.ConversionProvider.StdStringUnicodeOutputConverter object at 0x7f879ab16710>
INFO:root:register <autowrap.ConversionProvider.StdVectorConverter object at 0x7f879ab16748>
INFO:root:register <autowrap.ConversionProvider.StdSetConverter object at 0x7f879ab16780>
INFO:root:register <autowrap.ConversionProvider.StdMapConverter object at 0x7f879ab167b8>
INFO:root:register <autowrap.ConversionProvider.StdPairConverter object at 0x7f879ab167f0>
INFO:root:register <autowrap.ConversionProvider.VoidConverter object at 0x7f879ab16828>
INFO:root:register <autowrap.ConversionProvider.SharedPtrConverter object at 0x7f879ab16860>
INFO:root:register <autowrap.ConversionProvider.TypeToWrapConverter object at 0x7f879ab168d0>
INFO:root:Create foreign imports for module /home/paul/PycharmProjects/doxa_cython/doxa/int_holder.pyx
INFO:root:create wrapper for class IntHolder
INFO:root:   create wrapper __copy__
INFO:root:   create wrapper for non overloaded constructor _init_0
INFO:root:   create wrapper for non overloaded constructor _init_1
INFO:root:   create wrapper decl for overloaded method __init__
INFO:root:   create wrapper for add ('int add(IntHolder o)')
Autwrap has wrapped 1 classes, 2 methods and 0 enums

Error compiling Cython file:
------------------------------------------------------------
...
from int_holder cimport IntHolder as _IntHolder

cdef extern from "autowrap_tools.hpp":
    char * _cast_const_away(char *) 

cdef class IntHolder:
    ^
------------------------------------------------------------

doxa/int_holder.pyx:22:5: 'IntHolder' redeclared 

Error compiling Cython file:
------------------------------------------------------------
...
cdef extern from "int_holder.hpp":
    cdef cppclass IntHolder:
        ^
------------------------------------------------------------

doxa/int_holder.pxd:2:9: Previous declaration is here

special method __getitem__

I see that there is a special __getitem__ method called create_special_getitem_method but I think there is an a slight logical problem here. In our case in OpenMS it generates code such as

    def __getitem__(self,  index ):
        assert isinstance(index, (int, long)), 'arg index wrong type'

        if (<size_t>index) < 0:
            raise IndexError("invalid index %d" % (<size_t>index))
        if (<size_t>index) >= self.inst.get().size():
            raise IndexError("invalid index %d" % (<size_t>index))
        cdef _DataFilter * _r = new _DataFilter(deref(self.inst.get())[(<size_t>index)])

which does not make a lot of sense here to compare a <size_t>index < 0 . The code is generated by a file called src/pyOpenMS/pxds/DataFilters.pxd which looks like this

 cdef extern from "<OpenMS/FILTERING/DATAREDUCTION/DataFilters.h>" namespace "OpenMS":

     cdef cppclass DataFilters "OpenMS::DataFilters":
         DataFilters() nogil except +
         DataFilters(DataFilters) nogil except + #wrap-ignore
         DataFilter operator[](Size index) nogil except + # wrap-upper-limit:size()

other classes that use int instead of Size do not have this issue.

In conclusion, I dont think it is a big problem but might be worthwhile to consider in the future

version.py breaks autowrap

Since 2aba9b3 my autowrap is broken with the following error:

python -c "import autowrap"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/IMSB/users/hroest/lib/autowrap/autowrap/__init__.py", line 36, in <module>
    from .version import *
  File "/IMSB/users/hroest/lib/autowrap/autowrap/version.py", line 34, in <module>
    __version__ = tuple(map(int, pkg_resources.require(__package__)[0].version.split(".")))
  File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 648, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 546, in resolve
    raise DistributionNotFound(req)

Not sure why that is, this is Python 2.6 on a RHEL server which would be nice to support. Could we either fix this or revert 2aba9b3 ?

Create release GH action

Best with a GH Actions job that checks agreement of all occurrences of the version, tags/branches and uploads to pip.

[autowrap 0.6.1] multiple types of annotations for a class not supported

Tested with commit d0e9a5 (Feb 9, 2015).
Tested by using both "wrap-inherits" and "wrap-instances" annotations together:
Only the first declared annotation is executed.

Test code:

cdef extern from "<gtsam/geometry/Pose2.h>" namespace "gtsam":
    cdef cppclass Pose2:
        Pose2()

cdef extern from "<gtsam/nonlinear/NonlinearFactor.h>" namespace "gtsam":
    cdef cppclass NoiseModelFactor1[VALUE]:
        void print_ "print"()

cdef extern from "<gtsam/slam/PriorFactor.h>" namespace "gtsam":
    cdef cppclass PriorFactor[VALUE](NoiseModelFactor1[VALUE]):
        # wrap-inherits:
        #   NoiseModelFactor1[VALUE]
        # wrap-instances:
        #   PriorFactor_Pose2 := PriorFactor[Pose2]
        PriorFactor()

In this case, the following error is returned:

Traceback (most recent call last):
File "./setup.py", line 41, in <module>
    main()
File "./setup.py", line 30, in main
    autowrap_main(args)
File "/usr/lib/python2.7/site-packages/autowrap/Main.py", line 121, in _main
    run(pxds, addons, converters, out)
File "/usr/lib/python2.7/site-packages/autowrap/Main.py", line 202, in run
    extra_opts)
File "/usr/lib/python2.7/site-packages/autowrap/Main.py", line 190, in create_wrapper_code
    inc_dirs = autowrap.generate_code(decls, instance_map, out, False, manual_code, cimports)
File "/usr/lib/python2.7/site-packages/autowrap/__init__.py", line 63, in generate_code
    gen.create_pyx_file(debug)
File "/usr/lib/python2.7/site-packages/autowrap/CodeGenerator.py", line 165, in create_pyx_file
    create_for(ResolvedClass, self.create_wrapper_for_class)
File "/usr/lib/python2.7/site-packages/autowrap/CodeGenerator.py", line 161, in create_for
    method(resolved)
File "/usr/lib/python2.7/site-packages/autowrap/CodeGenerator.py", line 294, in create_wrapper_for_class
    codes = self.create_wrapper_for_method(r_class, name, methods)
File "/usr/lib/python2.7/site-packages/autowrap/CodeGenerator.py", line 420, in create_wrapper_for_method
    method,
File "/usr/lib/python2.7/site-packages/autowrap/CodeGenerator.py", line 548, in create_wrapper_for_nonoverloaded_method
    method)
File "/usr/lib/python2.7/site-packages/autowrap/CodeGenerator.py", line 448, in _create_fun_decl_and_input_conversion
    converter = self.cr.get(t)
File "/usr/lib/python2.7/site-packages/autowrap/ConversionProvider.py", line 117, in get
    raise Exception("no converter for %s" % cpp_type)
Exception: no converter for shared_ptr[PriorFactor[Pose2]] &

If I would swap the annotations, such that the last method is defined as:

cdef extern from "<gtsam/slam/PriorFactor.h>" namespace "gtsam":
    cdef cppclass PriorFactor[VALUE](NoiseModelFactor1[VALUE]):
        # wrap-instances:
        #   PriorFactor_Pose2 := PriorFactor[Pose2]
        # wrap-inherits:
        #   NoiseModelFactor1[VALUE]
        PriorFactor()

then the wrapping will give no errors, but the "print_()" method will not be inherited.

[0.7.1] GIL test failed with Python3.5

Hi all,

GIL test is not compiled with Python3.5:

gcc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=hard -D_GNU_SOURCE -fPIC -fwrapv -I/usr/include/boost -fPIC -I/builddir/build/BUILD/python3-autowrap-0.7.0-1.20151124gitd5e233.fc24/autowrap/data_files/boost -I/builddir/build/BUILD/python3-autowrap-0.7.0-1.20151124gitd5e233.fc24/autowrap/data_files -I/builddir/build/BUILD/python3-autowrap-0.7.0-1.20151124gitd5e233.fc24/tests/test_files -I/usr/include/python3.5m -c gil_testing_wrapper.cpp -o build/temp.linux-armv7l-3.5/gil_testing_wrapper.o -Wno-unused-but-set-variable
In file included from gil_testing_wrapper.cpp:260:0:
/builddir/build/BUILD/python3-autowrap-0.7.0-1.20151124gitd5e233.fc24/tests/test_files/gil_testing.hpp: In member function 'void GilTesting::do_something(const char*)':
/builddir/build/BUILD/python3-autowrap-0.7.0-1.20151124gitd5e233.fc24/tests/test_files/gil_testing.hpp:14:75: error: '_PyThreadState_Current' was not declared in this scope
         PyThreadState * tstate = (PyThreadState*)_Py_atomic_load_relaxed(&_PyThreadState_Current);
                                                                           ^
/builddir/build/BUILD/python3-autowrap-0.7.0-1.20151124gitd5e233.fc24/tests/test_files/gil_testing.hpp:14:97: error: '_Py_atomic_load_relaxed' was not declared in this scope
         PyThreadState * tstate = (PyThreadState*)_Py_atomic_load_relaxed(&_PyThreadState_Current);
                                                                                                 ^
error: command 'gcc' failed with exit status 1
FAIL

Full log: https://kojipkgs.fedoraproject.org//work/tasks/3203/11993203/build.log

Tag releases

could you push a git tag for the 0.5.0 release:

git tag 0.5.0 1753b9bf044559e18ca1ed39914405a2f8b4fca3 && git push --tags

that would be useful to have a stable .tar.gz to download and use for the release. Thanks

test_main.test failed

Hi all.
tests.test_main.test_from_command_line tests.test_main.test_run are failed with following output:

======================================================================
ERROR: tests.test_main.test_from_command_line
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/builddir/build/BUILD/autowrap-0.8.0/python2/tests/test_main.py", line 64, in test_from_command_line
    _main(args)
  File "/builddir/build/BUILD/autowrap-0.8.0/python2/autowrap/Main.py", line 121, in _main
    run(pxds, addons, converters, out)
  File "/builddir/build/BUILD/autowrap-0.8.0/python2/autowrap/Main.py", line 202, in run
    extra_opts)
  File "/builddir/build/BUILD/autowrap-0.8.0/python2/autowrap/Main.py", line 195, in create_wrapper_code
    run_cython(inc_dirs, extra_opts, out)
  File "/builddir/build/BUILD/autowrap-0.8.0/python2/autowrap/Main.py", line 175, in run_cython
    from Cython.Compiler.Options import directive_defaults
ImportError: cannot import name directive_defaults
-------------------- >> begin captured stdout << ---------------------
WARNING!  '/addons' did not match any file
STATUS:
       1 pxd input files to parse
       0 add on files to process
       1 type converter files to consider
Autwrap has wrapped 6 classes, 20 methods and 0 enums
--------------------- >> end captured stdout << ----------------------
-------------------- >> begin captured logging << --------------------
root: INFO: parse ./pxds/test.pxd
root: INFO: start resolving decls
root: INFO: resolve_inheritance for Holder
root: INFO: resolve_inheritance for Outer
root: INFO: resolve_inheritance for SharedPtrTest
root: INFO: resolve class decl Holder
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: void Holder ([])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: void Holder ([u'U '])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: void Holder ([u'Holder[U] '])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: U get ([])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: void set ([u'U '])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: void Holder ([])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: void Holder ([u'U '])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: void Holder ([u'Holder[U] '])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: U get ([])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: void set ([u'U '])'
root: INFO: resolve class decl Outer
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: void Outer ([])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: void Outer ([u'Outer[U] '])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: Holder[U] get ([])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: void set ([u'Holder[U] a'])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: iterator begin ([])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: iterator end ([])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: void Outer ([])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: void Outer ([u'Outer[U] '])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: Holder[U] get ([])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: void set ([u'Holder[U] a'])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: iterator begin ([])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: iterator end ([])'
root: INFO: resolve class decl SharedPtrTest
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: U sum_values ([u'shared_ptr[Holder[U]] a1', u'shared_ptr[Holder[U]] a2'])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: void set_inner_value ([u'shared_ptr[Holder[U]] & h', u'U value'])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: U sum_values ([u'shared_ptr[Holder[U]] a1', u'shared_ptr[Holder[U]] a2'])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: void set_inner_value ([u'shared_ptr[Holder[U]] & h', u'U value'])'
root: INFO: register <autowrap.ConversionProvider.IntegerConverter object at 0x3ff7cac0150>
root: INFO: register <autowrap.ConversionProvider.FloatConverter object at 0x3ff7cac0850>
root: INFO: register <autowrap.ConversionProvider.DoubleConverter object at 0x3ff7cac0790>
root: INFO: register <autowrap.ConversionProvider.ConstCharPtrConverter object at 0x3ff7cb05c50>
root: INFO: register <autowrap.ConversionProvider.CharPtrConverter object at 0x3ff7ca9a0d0>
root: INFO: register <autowrap.ConversionProvider.CharConverter object at 0x3ff7ca9a550>
root: INFO: register <autowrap.ConversionProvider.StdStringConverter object at 0x3ff7ac4ce90>
root: INFO: register <autowrap.ConversionProvider.StdStringUnicodeConverter object at 0x3ff7ac4ced0>
root: INFO: register <autowrap.ConversionProvider.StdVectorConverter object at 0x3ff7ac4cf10>
root: INFO: register <autowrap.ConversionProvider.StdSetConverter object at 0x3ff7ac4cf50>
root: INFO: register <autowrap.ConversionProvider.StdMapConverter object at 0x3ff7ac4cf90>
root: INFO: register <autowrap.ConversionProvider.StdPairConverter object at 0x3ff7ac4cfd0>
root: INFO: register <autowrap.ConversionProvider.VoidConverter object at 0x3ff7ac73050>
root: INFO: register <autowrap.ConversionProvider.SharedPtrConverter object at 0x3ff7ac73090>
root: INFO: register <autowrap.ConversionProvider.TypeToWrapConverter object at 0x3ff7ac73110>
root: INFO: register <autowrap.ConversionProvider.TypeToWrapConverter object at 0x3ff7ac73150>
root: INFO: register <autowrap.ConversionProvider.TypeToWrapConverter object at 0x3ff7ac73190>
root: INFO: register <autowrap.ConversionProvider.TypeToWrapConverter object at 0x3ff7ac731d0>
root: INFO: register <autowrap.ConversionProvider.TypeToWrapConverter object at 0x3ff7ac73210>
root: INFO: register <autowrap.ConversionProvider.TypeToWrapConverter object at 0x3ff7ac73250>
root: INFO: register <tests.test_code_generator.SpecialIntConverter object at 0x3ff7ca77c90>
root: INFO: register <converters.IntHolderConverter.IntHolderConverter object at 0x3ff7b46c550>
root: INFO: create wrapper for class B
root: INFO:    create wrapper for non overloaded constructor _init_0
root: INFO:    create wrapper for non overloaded constructor _init_1
root: INFO:    create wrapper decl for overloaded method __init__
root: INFO:    create wrapper for set_ ('void set_(IntHolder a)')
root: INFO:    create wrapper for get ('IntHolder get()')
root: INFO:    create wrapper for iter __iter__
root: INFO: create wrapper for class C
root: INFO:    create wrapper for non overloaded constructor _init_0
root: INFO:    create wrapper for non overloaded constructor _init_1
root: INFO:    create wrapper decl for overloaded method __init__
root: INFO:    create wrapper for set_ ('void set_(FloatHolder a)')
root: INFO:    create wrapper for get ('FloatHolder get()')
root: INFO:    create wrapper for iter __iter__
root: INFO: create wrapper for class FloatHolder
root: INFO:    create wrapper for non overloaded constructor _init_0
root: INFO:    create wrapper for non overloaded constructor _init_1
root: INFO:    create wrapper for non overloaded constructor _init_2
root: INFO:    create wrapper decl for overloaded method __init__
root: INFO:    create wrapper for set_ ('void set_(float)')
root: INFO:    create wrapper for get ('float get()')
root: INFO: create wrapper for class IntHolder
root: INFO:    create wrapper for non overloaded constructor _init_0
root: INFO:    create wrapper for non overloaded constructor _init_1
root: INFO:    create wrapper for non overloaded constructor _init_2
root: INFO:    create wrapper decl for overloaded method __init__
root: INFO:    create wrapper for set_ ('void set_(int)')
root: INFO:    create wrapper for get ('int get()')
root: INFO: create wrapper for class SharedPtrTestFloat
root: INFO:    create wrapper for set_inner_value ('void set_inner_value(shared_ptr[FloatHolder] & h, float value)')
root: INFO:    create wrapper for sum_values ('float sum_values(shared_ptr[FloatHolder] a1, shared_ptr[FloatHolder] a2)')
root: INFO: create wrapper for class SharedPtrTestInt
root: INFO:    create wrapper for set_inner_value ('void set_inner_value(shared_ptr[IntHolder] & h, int value)')
root: INFO:    create wrapper for sum_values ('int sum_values(shared_ptr[IntHolder] a1, shared_ptr[IntHolder] a2)')
--------------------- >> end captured logging << ---------------------
======================================================================
ERROR: tests.test_main.test_run
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/builddir/build/BUILD/autowrap-0.8.0/python2/tests/test_main.py", line 89, in test_run
    extra_includes)
  File "/builddir/build/BUILD/autowrap-0.8.0/python2/autowrap/Main.py", line 202, in run
    extra_opts)
  File "/builddir/build/BUILD/autowrap-0.8.0/python2/autowrap/Main.py", line 195, in create_wrapper_code
    run_cython(inc_dirs, extra_opts, out)
  File "/builddir/build/BUILD/autowrap-0.8.0/python2/autowrap/Main.py", line 175, in run_cython
    from Cython.Compiler.Options import directive_defaults
ImportError: cannot import name directive_defaults
-------------------- >> begin captured stdout << ---------------------
Autwrap has wrapped 6 classes, 20 methods and 0 enums
--------------------- >> end captured stdout << ----------------------
-------------------- >> begin captured logging << --------------------
root: INFO: parse /builddir/build/BUILD/autowrap-0.8.0/python2/tests/test_files/pxds/test.pxd
root: INFO: start resolving decls
root: INFO: resolve_inheritance for Holder
root: INFO: resolve_inheritance for Outer
root: INFO: resolve_inheritance for SharedPtrTest
root: INFO: resolve class decl Holder
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: void Holder ([])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: void Holder ([u'U '])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: void Holder ([u'Holder[U] '])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: U get ([])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: void set ([u'U '])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: void Holder ([])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: void Holder ([u'U '])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: void Holder ([u'Holder[U] '])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: U get ([])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: void set ([u'U '])'
root: INFO: resolve class decl Outer
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: void Outer ([])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: void Outer ([u'Outer[U] '])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: Holder[U] get ([])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: void set ([u'Holder[U] a'])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: iterator begin ([])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: iterator end ([])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: void Outer ([])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: void Outer ([u'Outer[U] '])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: Holder[U] get ([])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: void set ([u'Holder[U] a'])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: iterator begin ([])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: iterator end ([])'
root: INFO: resolve class decl SharedPtrTest
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: U sum_values ([u'shared_ptr[Holder[U]] a1', u'shared_ptr[Holder[U]] a2'])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: void set_inner_value ([u'shared_ptr[Holder[U]] & h', u'U value'])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: U sum_values ([u'shared_ptr[Holder[U]] a1', u'shared_ptr[Holder[U]] a2'])'
root: INFO: resolve method decl: 'CppMethodOrFunctionDecl: void set_inner_value ([u'shared_ptr[Holder[U]] & h', u'U value'])'
root: INFO: register <autowrap.ConversionProvider.IntegerConverter object at 0x3ff7ac7ca50>
root: INFO: register <autowrap.ConversionProvider.FloatConverter object at 0x3ff7ac13690>
root: INFO: register <autowrap.ConversionProvider.DoubleConverter object at 0x3ff7ac13650>
root: INFO: register <autowrap.ConversionProvider.ConstCharPtrConverter object at 0x3ff7ac13950>
root: INFO: register <autowrap.ConversionProvider.CharPtrConverter object at 0x3ff7abdfc10>
root: INFO: register <autowrap.ConversionProvider.CharConverter object at 0x3ff7abdfc90>
root: INFO: register <autowrap.ConversionProvider.StdStringConverter object at 0x3ff7abdfcd0>
root: INFO: register <autowrap.ConversionProvider.StdStringUnicodeConverter object at 0x3ff7abdfd10>
root: INFO: register <autowrap.ConversionProvider.StdVectorConverter object at 0x3ff7abdfd50>
root: INFO: register <autowrap.ConversionProvider.StdSetConverter object at 0x3ff7abdfd90>
root: INFO: register <autowrap.ConversionProvider.StdMapConverter object at 0x3ff7abdfdd0>
root: INFO: register <autowrap.ConversionProvider.StdPairConverter object at 0x3ff7abdfe10>
root: INFO: register <autowrap.ConversionProvider.VoidConverter object at 0x3ff7abdfe50>
root: INFO: register <autowrap.ConversionProvider.SharedPtrConverter object at 0x3ff7abdfe90>
root: INFO: register <autowrap.ConversionProvider.TypeToWrapConverter object at 0x3ff7abdff10>
root: INFO: register <autowrap.ConversionProvider.TypeToWrapConverter object at 0x3ff7abdff50>
root: INFO: register <autowrap.ConversionProvider.TypeToWrapConverter object at 0x3ff7abdff90>
root: INFO: register <autowrap.ConversionProvider.TypeToWrapConverter object at 0x3ff7abdffd0>
root: INFO: register <autowrap.ConversionProvider.TypeToWrapConverter object at 0x3ff7ab41050>
root: INFO: register <autowrap.ConversionProvider.TypeToWrapConverter object at 0x3ff7ab41090>
root: INFO: register <tests.test_code_generator.SpecialIntConverter object at 0x3ff7ca77c90>
root: INFO: register <converters.IntHolderConverter.IntHolderConverter object at 0x3ff7b46c550>
root: INFO: register <converters.IntHolderConverter.IntHolderConverter object at 0x3ff7ac13090>
root: INFO: create wrapper for class B
root: INFO:    create wrapper for non overloaded constructor _init_0
root: INFO:    create wrapper for non overloaded constructor _init_1
root: INFO:    create wrapper decl for overloaded method __init__
root: INFO:    create wrapper for set_ ('void set_(IntHolder a)')
root: INFO:    create wrapper for get ('IntHolder get()')
root: INFO:    create wrapper for iter __iter__
root: INFO: create wrapper for class C
root: INFO:    create wrapper for non overloaded constructor _init_0
root: INFO:    create wrapper for non overloaded constructor _init_1
root: INFO:    create wrapper decl for overloaded method __init__
root: INFO:    create wrapper for set_ ('void set_(FloatHolder a)')
root: INFO:    create wrapper for get ('FloatHolder get()')
root: INFO:    create wrapper for iter __iter__
root: INFO: create wrapper for class FloatHolder
root: INFO:    create wrapper for non overloaded constructor _init_0
root: INFO:    create wrapper for non overloaded constructor _init_1
root: INFO:    create wrapper for non overloaded constructor _init_2
root: INFO:    create wrapper decl for overloaded method __init__
root: INFO:    create wrapper for set_ ('void set_(float)')
root: INFO:    create wrapper for get ('float get()')
root: INFO: create wrapper for class IntHolder
root: INFO:    create wrapper for non overloaded constructor _init_0
root: INFO:    create wrapper for non overloaded constructor _init_1
root: INFO:    create wrapper for non overloaded constructor _init_2
root: INFO:    create wrapper decl for overloaded method __init__
root: INFO:    create wrapper for set_ ('void set_(int)')
root: INFO:    create wrapper for get ('int get()')
root: INFO: create wrapper for class SharedPtrTestFloat
root: INFO:    create wrapper for set_inner_value ('void set_inner_value(shared_ptr[FloatHolder] & h, float value)')
root: INFO:    create wrapper for sum_values ('float sum_values(shared_ptr[FloatHolder] a1, shared_ptr[FloatHolder] a2)')
root: INFO: create wrapper for class SharedPtrTestInt
root: INFO:    create wrapper for set_inner_value ('void set_inner_value(shared_ptr[IntHolder] & h, int value)')
root: INFO:    create wrapper for sum_values ('int sum_values(shared_ptr[IntHolder] a1, shared_ptr[IntHolder] a2)')
--------------------- >> end captured logging << ---------------------
----------------------------------------------------------------------
Ran 73 tests in 110.603s
FAILED (errors=2)

Fedora 26 (development branch)
Python 2.7
autowrap 3f48085
Full build log: https://paste.fedoraproject.org/511830/

Porting to python 3?

It sems that the library does not currently work under python3. Are there any plans to port it? Cython already works under python 3 so there should be no major obstacles.

Seg Fault in certain processes of libcpp_test binding.

I generated extension module for libcpp_test.hpp script. While testing process211 as shown below, segmentation fault occurs. Similar situation also for process212 & process214.

sf

Although, I understand that this error occurs as the function expects a dict with (b'42':non-empty list}) as atleast one key-value pair.

 void  process211(std::map<int, float> & in, std::map<std::string, std::vector<int> > & arg2)
 {
     std::string test_str("42");
    in[1] = (float) arg2[test_str][0];
 }

Can cython gracefully handle the seg fault error ?

ImportError (cannot import name Pipeline) (d0e9a5a)

Hi all.

Tests fail with Cython-0.14.1 (do not fail with Cython-0.19); incompatibilities?

Failure: ImportError (cannot import name Pipeline) ... ERROR
tests.test_cython_build_process.testBuildExt ... running build_ext
cythoning itertest.pyx to itertest.cpp
Error compiling Cython file:
------------------------------------------------------------
...
    def __iter__(self):
        assert self.inst != NULL
        it = self.inst.begin()
        while it != self.inst.end():
            yield <int> deref(it)
           ^
------------------------------------------------------------
itertest.pyx:29:12: Generators are not supported
Error compiling Cython file:
------------------------------------------------------------
...
        result.add(i)
    return result
cdef inline conv1(cpplist[int] & ii):
    return [ <int>i for i in ii ]
                               ^
------------------------------------------------------------
itertest.pyx:41:32: Cannot convert 'list<int> &' to Python object
Error compiling Cython file:
------------------------------------------------------------
...
cdef inline conv2(list ii):
    cdef cpplist[int] rv
    for i in ii:
        rv.push_back(<int> i)
    return rv
            ^
------------------------------------------------------------
itertest.pyx:47:13: Cannot convert 'list<int>' to Python object
Error compiling Cython file:
------------------------------------------------------------
...
    for i in ii:
        rv.push_back(<int> i)
    return rv
def run(list x):
    cdef cpplist[int] xv = conv2(x)
                               ^
------------------------------------------------------------
itertest.pyx:50:32: Cannot convert Python object to 'list<int>'

Full log: https://kojipkgs.fedoraproject.org//work/tasks/4606/9224606/build.log
autowrap checkout: d0e9a5a

Offical Python API

In our project we use autowrap not from clias docs suggest, but from setup.py. Please see code snippet below:

    addons = glob.glob('src/addons/*')
    pxds = glob.glob('src/pxds/*')
    converters = 'src/converters'
    converter_files = glob.glob(path.join(converters, '*'))
    max_modification_time = max([path.getmtime(fn) for fn in addons + pxds + converter_files])

    if not path.exists(pykeyvi_cpp) or max_modification_time > path.getmtime(pykeyvi_cpp):
        import autowrap.Main
        autowrap.Main.run(pxds, addons, [converters], pykeyvi_pyx)

So can you please comment weather the autowrap.Main.run() can be threat as a supported API ?

[autowrap 0.6.1] instanced templated typedefs and "wrap-instance"-ed types can have name collisions

Tested with commit d0e9a5 (Feb 9, 2015).
In some cases, a C++ header may define a typedef to a specific instantiation of a templated class, but it seems to be impossible to both create the typedef in the ".pxd"-file, and wrap that instantiation to Python (with the same name).

Test code (replaced variable names):

cdef extern from "eggs.hpp" namespace "bar":
    cdef cppclass Eggs:
        Eggs()

cdef extern from "foo.hpp" namespace "bar":
    cdef cppclass Foo[Spam]:
        # wrap-instances:
        #   Foo_Eggs := Foo[Eggs]
        Foo()
    ctypedef Foo[Eggs] Foo_Eggs

After autowrap has created the ".pyx"-file without warnings, but Cython fails to compile it:

Error compiling Cython file:
------------------------------------------------------------
...

cdef class Foo_Eggs:
    ^
------------------------------------------------------------

bar_ext.pyx:1178:5: 'Foo_Eggs' redeclared

Some extra name mangling in autowrap is needed to make it work,
since Cython doesn't complain when the typedef is altered to, e.g.:

ctypedef Foo[Eggs] Foo_Eggs_

or:

ctypedef Foo[Eggs] Foo_Eggs_ "Foo_Eggs"

[FEATURE] Improve handling of std conversions

  1. Add recursion to all std conversion providers:

    • currently only done for vector
    • should be doable for most types
    • refactor into more fine-grained code generation functions that are called based on the next level of recursion.
  2. add support for std::tuple (see pair) and std::unordered_map (see map)

  3. allow multiple overloads per std container

    • one for conversion from-to python type
    • one for conversion into a wrapping python object (for passing between wrapped functions without conversion to python)
    • one for special (numpy) types (e.g. memoryviews for std::vector)
    • we could maybe also add a wrap-XYZ statement to a function on which ones to use

std::move in autowrap

Cython has std::move support since version 0.29.17 (cython/cython#3358).

I was trying to wrap a new function from the SiriusAdapterAlgorithm (OpenMS) via autowrap which looks like this:

...
from libcpp.utility cimport move
...
libcpp_vector[String] sortSiriusWorkspacePathsByScanIndex(libcpp_vector[String]&& subdirs) nogil except +

Building pyopenms fails with the following traceback:

Traceback (most recent call last):
  File "create_cpp_extension.py", line 63, in <module>
    decls, instance_map = autowrap.parse(pxd_files, ".", num_processes=int(PY_NUM_THREADS))
  File "/usr/local/miniconda3/envs/build_pyopenms_38/lib/python3.8/site-packages/autowrap/__init__.py", line 51, in parse
    return DeclResolver.resolve_decls_from_files(files, root, num_processes)
  File "/usr/local/miniconda3/envs/build_pyopenms_38/lib/python3.8/site-packages/autowrap/DeclResolver.py", line 239, in resolve_decls_from_files
    return resolve_decls_from_files_single_thread(pathes, root)
  File "/usr/local/miniconda3/envs/build_pyopenms_38/lib/python3.8/site-packages/autowrap/DeclResolver.py", line 232, in resolve_decls_from_files_single_thread
    decls.extend(PXDParser.parse_pxd_file(full_path))
  File "/usr/local/miniconda3/envs/build_pyopenms_38/lib/python3.8/site-packages/autowrap/PXDParser.py", line 487, in parse_pxd_file
    result.append(handler(body, lines, path))
  File "/usr/local/miniconda3/envs/build_pyopenms_38/lib/python3.8/site-packages/autowrap/PXDParser.py", line 288, in parseTree
    decl = MethodOrAttributeDecl.parseTree(att, lines, pxd_path)
  File "/usr/local/miniconda3/envs/build_pyopenms_38/lib/python3.8/site-packages/autowrap/PXDParser.py", line 390, in parseTree
    argname = argdecl.base.name
AttributeError: 'CReferenceDeclaratorNode' object has no attribute 'name'
make[3]: *** [src/pyOpenMS/CMakeFiles/pyopenms_create_cpp] Error 1
make[2]: *** [src/pyOpenMS/CMakeFiles/pyopenms_create_cpp.dir/all] Error 2
make[1]: *** [src/pyOpenMS/CMakeFiles/pyopenms.dir/rule] Error 2
make: *** [pyopenms] Error 2

Is this functionality currently available in autowrap and/or does someone has experience with it?

Exception: no converter string

I'm trying to wrap a c++ code containing some std::string. After creating a .pxd file, and running autowrap, I get the error here-below. Would you have any hints on how to solve it? I included "from libcpp.string cimport string" at the top of my pxd file.

Traceback (most recent call last):
File "/home/ftpronk/local/bin/autowrap", line 9, in
load_entry_point('autowrap==0.5.1', 'console_scripts', 'autowrap')()
File "/home/ftpronk/local/lib/python2.7/site-packages/autowrap-0.5.1-py2.7.egg/autowrap/Main.py", line 67, in main
_main(sys.argv[1:])
File "/home/ftpronk/local/lib/python2.7/site-packages/autowrap-0.5.1-py2.7.egg/autowrap/Main.py", line 121, in _main
run(pxds, addons, converters, out)
File "/home/ftpronk/local/lib/python2.7/site-packages/autowrap-0.5.1-py2.7.egg/autowrap/Main.py", line 202, in run
extra_opts)
File "/home/ftpronk/local/lib/python2.7/site-packages/autowrap-0.5.1-py2.7.egg/autowrap/Main.py", line 190, in create_wrapper_code
inc_dirs = autowrap.generate_code(decls, instance_map, out, False, manual_code, cimports)
File "/home/ftpronk/local/lib/python2.7/site-packages/autowrap-0.5.1-py2.7.egg/autowrap/init.py", line 63, in generate_code
gen.create_pyx_file(debug)
File "/home/ftpronk/local/lib/python2.7/site-packages/autowrap-0.5.1-py2.7.egg/autowrap/CodeGenerator.py", line 171, in create_pyx_file
create_for(ResolvedClass, self.create_wrapper_for_class)
File "/home/ftpronk/local/lib/python2.7/site-packages/autowrap-0.5.1-py2.7.egg/autowrap/CodeGenerator.py", line 167, in create_for
method(resolved)
File "/home/ftpronk/local/lib/python2.7/site-packages/autowrap-0.5.1-py2.7.egg/autowrap/CodeGenerator.py", line 300, in create_wrapper_for_class
codes = self.create_wrapper_for_method(r_class, name, methods)
File "/home/ftpronk/local/lib/python2.7/site-packages/autowrap-0.5.1-py2.7.egg/autowrap/CodeGenerator.py", line 412, in create_wrapper_for_method
code = self.create_wrapper_for_nonoverloaded_method(cdcl, py_name, methods[0])
File "/home/ftpronk/local/lib/python2.7/site-packages/autowrap-0.5.1-py2.7.egg/autowrap/CodeGenerator.py", line 562, in create_wrapper_for_nonoverloaded_method
out_converter = self.cr.get(res_t)
File "/home/ftpronk/local/lib/python2.7/site-packages/autowrap-0.5.1-py2.7.egg/autowrap/ConversionProvider.py", line 116, in get
raise Exception("no converter for %s" % cpp_type)
Exception: no converter for string

Python-3.6 support

Hi all.

Does autowrap support Python3.6 ?
Can you implement it, please?

autowrap currently fails on 2.7

To reenable 2.7 support this might need some change

File "/home/runner/work/autowrap/autowrap/autowrap/PXDParser.py", line 142
   raise ValueError("Cannot parse '{}'".format(line)) from e

testing fails

$ python setup.py build install
$ py.test tests

It appears the method result_type is failing to return the correct type

python 2.7.11, pytest 2.9.1, cython 0.24
full log here

Question about `wrap-attach` vs `@staticmethod`

Hi @hroest and @uweschmitt

Is there a reason why attaching a free function to a class was chosen over the @staticmethod decorator?
Or was this feature not present when support for static methods was required.

We are having problems like the following when building with the compiler directive binding=True (the new default in Cython3):
unbound method "cython_function_or_method" object must be called with instance as first argument

[FEATURE] Create type stubs (pyi) next to pyx

For better static typing support, auto-complete in IDEs etc.
Shouldn't be too hard to do. We have all the information. We probably just need to create another Code(Stub)Generator.py,
generate another list of Code objects with typing stubs and write them to a different file.

We can even use the new typing.overload decorator https://docs.python.org/3/library/typing.html#typing.overload
to specify all possible overloads of a method. No clunky squeezing into docstrings anymore.

Releasing the GIL for expensive methods

I am trying to find out how I can release the GIL for long running/expensive calls.
Marking the method as nogil in the pxd has not the desired effect, the generated pyx looks e.g. like this

def Compile(self):
        self.inst.get().Compile()

to release the GIL it should afaik look like this:

def Compile(self):
        with nogil:
            self.inst.get().Compile()

I am able to release the GIL in an addon like this, with the effect that the generated cpp contains the Py_BLOCK_THREADS and Py_UNBLOCK_THREADS macro.

Is there any plan to support GIL unlocking? Or if not how would a implementation look like? An annotation? Or would the nogil declaration be enough? I am not sure if it has really the same meaning:

http://docs.cython.org/src/userguide/external_C_code.html

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.