2 dnl # The majority of the python scripts are written to be compatible
3 dnl # with Python 3.6. This option is intended to
4 dnl # to provide a method to specify the default system version, and
5 dnl # set the PYTHON environment variable accordingly.
7 AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_PYTHON], [
9 AS_HELP_STRING([--with-python[=VERSION]],
10 [default system python version @<:@default=check@:>@]),
11 [with_python=$withval],
14 AS_CASE([$with_python],
15 [check], [AC_CHECK_PROGS([PYTHON], [python3], [:])],
16 [3*], [PYTHON="python${with_python}"],
17 [*python3*], [PYTHON="${with_python}"],
19 [AC_MSG_ERROR([Unknown --with-python value '$with_python'])]
23 dnl # Minimum supported Python versions for utilities: Python 3.6
25 AM_PATH_PYTHON([], [], [:])
26 AS_IF([test -z "$PYTHON_VERSION"], [
27 PYTHON_VERSION=$(echo ${PYTHON##*/} | tr -cd 0-9.)
29 PYTHON_MINOR=${PYTHON_VERSION#*\.}
31 AS_CASE([$PYTHON_VERSION],
33 AS_IF([test $PYTHON_MINOR -lt 6],
34 [AC_MSG_ERROR("Python >= 3.6 is required")])
40 AM_CONDITIONAL([USING_PYTHON], [test "$PYTHON" != :])
41 AC_SUBST([PYTHON_SHEBANG], [python3])
44 dnl # Request that packages be built for a specific Python version.
46 AS_IF([test "x$with_python" != xcheck], [
47 PYTHON_PKG_VERSION=$(echo $PYTHON_VERSION | tr -d .)
48 DEFINE_PYTHON_PKG_VERSION='--define "__use_python_pkg_version '${PYTHON_PKG_VERSION}'"'
49 DEFINE_PYTHON_VERSION='--define "__use_python '${PYTHON}'"'
51 DEFINE_PYTHON_VERSION=''
52 DEFINE_PYTHON_PKG_VERSION=''
55 AC_SUBST(DEFINE_PYTHON_VERSION)
56 AC_SUBST(DEFINE_PYTHON_PKG_VERSION)