bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gnulib-tool: Use the Python implementation by default


From: Pádraig Brady
Subject: Re: gnulib-tool: Use the Python implementation by default
Date: Sat, 27 Apr 2024 18:53:45 +0100
User-agent: Mozilla Thunderbird

On 27/04/2024 14:32, Bruno Haible wrote:
Hi Pádraig,

+    if (python3 --version) >/dev/null 2>/dev/null \
+       && case `python3 --version 2>&1` in
+            Python\ 3.[0-6] | Python\ 3.[0-6].*) false ;;
+            Python\ 3.*) true ;;
+            *) false ;;
+          esac; then

It may be preferable to state the supported version directly,

I wanted a short warning message. In most cases the absence of python3
will be the problem. It should be rare than anyone still uses an old
version.

and replace the above 6 lines with:

    if python3 -c 'import sys; sys.exit(not sys.version_info >= (3,7))' 
2>/dev/null; then

Thanks for the hint. I admit that I did not think at it. But is it
actually better?

Only that's it's shorter, and more directly states the supported version.
No biggie, just a suggestion.


Are there alternative Python implementations, which could be installed under
the name 'python3'?

So this is a general question, unrelated to my particular suggestion.
I think the version check is fine, and should be quite independent from python 
implementation.
Possible drop in replacements for the python3 command might be ...

... pypy, which separates its implementation version from python language 
support version:
$ dnf install pypy3
$ pypy3

>>>> sys.pypy_version_info
sys.pypy_version_info(major=7, minor=3, micro=15, releaselevel='final', 
serial=0)
>>>> sys.version_info
sys.version_info(major=3, minor=10, micro=13, releaselevel='final', serial=0)

... cinder, which is very close to cpython ...
$ dnf install docker
$ sudo systemctl start docker
$ sudo setfacl --modify user:$USER:rw /var/run/docker.sock
$ docker run -it --rm ghcr.io/facebookincubator/cinder-runtime:cinder-3.10

Python 3.10.5+cinder (main, Apr 26 2024, 22:00:58) [GCC 10.3.1 20210422 (Red 
Hat 10.3.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.version_info
sys.version_info(major=3, minor=10, micro=5, releaselevel='final', serial=0)


There are no other real contenders for drop in python 3 replacement.
For example codon or mojo are not designed as drop in replacements.
I expect any future drop in replacements would follow the model above.

Note also that your snippet would not replace the 6 lines of code, only the
last 5 lines, because with Solaris 10 /bin/sh your snippet produces the
diagnostic
   python3: not found

Out of interest, I dug out an old dsa ssh key from a backup, to get access to a 
solaris 10 machine.
Testing shows that a subshell does avoid that issue, so the following works:

  if (python3 -c 'import sys; sys.exit(not sys.version_info >= (3,7))') 
2>/dev/null; then

cheers,
Pádraig



reply via email to

[Prev in Thread] Current Thread [Next in Thread]