diff --git a/config/ax_python_devel.m4 b/config/ax_python_devel.m4 index 7adcf01a04cd..e6cee04288b8 100644 --- a/config/ax_python_devel.m4 +++ b/config/ax_python_devel.m4 @@ -165,31 +165,16 @@ variable to configure. See ``configure --help'' for reference. fi fi - # - # Check if you have distutils, else fail - # - AC_MSG_CHECKING([for the distutils Python package]) - if ac_distutils_result=`$PYTHON -c "import distutils" 2>&1`; then - AC_MSG_RESULT([yes]) - else - AC_MSG_RESULT([no]) - m4_ifvaln([$2],[$2],[ - AC_MSG_ERROR([cannot import Python module "distutils". -Please check your Python installation. The error was: -$ac_distutils_result]) - PYTHON_VERSION="" - ]) - fi - # # Check for Python include path # + # AC_MSG_CHECKING([for Python include path]) if test -z "$PYTHON_CPPFLAGS"; then - python_path=`$PYTHON -c "import distutils.sysconfig; \ - print (distutils.sysconfig.get_python_inc ());"` - plat_python_path=`$PYTHON -c "import distutils.sysconfig; \ - print (distutils.sysconfig.get_python_inc (plat_specific=1));"` + python_path=`$PYTHON -c "import sysconfig; \ + print (sysconfig.get_path('include'));"` + plat_python_path=`$PYTHON -c "import sysconfig; \ + print (sysconfig.get_path('platinclude'));"` if test -n "${python_path}"; then if test "${plat_python_path}" != "${python_path}"; then python_path="-I$python_path -I$plat_python_path" @@ -213,7 +198,7 @@ $ac_distutils_result]) # join all versioning strings, on some systems # major/minor numbers could be in different list elements -from distutils.sysconfig import * +from sysconfig import * e = get_config_var('VERSION') if e is not None: print(e) @@ -236,8 +221,8 @@ EOD` ac_python_libdir=`cat</dev/null || \ + $PYTHON -c "import sysconfig; \ + print (sysconfig.get_path('purelib'));"` fi AC_MSG_RESULT([$PYTHON_SITE_PKG]) AC_SUBST([PYTHON_SITE_PKG]) @@ -299,8 +286,8 @@ EOD` # AC_MSG_CHECKING(python extra libraries) if test -z "$PYTHON_EXTRA_LIBS"; then - PYTHON_EXTRA_LIBS=`$PYTHON -c "import distutils.sysconfig; \ - conf = distutils.sysconfig.get_config_var; \ + PYTHON_EXTRA_LIBS=`$PYTHON -c "import sysconfig; \ + conf = sysconfig.get_config_var; \ print (conf('LIBS') + ' ' + conf('SYSLIBS'))"` fi AC_MSG_RESULT([$PYTHON_EXTRA_LIBS]) @@ -311,8 +298,8 @@ EOD` # AC_MSG_CHECKING(python extra linking flags) if test -z "$PYTHON_EXTRA_LDFLAGS"; then - PYTHON_EXTRA_LDFLAGS=`$PYTHON -c "import distutils.sysconfig; \ - conf = distutils.sysconfig.get_config_var; \ + PYTHON_EXTRA_LDFLAGS=`$PYTHON -c "import sysconfig; \ + conf = sysconfig.get_config_var; \ print (conf('LINKFORSHARED'))"` fi AC_MSG_RESULT([$PYTHON_EXTRA_LDFLAGS]) diff --git a/rpm/generic/zfs.spec.in b/rpm/generic/zfs.spec.in index 8cab1c3d70bb..9e8fcedf41b6 100644 --- a/rpm/generic/zfs.spec.in +++ b/rpm/generic/zfs.spec.in @@ -100,7 +100,7 @@ %define __python_cffi_pkg python%{__python_pkg_version}-cffi %define __python_setuptools_pkg python%{__python_pkg_version}-setuptools %endif -%define __python_sitelib %(%{__python} -Esc "from distutils.sysconfig import get_python_lib; print(get_python_lib())") +%define __python_sitelib %(%{__python} -Esc "from distutils.sysconfig import get_python_lib; print(get_python_lib())" 2>/dev/null || %{__python} -Esc "import sysconfig; print(sysconfig.get_path('purelib'))") # By default python-pyzfs is enabled, with the exception of # RHEL 6 which by default uses Python 2.6 which is too old. diff --git a/tests/runfiles/sanity.run b/tests/runfiles/sanity.run index 3f9d82ddb18a..7258702f9c34 100644 --- a/tests/runfiles/sanity.run +++ b/tests/runfiles/sanity.run @@ -621,3 +621,7 @@ tags = ['functional', 'zvol', 'zvol_swap'] [tests/functional/zpool_influxdb] tests = ['zpool_influxdb'] tags = ['functional', 'zpool_influxdb'] + +[tests/functional/pyzfs] +tests = ['pyzfs_unittest'] +tags = ['functional', 'pyzfs'] diff --git a/tests/test-runner/bin/zts-report.py.in b/tests/test-runner/bin/zts-report.py.in index 3e3a66669df8..8286f0d5e3cc 100755 --- a/tests/test-runner/bin/zts-report.py.in +++ b/tests/test-runner/bin/zts-report.py.in @@ -61,15 +61,6 @@ known_reason = 'Known issue' # exec_reason = 'Test user execute permissions required for utilities' -# -# Some tests require a minimum python version of 3.5 and will be skipped when -# the default system version is too old. There may also be tests which require -# additional python modules be installed, for example python-cffi is required -# by the pyzfs tests. -# -python_reason = 'Python v3.5 or newer required' -python_deps_reason = 'Python modules missing: python-cffi' - # # Some tests require that the kernel supports renameat2 syscall. # @@ -246,7 +237,6 @@ maybe = { 'io/mmap': ['SKIP', fio_reason], 'largest_pool/largest_pool_001_pos': ['FAIL', known_reason], 'mmp/mmp_on_uberblocks': ['FAIL', known_reason], - 'pyzfs/pyzfs_unittest': ['SKIP', python_deps_reason], 'pool_checkpoint/checkpoint_discard_busy': ['FAIL', '11946'], 'projectquota/setup': ['SKIP', exec_reason], 'removal/removal_condense_export': ['FAIL', known_reason], diff --git a/tests/zfs-tests/tests/functional/pyzfs/pyzfs_unittest.ksh.in b/tests/zfs-tests/tests/functional/pyzfs/pyzfs_unittest.ksh.in index 4ca610e5f1e9..d4ae1681e382 100755 --- a/tests/zfs-tests/tests/functional/pyzfs/pyzfs_unittest.ksh.in +++ b/tests/zfs-tests/tests/functional/pyzfs/pyzfs_unittest.ksh.in @@ -16,6 +16,12 @@ . $STF_SUITE/include/libtest.shlib +if [ -n "$ASAN_OPTIONS" ]; then + export LD_PRELOAD=$(ldd "$(command -v zfs)" | awk '/libasan\.so/ {print $3}') + # ASan reports leaks in CPython 3.10 + ASAN_OPTIONS="$ASAN_OPTIONS:detect_leaks=false" +fi + # # DESCRIPTION: # Verify the libzfs_core Python test suite can be run successfully @@ -26,24 +32,6 @@ # verify_runnable "global" - -# Verify that the required dependencies for testing are installed. -@PYTHON@ -c "import cffi" 2>/dev/null -if [ $? -eq 1 ]; then - log_unsupported "python-cffi not found by Python" -fi - -# We don't just try to "import libzfs_core" because we want to skip these tests -# only if pyzfs was not installed due to missing, build-time, dependencies; if -# we cannot load "libzfs_core" due to other reasons, for instance an API/ABI -# mismatch, we want to report it. -@PYTHON@ -c ' -import pkgutil, sys -sys.exit(pkgutil.find_loader("libzfs_core") is None)' -if [ $? -eq 1 ]; then - log_unsupported "libzfs_core not found by Python" -fi - log_assert "Verify the nvlist and libzfs_core Python unittest run successfully" # NOTE: don't use log_must() here because it makes output unreadable