]>
Commit | Line | Data |
---|---|---|
6e72a5b9 BB |
1 | dnl # |
2 | dnl # The majority of the python scripts are written to be compatible | |
8a7c4efd | 3 | dnl # with Python 3.6. This option is intended to |
6e72a5b9 BB |
4 | dnl # to provide a method to specify the default system version, and |
5 | dnl # set the PYTHON environment variable accordingly. | |
6 | dnl # | |
7 | AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_PYTHON], [ | |
8 | AC_ARG_WITH([python], | |
06346cc5 | 9 | AS_HELP_STRING([--with-python[=VERSION]], |
6e72a5b9 BB |
10 | [default system python version @<:@default=check@:>@]), |
11 | [with_python=$withval], | |
12 | [with_python=check]) | |
13 | ||
14 | AS_CASE([$with_python], | |
8a7c4efd | 15 | [check], [AC_CHECK_PROGS([PYTHON], [python3], [:])], |
6e72a5b9 BB |
16 | [3*], [PYTHON="python${with_python}"], |
17 | [*python3*], [PYTHON="${with_python}"], | |
1a132f06 | 18 | [no], [PYTHON=":"], |
6e72a5b9 BB |
19 | [AC_MSG_ERROR([Unknown --with-python value '$with_python'])] |
20 | ) | |
21 | ||
6e72a5b9 | 22 | dnl # |
8a7c4efd | 23 | dnl # Minimum supported Python versions for utilities: Python 3.6 |
6e72a5b9 | 24 | dnl # |
b1b4ac27 RM |
25 | AM_PATH_PYTHON([], [], [:]) |
26 | AS_IF([test -z "$PYTHON_VERSION"], [ | |
420b4448 | 27 | PYTHON_VERSION=$(echo ${PYTHON##*/} | tr -cd 0-9.) |
6e72a5b9 | 28 | ]) |
b1b4ac27 | 29 | PYTHON_MINOR=${PYTHON_VERSION#*\.} |
6e72a5b9 | 30 | |
b1b4ac27 | 31 | AS_CASE([$PYTHON_VERSION], |
b1b4ac27 | 32 | [3.*], [ |
8a7c4efd DS |
33 | AS_IF([test $PYTHON_MINOR -lt 6], |
34 | [AC_MSG_ERROR("Python >= 3.6 is required")]) | |
b1b4ac27 RM |
35 | ], |
36 | [:|2|3], [], | |
37 | [PYTHON_VERSION=3] | |
38 | ) | |
39 | ||
40 | AM_CONDITIONAL([USING_PYTHON], [test "$PYTHON" != :]) | |
8a7c4efd | 41 | AC_SUBST([PYTHON_SHEBANG], [python3]) |
38e2e9ce | 42 | |
6e72a5b9 BB |
43 | dnl # |
44 | dnl # Request that packages be built for a specific Python version. | |
45 | dnl # | |
b1b4ac27 RM |
46 | AS_IF([test "x$with_python" != xcheck], [ |
47 | PYTHON_PKG_VERSION=$(echo $PYTHON_VERSION | tr -d .) | |
6e72a5b9 BB |
48 | DEFINE_PYTHON_PKG_VERSION='--define "__use_python_pkg_version '${PYTHON_PKG_VERSION}'"' |
49 | DEFINE_PYTHON_VERSION='--define "__use_python '${PYTHON}'"' | |
50 | ], [ | |
51 | DEFINE_PYTHON_VERSION='' | |
52 | DEFINE_PYTHON_PKG_VERSION='' | |
53 | ]) | |
54 | ||
55 | AC_SUBST(DEFINE_PYTHON_VERSION) | |
56 | AC_SUBST(DEFINE_PYTHON_PKG_VERSION) | |
57 | ]) |