Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make building the Python GTK+3 user interface conditional. #21

Closed
wants to merge 1 commit into from
Closed

Make building the Python GTK+3 user interface conditional. #21

wants to merge 1 commit into from

Conversation

fcambus
Copy link

@fcambus fcambus commented Jul 29, 2022

This introduces an ENABLE_UI configuration option (enabled by default),
which allows disabling the user interface on systems where the Python
GTK+3 bindings are not available.

This introduces an ENABLE_UI configuration option (enabled by default),
which allows disabling the user interface on systems where the Python
GTK+3 bindings are not available.
@huth
Copy link
Member

huth commented Jul 31, 2022

Hi! Thanks for the patch, but I think introducing a user-selectable switch is the wrong approach here. It would be better if the cmake script probes for the availability of the right python stuff and then selects automatically whether to include the python-ui or not.

@huth
Copy link
Member

huth commented Jul 31, 2022

I think something like this should do the job:

diff a/CMakeLists.txt b/CMakeLists.txt
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -325,7 +325,18 @@ if(PYTHONINTERP_FOUND AND PYTHON_VERSION_MAJOR LESS 3)
        unset(PYTHONINTERP_FOUND)
 endif()
 if(PYTHONINTERP_FOUND)
-       add_subdirectory(python-ui)
+       execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "\
+import gi\n\
+gi.require_version('Gtk', '3.0')\n\
+from gi.repository import Gtk\n\
+from gi.repository import Gdk\n\
+from gi.repository import GdkPixbuf\n\
+from gi.repository import GLib"
+                       RESULT_VARIABLE PYTHON_GTK_RESULT
+                       OUTPUT_QUIET ERROR_QUIET)
+       if(${PYTHON_GTK_RESULT} EQUAL 0)
+               add_subdirectory(python-ui)
+       endif()
 endif(PYTHONINTERP_FOUND)
 
 if(UNIX AND NOT ENABLE_OSX_BUNDLE)

@fcambus
Copy link
Author

fcambus commented Aug 1, 2022

Yes, that makes sense. I tested your diff and I can confirm the detection works correctly, thanks!

@huth
Copy link
Member

huth commented Aug 1, 2022

Patch has been committed: 7464d78

@huth huth closed this Aug 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants