Frederic Berat wrote:
On Sun, Jan 14, 2024 at 3:13 AM Karl Berry <k...@freefriends.org> wrote:
With Python 3.12 out now, and 3.13 out in ~9 months, the existing
runway
is running out. Bump up to 3.20 for the next Automake release.
Applied, thanks.
Not proposing to try anything for our upcoming release, but I wonder if
there is some more general way to handle Python versions? We don't have
to laboriously list every possible version for anything else.
That may not be the most clever way to do it, but you can probably build
the list dynamically at least, with something like (untested):
pythons="python python2 python3"
for i in {20..0};do pythons="$pythons python3.$i";done
for i in {7..0};do pythons="$pythons python2.$i";done
m4_define_default([_AM_PYTHON_INTERPRETER_LIST], [$pythons])
The {20..0} is a syntax unfamiliar to me, yet even Bash 3 has it...
interesting. Also interesting that it is brace expansion, so you could do:
pythons=`echo python{,2,3} python3.{20..0} python2.{7..0}`
The use of command substitution and echo works around the small catch
that brace expansion does not occur inside double quotes. However,
brace expansion does occur inside a command substitution inside double
quotes, but the result of command substitution as a variable assignment
is not subject to word splitting, so the double quotes can be omitted.
I wonder if all shells that allow {20..0} also allow $() for command
substitution, or if this code must be valid in shells that predate POSIX...
Oh wait, after reviewing the thread, I find that this is in m4 macros.
Yes, it could be dynamically produced, but not using shell iteration
constructs or expansions. Macros in m4 are allowed to use tail
recursion, and counted iteration is possible to implement (and autoconf
provides some macros for it).
The required quoting is "fun" and Automake may complain that this
appears to be underquoted: (untested; the fine details of the quoting
may be wrong)
m4_define_default([_AM_PYTHON_INTERPRETER_LIST], dnl
[python python2 python3] dnl
m4_for(i, 20, 0, -1, [ python3.i]) dnl
m4_for(i, 7, 0, -1, [ python2.i]))
As written, this might lead to some extra spaces in the interpreter
list, but the shell will ignore those when running configure.
-- Jacob