Skip to content

Commit

Permalink
Fix: configure.ac: silently accepting invalid Python configuration
Browse files Browse the repository at this point in the history
Currently, if the user builds and installs the project with:
  ./configure --enable-python-plugins
  make
  make install

They won't be able to do the `import bt2` necessary to start defining
their BT2 plugin. To write a Python plugin , the user needs to use the
Python bindings as well.

The user gets this:
  >>> import bt2
  Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
  ModuleNotFoundError: No module named 'bt2'

As suggested by Simon Marchi, I implemented the following truth table
for the Python-related configure options (--enable-python-bindings and
 --enable-python-plugins):

  plugins | bindings
  --------+---------
  missing | missing  -> both disabled
  missing | enable   -> plugins disabled, bindings enabled
  missing | disable  -> both disabled
  enable  | missing  -> both enabled
  enable  | enable   -> both enabled
  enable  | disable  -> error
  disable | missing  -> both disabled
  disable | enable   -> plugins disabled, bindings enabled
  disable | disable  -> both disabled

This makes sure the user doesn't get into an invalid configuration _and_
offers the sane default of enabling the bindings (if they were omitted)
when plugins are enabled explicitly.

Fixes #1240

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I3b94d8911568290239add616f8e794ad73e278db
Reviewed-on: https://review.lttng.org/c/babeltrace/+/3152
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Michael Jeanson <mjeanson@efficios.com>
  • Loading branch information
frdeso authored and jgalar committed Mar 2, 2020
1 parent 18c9df9 commit 3530dd0
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,9 @@ AS_IF([test "x$BABELTRACE_DEBUG_MODE" = x1], [
# Python bindings
# Disabled by default
AC_ARG_ENABLE([python-bindings],
[AC_HELP_STRING([--enable-python-bindings], [build the Python bindings])]
dnl AC_ARG_ENABLE will fill enable_python_bindings with the user choice
[AC_HELP_STRING([--enable-python-bindings], [build the Python bindings])],
[], dnl AC_ARG_ENABLE will fill enable_python_bindings with the user choice
[enable_python_bindings=unspecified]
)

# Python plugins
Expand Down Expand Up @@ -446,6 +447,29 @@ AS_IF([test "x$enable_debug_info" = xyes],

AC_SUBST([ENABLE_DEBUG_INFO_VAL])

# Check for conflicting Python related features user choices.
AS_IF([test "x$enable_python_plugins" = xyes],
[
AS_IF([test "x$enable_python_bindings" = xunspecified],
[
# --enable-python-plugins was provided but --enable-python-bindings was
# omitted. Turn the Python bindings ON anyway because it's needed to
# use the Python plugins.
enable_python_bindings=yes
],
[
AS_IF([test "x$enable_python_bindings" = xno],
[
# --enable-python-plugins _and_ --disable-python-bindings were
# used. This is invalid because Python plugins need the Python
# bindings to be useful.
AC_MSG_ERROR(--enable-python-bindings must be used to support Python plugins)
]
)
]
)
]
)

# Check for conflicting optional features user choices

Expand Down

0 comments on commit 3530dd0

Please sign in to comment.