Open opeil opened 8 years ago
again, I need a complete example on which I can work ...
https://gist.github.com/opeil/396ba90fab1c610c703f
Three issues are demonstrated there:
CMake files are also attached. They need to be placed in respective directories ('c++' and 'python').
On Mon, Feb 15, 2016 at 5:56 PM, Olivier Parcollet <notifications@github.com
wrote:
again, I need a complete example on which I can work ...
— Reply to this email directly or view it on GitHub https://github.com/TRIQS/triqs/issues/305#issuecomment-184299231.
Dr. Oleg E. Peil Department of Quantum Matter Physics Universite de Geneve CH-1211 Geneve 4 Switzerland Tel :+41 (0)22 379 3571
UPDATE: It does not always work. There is still a problem with convert_from_python<T>(ob)
.
I found out that the issue #305 (this issue) is resolved if one puts the proper header (#include <triqs/python_tools/converters/arrays.hpp>
) into the 'add_preamble()'. So all these three issues are related to bugs in c++2py.
Hi Oleg,
Your testlib_wrap.py
exhibits two problems with c++2py
:
../c++
prefix is (erroneously?) removed from an argument of module.add_include()
. Commit cd4fd40629ed5e45901be50f82a8a4b9cf558019 is responsible for this behavior.#include <triqs/python_tools/converters/arrays.hpp>
is missing from add_preamble()
. This is because half of the converters we have in triqs/python_tools/converters
are not listed in converters_to_include
mapping. arrays.hpp
is one of them.Igor, /c++
prefixed was not removed, it was not there from the very beginning. I added it by hands (a commented line above the wrong one) but then left the original line to point out a potential bug in c++2py
.
As to the include ../converters/arrays.hpp
I also added it by hands but it helped only in the case of the little example that I put on gist. When I did this in the full source file I still got the error message given in the title of the issue. Admittedly, a reference to a pointer, PyObject *&
, looks suspicious to me. Is it meant to be like that?
Igor,
/c++
prefixed was not removed, it was not there from the very beginning. I added it by hands (a commented line above the wrong one) but then left the original line to point out a potential bug in c++2py.
I understand, I meant that it was removed by c++2py in the first place. For a reason, which is not clear to me.
As to the include ../converters/arrays.hpp I also added it by hands but it helped only in the case of the little example that I put on gist. When I did this in the full source file I still got the error message given in the title of the issue. Admittedly, a reference to a pointer, PyObject *&, looks suspicious to me. Is it meant to be like that?
In general, PyObject *&
is a perfectly valid argument type for convert_from_python()
.
You are saying that your short example compiles after adding #include <triqs/python_tools/converters/arrays.hpp>
to add_preamble()
, but the full application still fails. Does it fail with exactly the same error message?
c++2py
: In this simple example it just removes the path completely. But in my full code it does a very strange thing: instead of putting a correct path ../../../c++/plovasp/atm/dos_tetra3d.cpp
it adds ../../plovasp/atm/dos_tetra3d.cpp
. Perhaps this would help to identify the problem.c++2py
tries to convert all functions present in the source file, to which I did not pay attention before. However, most of them are internal and some of them take arguments such as double *
. Obviously, there is not converter for this type of arguments and the wrapper fails to compile. To fix this I just removed from _desc.py
all functions that are not meant to be converted and the compilation worked (have not checked yet whether the code runs, though).My question is the following: Is there a legal way to tell c++2py
not to touch certain (static) functions which are supposed to be internal to a library?
Perhaps this would help to identify the problem
The problem is in commit cd4fd40629ed5e45901be50f82a8a4b9cf558019, as I wrote above (see the changes made to tools/cpp2py/mako/xxx_desc.py
). I guess Olivier @parcollet can explain what and why he did in that commit.
My question is the following: Is there a legal way to tell c++2py not to touch certain (static) functions which are supposed to be internal to a library?
First of all, you should normally run c++2py.py
on the header file, dos_tetra3d.hpp
in your example. dos_tetra3d.cpp
may contain as many internal functions as you like; they will not be seen by c++2py.py
.
Second, there is a special macro TRIQS_CPP2PY_IGNORE
. You can put it in front of a function declaration in the header file and effectively hide that declaration from c++2py
.
Here is an example of use: https://github.com/TRIQS/cthyb/blob/master/c++/atom_diag.hpp
The following error(s) are produced when trying to compile the wrapped c++ code:
Code snippet: