From 522477eb2d47c6da83077d281d2b4c556d99ee17 Mon Sep 17 00:00:00 2001 From: Olivier Parcollet Date: Sat, 26 Jul 2014 21:51:40 +0200 Subject: [PATCH] desc generator : minor cleaning - while porting apps. examples to 1.2 - add build_ipytriqs, etc... - various details... --- cmake/TRIQSConfig.cmake.in | 19 +++++++++++++++++++ pytriqs/wrap_generator/clang_parser.py | 5 +++-- pytriqs/wrap_generator/wrap_desc.mako.py | 7 +++++-- .../wrapper_desc_generator.py.in | 2 +- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/cmake/TRIQSConfig.cmake.in b/cmake/TRIQSConfig.cmake.in index 7b386c0c..d0428850 100644 --- a/cmake/TRIQSConfig.cmake.in +++ b/cmake/TRIQSConfig.cmake.in @@ -151,6 +151,25 @@ macro (triqs_prepare_local_pytriqs_merged_with_my_python python_destination) ) execute_process(COMMAND chmod 755 ${CMAKE_BINARY_DIR}/build_pytriqs) + # the ipython -> just replace python by ipython, keep the same path + STRING (REPLACE "python" "ipython" TRIQS_IPYTHON_INTERPRETER ${TRIQS_PYTHON_INTERPRETER}) + + # Create the local build_ipytriqs executable + file(WRITE ${CMAKE_BINARY_DIR}/build_ipytriqs + "#!/bin/bash + export PYTHONPATH=${CMAKE_BINARY_DIR}:$PYTHONPATH + ${TRIQS_IPYTHON_INTERPRETER} $@" + ) + execute_process(COMMAND chmod 755 ${CMAKE_BINARY_DIR}/build_ipytriqs) + + # Create the local build_ipytriqs_notebook executable + file(WRITE ${CMAKE_BINARY_DIR}/build_ipytriqs_notebook + "#!/bin/bash + export PYTHONPATH=${CMAKE_BINARY_DIR}:$PYTHONPATH + ${TRIQS_IPYTHON_INTERPRETER} notebook --pylab=inline $@" + ) + execute_process(COMMAND chmod 755 ${CMAKE_BINARY_DIR}/build_ipytriqs_notebook) + # Get a list of all local py and pyx files file(GLOB_RECURSE relative_local RELATIVE ${CMAKE_SOURCE_DIR}/python *.py *.pyx) foreach(f IN LISTS relative_local) diff --git a/pytriqs/wrap_generator/clang_parser.py b/pytriqs/wrap_generator/clang_parser.py index 6938518c..69da524e 100644 --- a/pytriqs/wrap_generator/clang_parser.py +++ b/pytriqs/wrap_generator/clang_parser.py @@ -158,12 +158,13 @@ def build_functions_and_classes(cursor, namespaces=[]): def parse(filename, debug, compiler_options, where_is_libclang): - compiler_options = [ '-std=c++11', '-stdlib=libc++', '-D__CODE_GENERATOR__'] + compiler_options + compiler_options = [ '-std=c++11', '-stdlib=libc++'] + compiler_options clang.cindex.Config.set_library_file(where_is_libclang) index = clang.cindex.Index.create() + print "Parsing the C++ file (may take a few seconds) ..." translation_unit = index.parse(filename, ['-x', 'c++'] + compiler_options) - print "Parsing done. \nExtracting ..." + print "... done. \nExtracting ..." # If clang encounters errors, we report and stop errors = [d for d in translation_unit.diagnostics if d.severity >= 3] diff --git a/pytriqs/wrap_generator/wrap_desc.mako.py b/pytriqs/wrap_generator/wrap_desc.mako.py index a7f51355..69262139 100644 --- a/pytriqs/wrap_generator/wrap_desc.mako.py +++ b/pytriqs/wrap_generator/wrap_desc.mako.py @@ -28,6 +28,8 @@ for m in c.methods : for t,n,d in m.params : analyse(t) analyse(m.rtype) + for p in c.proplist : + analyse(p.getter.rtype) for f in functions : for t,n,d in f.params : analyse(t) @@ -51,7 +53,8 @@ %> ## ## -# Generated automatically using libclang +# Generated automatically using libclang using the command : +# ${shell_command} from wrap_generator import * # The module @@ -69,7 +72,7 @@ module.add_include("${args.filename}") module.add_preamble(""" // using namespace XXX; """) -## + ## %for c in classes : # The class ${c.name} diff --git a/pytriqs/wrap_generator/wrapper_desc_generator.py.in b/pytriqs/wrap_generator/wrapper_desc_generator.py.in index afc3919a..e9c0828d 100644 --- a/pytriqs/wrap_generator/wrapper_desc_generator.py.in +++ b/pytriqs/wrap_generator/wrapper_desc_generator.py.in @@ -76,7 +76,7 @@ if __name__ == '__main__' : cls.methods = [m for m in cls.methods if m not in exclude] tpl = Template(filename=triqs_install_location + '/share/triqs/wrap_generator/wrap_desc.mako.py') - rendered = tpl.render(classes = classes, functions = functions, modulename=modulename, args = args ) + rendered = tpl.render(classes = classes, functions = functions, modulename=modulename, args = args, shell_command= ' '.join(sys.argv) ) with open("{modulename}_desc.py".format(modulename=modulename), "w") as f: f.write(rendered)