Skip to content

Commit

Permalink
configure: do not use deprecated distutils Python module
Browse files Browse the repository at this point in the history
Problem: distutils has been deprecated in Python 3.12, but
AM_CHECK_PYMOD uses StrictVersion from distutils.version to aid in
version comparison of Python modules.

Follow the advice in

 https://peps.python.org/pep-0632/#migration-advice

And use packaging.version.Version instead. (LooseVersion was unused,
so need for a replacement)
  • Loading branch information
grondo committed Sep 19, 2023
1 parent a00922d commit d1d6092
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion config/am_check_pymod.m4
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ except:
sys.exit(0)
sys.exit(0)"], [prog="
import sys
from distutils.version import LooseVersion, StrictVersion
from packaging.version import Version
import $1
if not $2:
sys.exit(1)
Expand Down
10 changes: 5 additions & 5 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -249,24 +249,24 @@ AM_CHECK_PYMOD(cffi,
[AC_MSG_ERROR([could not find python module cffi, version 1.1+ required])]
)
AM_CHECK_PYMOD(yaml,
[StrictVersion(yaml.__version__) >= StrictVersion ('3.10.0')],
[Version(yaml.__version__) >= Version ('3.10.0')],
,
[AC_MSG_ERROR([could not find python module yaml, version 3.10+ required])]
)
AM_CHECK_PYMOD(jsonschema,
[StrictVersion(jsonschema.__version__) >= StrictVersion ('2.3.0')],
[Version(jsonschema.__version__) >= Version ('2.3.0')],
,
[AC_MSG_ERROR([could not find python module jsonschema, version 2.3.0+ required])]
)

AS_IF([test "x$enable_docs" != "xno"], [
AM_CHECK_PYMOD(sphinx,
[StrictVersion(sphinx.__version__) >= StrictVersion ('1.6.7')],
[Version(sphinx.__version__) >= Version ('1.6.7')],
[sphinx=true],
[sphinx=false; AC_MSG_WARN([could not find sphinx to generate docs, version 1.6.7+ required])]
)
AM_CHECK_PYMOD(docutils,
[StrictVersion(docutils.__version__) >= StrictVersion ('0.11.0')],
[Version(docutils.__version__) >= Version ('0.11.0')],
[docutils=true],
[docutils=false; AC_MSG_WARN([could not find docutils to generate docs, version 0.11.0+ required])]
)
Expand Down Expand Up @@ -316,7 +316,7 @@ AS_IF([test "x$enable_pylint" = "xyes"], [
AC_CHECK_PROG(PYLINT,[pylint],[pylint])
AS_IF([test "x$PYLINT" != "xpylint"], [AC_MSG_ERROR([No pylint found in PATH])])
AM_CHECK_PYMOD(pylint,
[StrictVersion(pylint.__version__) >= StrictVersion('1.8.4')],
[Version(pylint.__version__) >= Version('1.8.4')],
,
[AC_MSG_ERROR([could not find python module pylint, version 1.8.4+ required])]
)
Expand Down

0 comments on commit d1d6092

Please sign in to comment.