Tcl text processing: Python 3.10 variants

Joshua Root jmr at macports.org
Mon Mar 21 20:13:24 UTC 2022


On 2022-3-22 06:51 , Zhenfu Shi wrote:
> Hi all,
> 
> I’m trying to add Python 3.10 variant to a few ports, but one of them (mpv) uses `set python_branch [join [split ${ver} {}] ".”]` to convert branch strings to version strings, resulting in “310” being converted to “3.1.0”. Can anyone advise how to change this line so it gives “3.10” without breaking compatibility with older Python versions?

Something like this works:

[string index $ver 0].[string range $ver 1 end]

However, it would be more reliable for mpv to start with versions 
containing dots and strip them out when needed; something like:

set python.versions [list 3.8 3.9 3.10]
foreach ver ${python.versions} {
     set ver_nodot [string map {. ""} $ver]
     ...
}

- Josh


More information about the macports-dev mailing list