[C++-sig] EXTERNAL: Re: pygccxml KeyError

Davidson, Josh josh.davidson at lmco.com
Wed Dec 21 01:44:31 CET 2011

I did run into a couple subtle problems with this approach.  Depending on where I put the header file, Py++ doesn't generate pypp.hpp/pypp.cpp files that actually register the data structures.  Everything shows up in the exposed_decl.pypp.txt file, but there are no Py++ generated source files to actually get compiled into the extension.   Just where the file can be placed and where it can't is quite puzzling.  Initially, I wanted to build the fake header as a string using file_configuration_t and CONTENT_TYPE.TEXT as my files argument to module builder, but that didn't work.  I then created a real fake header in the filesystem, and it initially didn't work either.  After much trial and error, I found that it would work if placed in certain directories.

This is all that is in the header that I'm generating:
#include "LoggerInterface.h"
#include "LogWriter.h"
#include "SchedulerInterface.h"
#include "SimLoggerInterface.h"
#include "ThreadInterface.h"
#include "TimeInterface.h"

Here is a quick summary of some directories I've tried (source code for bindings is in: C:\Users\davidsj2\workspace\SimExternalInterfaces\src\C++\SimInterfaces\SimExecInterfaces)

C:\ - Outlier.  Spit out additional warnings and the build failed
C:\temp - FAIL
C:\Users - PASS
<user> - PASS
<user>\hello - FAIL
<user>\workspace - PASS
<user>\workspace\test - FAIL
<user>\workspace\SimExternalInterfaces - PASS
<user>\workspace\SimExternalInterfaces\build - FAIL
And many more

It seems like in order to work, the parent hierarchy of the fake header has to be an ancestor of the source directory.  As you'll note above, any time I branched away from the path leading to the source files, I ran into a problem.  Adding the parent directory for the fake header to the include_paths, does not resolve the problem.  I believe the string based approach also fails because py++ ends up creating a temporary file in a directory that is not an ancestor of the source.

Below, I'm including the build output for a build where the fake header is in a functioning directory, a non-functioning directory, and where it's included as in in-memory string using file_configuration_t.

-------------------------------------- CORRECT OUTPUT WITH FAKE HEADER IN SOURCE DIRECTORY ----------------------------------
INFO Parsing source file "C:\Users\davidsj2\workspace\SimExternalInterfaces\src\C++\SimInterfaces\SimExecInterfaces\executivefake.hpp" ... 
INFO gccxml cmd: ""C:\MinGW\bin\gccxml.exe"  -DBOOST_NO_RVALUE_REFERENCES -D__mode__(x)= -DMS_WIN64   -I"." -I"C:\Users\davidsj2\workspace\SimExternalInterfaces\src\C++\SimInterfaces\SimExecInterfaces" -I"C:\Users\davidsj2\workspace\SimExternalInterfaces\src\C++\SimInterfaces\SimExecInterfaces" -I"c:\Python26\include" -I"C:\Users\davidsj2\workspace\SimExternalInterfaces\src\C++\SimInterfaces\SimExecInterfaces" -I"C:\Users\davidsj2\workspace\SimExternalInterfaces\build\win64\sim\external"   "C:\Users\davidsj2\workspace\SimExternalInterfaces\src\C++\SimInterfaces\SimExecInterfaces\executivefake.hpp" -fxml="c:\users\davidsj2\appdata\local\temp\tmpimmd0m.xml""
INFO GCCXML version - 0.9( 1.135 )

INFO: file "named_tuple.py" - updated( 0.007568 seconds )

INFO: file "LogWriter.pypp.hpp" - updated( 0.007633 seconds )

INFO: file "LogWriter.pypp.cpp" - updated( 0.007400 seconds )

INFO: file "SchedulerInterface.pypp.hpp" - updated( 0.008093 seconds )

INFO: file "SchedulerInterface.pypp.cpp" - updated( 0.007427 seconds )

INFO: file "SimLoggerInterface.pypp.hpp" - updated( 0.008928 seconds )

INFO: file "SimLoggerInterface.pypp.cpp" - updated( 0.008304 seconds )

INFO: file "ThreadInterface.pypp.hpp" - updated( 0.007347 seconds )

