From ce47af852e37676081db13cc67779cc668c8d31a Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Mon, 6 Nov 2017 15:00:06 +0100 Subject: [PATCH] [python] Import tkinter only when necessary Don't import if Netgen was configured with USE_GUI=OFF --- python/CMakeLists.txt | 5 +++++ python/__init__.py | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 4c40d210..96a9cdc7 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -1,3 +1,8 @@ +if(USE_GUI) + set(IMPORT_TKINTER True) +else() + set(IMPORT_TKINTER False) +endif() configure_file(__init__.py ${CMAKE_CURRENT_BINARY_DIR}/__init__.py @ONLY) install(FILES diff --git a/python/__init__.py b/python/__init__.py index d4167469..5c8f2dc3 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -1,7 +1,9 @@ import os import sys -import tkinter +# import tkinter only if Netgen was configured with USE_GUI=ON +if @IMPORT_TKINTER@: + import tkinter _netgen_bin_dir=os.path.realpath(os.path.join(os.path.dirname(__file__),'..','@NETGEN_PYTHON_RPATH_BIN@')) _netgen_lib_dir=os.path.realpath(os.path.join(os.path.dirname(__file__),'..','@NETGEN_PYTHON_RPATH@'))