Make Python detection optional and more portable
Previously, --without-python would cause ./configure to fail. Now it is able to proceed, and the Python scripts will not be built. Use portable parameter expansion matching instead of nonstandard substring matching to detect the Python version. This test is duplicated in several places, so define a function for it. Don't assume the full path to binaries, since different platforms do install things in different places. Use AC_CHECK_PROGS instead. When building without Python, also build without pyzfs. Sponsored by: iXsystems, Inc. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Richard Laager <rlaager@wiktel.com> Reviewed-by: Eli Schwartz <eschwartz93@gmail.com> Signed-off-by: Ryan Moeller <ryan@freqlabs.com> Closes #8809 Closes #8731
This commit is contained in:
parent
df24bcf00a
commit
1a132f0638
|
@ -1,3 +1,8 @@
|
||||||
SUBDIRS = zfs zpool zdb zhack zinject zstreamdump ztest
|
SUBDIRS = zfs zpool zdb zhack zinject zstreamdump ztest
|
||||||
SUBDIRS += mount_zfs fsck_zfs zvol_id vdev_id arcstat dbufstat zed
|
SUBDIRS += fsck_zfs vdev_id raidz_test zgenhostid
|
||||||
SUBDIRS += arc_summary raidz_test zgenhostid
|
|
||||||
|
if USING_PYTHON
|
||||||
|
SUBDIRS += arcstat arc_summary dbufstat
|
||||||
|
endif
|
||||||
|
|
||||||
|
SUBDIRS += mount_zfs zed zvol_id
|
||||||
|
|
|
@ -12,6 +12,17 @@ AC_DEFUN([ZFS_AC_PYTHON_VERSION], [
|
||||||
])
|
])
|
||||||
])
|
])
|
||||||
|
|
||||||
|
dnl #
|
||||||
|
dnl # ZFS_AC_PYTHON_VERSION_IS_2
|
||||||
|
dnl # ZFS_AC_PYTHON_VERSION_IS_3
|
||||||
|
dnl #
|
||||||
|
dnl # Tests if the $PYTHON_VERSION matches 2.x or 3.x.
|
||||||
|
dnl #
|
||||||
|
AC_DEFUN([ZFS_AC_PYTHON_VERSION_IS_2],
|
||||||
|
[test "${PYTHON_VERSION%%\.*}" = "2"])
|
||||||
|
AC_DEFUN([ZFS_AC_PYTHON_VERSION_IS_3],
|
||||||
|
[test "${PYTHON_VERSION%%\.*}" = "3"])
|
||||||
|
|
||||||
dnl #
|
dnl #
|
||||||
dnl # ZFS_AC_PYTHON_MODULE(module_name, [action-if-true], [action-if-false])
|
dnl # ZFS_AC_PYTHON_MODULE(module_name, [action-if-true], [action-if-false])
|
||||||
dnl #
|
dnl #
|
||||||
|
@ -46,42 +57,36 @@ AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_PYTHON], [
|
||||||
[with_python=check])
|
[with_python=check])
|
||||||
|
|
||||||
AS_CASE([$with_python],
|
AS_CASE([$with_python],
|
||||||
[check],
|
[check], [AC_CHECK_PROGS([PYTHON], [python3 python2], [:])],
|
||||||
[AS_IF([test -x /usr/bin/python3],
|
|
||||||
[PYTHON="python3"],
|
|
||||||
[AS_IF([test -x /usr/bin/python2],
|
|
||||||
[PYTHON="python2"],
|
|
||||||
[PYTHON=""]
|
|
||||||
)]
|
|
||||||
)],
|
|
||||||
[2*], [PYTHON="python${with_python}"],
|
[2*], [PYTHON="python${with_python}"],
|
||||||
[*python2*], [PYTHON="${with_python}"],
|
[*python2*], [PYTHON="${with_python}"],
|
||||||
[3*], [PYTHON="python${with_python}"],
|
[3*], [PYTHON="python${with_python}"],
|
||||||
[*python3*], [PYTHON="${with_python}"],
|
[*python3*], [PYTHON="${with_python}"],
|
||||||
[no], [PYTHON=""],
|
[no], [PYTHON=":"],
|
||||||
[AC_MSG_ERROR([Unknown --with-python value '$with_python'])]
|
[AC_MSG_ERROR([Unknown --with-python value '$with_python'])]
|
||||||
)
|
)
|
||||||
|
|
||||||
AS_IF([$PYTHON --version >/dev/null 2>&1], [ /bin/true ], [
|
AS_IF([test $PYTHON != :], [
|
||||||
AC_MSG_ERROR([Cannot find $PYTHON in your system path])
|
AS_IF([$PYTHON --version >/dev/null 2>&1],
|
||||||
|
[AM_PATH_PYTHON([2.6], [], [:])],
|
||||||
|
[AC_MSG_ERROR([Cannot find $PYTHON in your system path])]
|
||||||
|
)
|
||||||
])
|
])
|
||||||
|
|
||||||
AM_PATH_PYTHON([2.6], [], [:])
|
|
||||||
AM_CONDITIONAL([USING_PYTHON], [test "$PYTHON" != :])
|
AM_CONDITIONAL([USING_PYTHON], [test "$PYTHON" != :])
|
||||||
AM_CONDITIONAL([USING_PYTHON_2], [test "${PYTHON_VERSION:0:2}" = "2."])
|
AM_CONDITIONAL([USING_PYTHON_2], [ZFS_AC_PYTHON_VERSION_IS_2])
|
||||||
AM_CONDITIONAL([USING_PYTHON_3], [test "${PYTHON_VERSION:0:2}" = "3."])
|
AM_CONDITIONAL([USING_PYTHON_3], [ZFS_AC_PYTHON_VERSION_IS_3])
|
||||||
|
|
||||||
dnl #
|
dnl #
|
||||||
dnl # Minimum supported Python versions for utilities:
|
dnl # Minimum supported Python versions for utilities:
|
||||||
dnl # Python 2.6.x, or Python 3.4.x
|
dnl # Python 2.6.x, or Python 3.4.x
|
||||||
dnl #
|
dnl #
|
||||||
AS_IF([test "${PYTHON_VERSION:0:2}" = "2."], [
|
AS_IF([ZFS_AC_PYTHON_VERSION_IS_2], [
|
||||||
ZFS_AC_PYTHON_VERSION([>= '2.6'], [ /bin/true ],
|
ZFS_AC_PYTHON_VERSION([>= '2.6'], [ true ],
|
||||||
[AC_MSG_ERROR("Python >= 2.6.x is not available")])
|
[AC_MSG_ERROR("Python >= 2.6.x is not available")])
|
||||||
])
|
])
|
||||||
|
|
||||||
AS_IF([test "${PYTHON_VERSION:0:2}" = "3."], [
|
AS_IF([ZFS_AC_PYTHON_VERSION_IS_3], [
|
||||||
ZFS_AC_PYTHON_VERSION([>= '3.4'], [ /bin/true ],
|
ZFS_AC_PYTHON_VERSION([>= '3.4'], [ true ],
|
||||||
[AC_MSG_ERROR("Python >= 3.4.x is not available")])
|
[AC_MSG_ERROR("Python >= 3.4.x is not available")])
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,12 @@ AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_PYZFS], [
|
||||||
DEFINE_PYZFS='--without pyzfs'
|
DEFINE_PYZFS='--without pyzfs'
|
||||||
])
|
])
|
||||||
], [
|
], [
|
||||||
DEFINE_PYZFS=''
|
AS_IF([test $PYTHON != :], [
|
||||||
|
DEFINE_PYZFS=''
|
||||||
|
], [
|
||||||
|
enable_pyzfs=no
|
||||||
|
DEFINE_PYZFS='--without pyzfs'
|
||||||
|
])
|
||||||
])
|
])
|
||||||
AC_SUBST(DEFINE_PYZFS)
|
AC_SUBST(DEFINE_PYZFS)
|
||||||
|
|
||||||
|
@ -26,10 +31,10 @@ AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_PYZFS], [
|
||||||
dnl # Require python-devel libraries
|
dnl # Require python-devel libraries
|
||||||
dnl #
|
dnl #
|
||||||
AS_IF([test "x$enable_pyzfs" = xcheck -o "x$enable_pyzfs" = xyes], [
|
AS_IF([test "x$enable_pyzfs" = xcheck -o "x$enable_pyzfs" = xyes], [
|
||||||
AS_IF([test "${PYTHON_VERSION:0:2}" = "2."], [
|
AS_IF([ZFS_AC_PYTHON_VERSION_IS_2], [
|
||||||
PYTHON_REQUIRED_VERSION=">= '2.7.0'"
|
PYTHON_REQUIRED_VERSION=">= '2.7.0'"
|
||||||
], [
|
], [
|
||||||
AS_IF([test "${PYTHON_VERSION:0:2}" = "3."], [
|
AS_IF([ZFS_AC_PYTHON_VERSION_IS_3], [
|
||||||
PYTHON_REQUIRED_VERSION=">= '3.4.0'"
|
PYTHON_REQUIRED_VERSION=">= '3.4.0'"
|
||||||
], [
|
], [
|
||||||
AC_MSG_ERROR("Python $PYTHON_VERSION unknown")
|
AC_MSG_ERROR("Python $PYTHON_VERSION unknown")
|
||||||
|
|
Loading…
Reference in New Issue