Autofoo test for maximum version of Python

I am trying to get autofoo to check the maximum version of Python, not the minimum. Example:

AC_REQUIRE([AM_PATH_PYTHON([2.7])])

... will check for Python> = 2.7 and will probably appear with / usr / bin / python 3. However, I want it to return nothing more than python2.7.

Is there an easy way to do this? I asked, and so far the best answer I have received is to "rewrite the macro."

Thanks in advance!

+3
source share
3 answers

1). Add toacinclude.m4

`# my_CHECK_MAJOR_VERSION(VARIABLE, VERSION, [ACTION-IF-TRUE], [ACTION-IF-FALSE])`  
`# ---------------------------------------------------------------------------`  
`# Run ACTION-IF-TRUE if the VAR has a major version >= VERSION.`  
`# Run ACTION-IF-FALSE otherwise.`  
AC_DEFUN([my_CHECK_MAJOR_VERSION],  
[AC_MSG_CHECKING([whether $1 $$1 major version == $2])  
case $$1 in  
$2*)  
  AC_MSG_RESULT([yes])  
  ifelse([$3], [$3], [:])  
  ;;  
*)  
  AC_MSG_RESULT([no])  
  ifelse([$4], , [AC_MSG_ERROR([$$1 differs from $2])], [$4])  
  ;;  
esac])  

2.) Add to zconfigure.inz

my_CHECK_MAJOR_VERSION([PYTHON_VERSION], [2])  

3.) aclocal, automake,autoconf

What is it.

+2
source

The version argument AM_PATH_PYTHONis optional. If python is required, name it like this:

AM_PATH_PYTHON

, :

AM_PATH_PYTHON(,, [:])

AM_PATH_PYTHON $PYTHON_VERSION sys.version[:3], .

+2

An alternative solution might be to set the default for _AM_PYTHON_INTERPRETER_LIST to include only Python 2 binaries.

0
source

Source: https://habr.com/ru/post/1783938/


All Articles