INFO: file "ThreadInterface.pypp.cpp" - updated( 0.009345 seconds )

INFO: file "TimeInterface.pypp.hpp" - updated( 0.008310 seconds )

INFO: file "TimeInterface.pypp.cpp" - updated( 0.009422 seconds )

INFO: file "executive_enumerations.pypp.hpp" - updated( 0.008549 seconds )

INFO: file "executive_enumerations.pypp.cpp" - updated( 0.009992 seconds )

INFO: file "executive.main.cpp" - updated( 0.009686 seconds

-------------------------------------- INCORRECT OUTPUT WITH FAKE HEADER IN A DIFFERENT DIR ----------------------------------
python setup.py bdist_egg --plat-name=win64 build_ext --compiler=mingw32 build --build-platlib=build\win64 
INFO Parsing source file "C:\Users\davidsj2\hello\executivefake.hpp" ... 
INFO gccxml cmd: ""C:\MinGW\bin\gccxml.exe"  -DBOOST_NO_RVALUE_REFERENCES -D__mode__(x)= -DMS_WIN64   -I"." -I"C:\Users\davidsj2\workspace\SimExternalInterfaces\src\C++\SimInterfaces\SimExecInterfaces" -I"C:\Users\davidsj2\workspace\SimExternalInterfaces\src\C++\SimInterfaces\SimExecInterfaces" -I"c:\Python26\include" -I"C:\Users\davidsj2\workspace\SimExternalInterfaces\src\C++\SimInterfaces\SimExecInterfaces"   "C:\Users\davidsj2\hello\executivefake.hpp" -fxml="c:\users\davidsj2\appdata\local\temp\tmppbg0jc.xml""
INFO GCCXML version - 0.9( 1.135 )

INFO: file "named_tuple.py" - updated( 0.007635 seconds )

INFO: file "executive.main.cpp" - updated( 0.050896 seconds )

-------------------------------------- INCORRECT OUTPUT WITH FAKE HEADER AS A STRING ----------------------------------

python setup.py bdist_egg --plat-name=win64 build_ext --compiler=mingw32 build --build-platlib=build\win64 
INFO gccxml cmd: ""C:\MinGW\bin\gccxml.exe"  -DBOOST_NO_RVALUE_REFERENCES -D__mode__(x)= -DMS_WIN64   -I"." -I"C:\Users\davidsj2\workspace\SimExternalInterfaces\src\C++\SimInterfaces\SimExecInterfaces" -I"C:\Users\davidsj2\workspace\SimExternalInterfaces\src\C++\SimInterfaces\SimExecInterfaces" -I"c:\Python26\include" -I"C:\Users\davidsj2\workspace\SimExternalInterfaces\src\C++\SimInterfaces\SimExecInterfaces"   "c:\users\davidsj2\appdata\local\temp\tmpe3ooz9.h" -fxml="c:\users\davidsj2\appdata\local\temp\tmptogx_j.xml""
INFO GCCXML version - 0.9( 1.135 )

INFO: file "named_tuple.py" - updated( 0.003908 seconds )

INFO: file "executive.main.cpp" - updated( 0.008799 seconds )

-----Original Message-----
From: cplusplus-sig-bounces+josh.davidson=lmco.com at python.org [mailto:cplusplus-sig-bounces+josh.davidson=lmco.com at python.org] On Behalf Of Roman Yakovenko
Sent: Monday, December 19, 2011 1:35 PM
To: Development of Python/C++ integration
Subject: Re: [C++-sig] EXTERNAL: Re: pygccxml KeyError

On Mon, Dec 19, 2011 at 10:24 PM, Davidson, Josh <josh.davidson at lmco.com> wrote:
> Actually, it is using a source_reader_t by default.  __parse_declarations invokes __parse_file_by_file, which uses a source_reader_t (line 236) to parse each file.  It then bombs out after parsing all of the files when it calls _join_class_hierarchy.
> I continue to have this issue with various combinations of classes.  In other words, I have headers that work fine with parsed in isolation, but when I try to build a module containing both, I get the KeyError.

Can you create a single header file, which includes all others?

Cplusplus-sig mailing list
Cplusplus-sig at python.org

More information about the Cplusplus-sig mailing list