# HG changeset patch # User František Kučera # Date 1544724758 -3600 # Node ID 2c8f5e05c7b7ecf23f61a8e9e46419c86e701c50 # Parent ed7ab0a068495a8a758910c818c5249046a23efa Python included diff -r ed7ab0a06849 -r 2c8f5e05c7b7 asan-ignore.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/asan-ignore.txt Thu Dec 13 19:12:38 2018 +0100 @@ -0,0 +1,12 @@ +# There migth be memory leaks ouside our program in shared libraries. +# We want to ignore them and focus on leaks in our code. + +# To use this ignore list, run with: +# LSAN_OPTIONS=suppressions=asan-ignore.txt +# In Netbeans it should be set in the project properties / Run / Environment + +# Would ignore all memory leaks: +# leak:.* + +# Ignore particular libraries: +leak:/usr/lib/x86_64-linux-gnu/libpython3.6m.so diff -r ed7ab0a06849 -r 2c8f5e05c7b7 nbproject/configurations.xml --- a/nbproject/configurations.xml Thu Dec 13 18:17:36 2018 +0100 +++ b/nbproject/configurations.xml Thu Dec 13 19:12:38 2018 +0100 @@ -51,7 +51,6 @@ kind="IMPORTANT_FILES_FOLDER"> CMakeLists.txt build/Debug/Makefile - build/Release/Makefile ^(nbproject|build)$ @@ -82,6 +81,8 @@ ../relpipe-lib-reader.cpp/include ../relpipe-lib-writer.cpp/include ../relpipe-lib-cli.cpp/include + /usr/include/python3.6m + /usr/include/x86_64-linux-gnu/python3.6m build/Debug/src diff -r ed7ab0a06849 -r 2c8f5e05c7b7 src/CMakeLists.txt --- a/src/CMakeLists.txt Thu Dec 13 18:17:36 2018 +0100 +++ b/src/CMakeLists.txt Thu Dec 13 19:12:38 2018 +0100 @@ -18,7 +18,7 @@ # Relpipe libraries: INCLUDE(FindPkgConfig) -pkg_check_modules (RELPIPE_LIBS relpipe-lib-reader.cpp relpipe-lib-writer.cpp relpipe-lib-cli.cpp) +pkg_check_modules (RELPIPE_LIBS relpipe-lib-reader.cpp relpipe-lib-writer.cpp relpipe-lib-cli.cpp python-3.6) include_directories(${RELPIPE_LIBS_INCLUDE_DIRS}) link_directories(${RELPIPE_LIBS_LIBRARY_DIRS}) diff -r ed7ab0a06849 -r 2c8f5e05c7b7 src/PythonHandler.h --- a/src/PythonHandler.h Thu Dec 13 18:17:36 2018 +0100 +++ b/src/PythonHandler.h Thu Dec 13 19:12:38 2018 +0100 @@ -26,6 +26,8 @@ #include #include +#include + #include #include #include @@ -48,6 +50,8 @@ private: shared_ptr relationalWriter; + wchar_t* pythonProgramName; + wregex relationNameRegEx; wregex attributeNameRegEx; wregex searchRegEx; @@ -63,15 +67,27 @@ GrepHandler(ostream& output, const vector& arguments) { relationalWriter.reset(writer::Factory::create(output)); + pythonProgramName = Py_DecodeLocale("relpipe-tr-python", NULL); + Py_SetProgramName(pythonProgramName); + Py_Initialize(); + + //PyRun_SimpleString("print('Hello from Python!')"); + if (arguments.size() == 3) { relationNameRegEx = wregex(arguments[0]); attributeNameRegEx = wregex(arguments[1]); searchRegEx = wregex(arguments[2]); } else { + PyMem_RawFree(pythonProgramName); throw cli::RelpipeCLIException(L"Usage: relpipe-tr-python ", cli::CLI::EXIT_CODE_UNKNOWN_COMMAND); } } + virtual ~GrepHandler() { + Py_FinalizeEx(); + PyMem_RawFree(pythonProgramName); + } + void startRelation(string_t name, vector attributes) override { // TODO: move to a reusable method (or use same metadata on both reader and writer side?) vector writerMetadata;