Subject: bug#30556: closed (Re: bug#30556: [PATCH] Python tests should run with multiple python versions)

From: [email-masked] (GNU bug Tracking System)
Date: Fri, 07 Jul 2023 01:29:02 +0000

Your bug report

#30556: Python tests should run with multiple python versions

which was filed against the automake package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
30556: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=30556
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#30556: [PATCH] Python tests should run with multiple python versions
From: Karl Berry <[email-masked]>
To: [email-masked], [email-masked]
Cc: [email-masked]
Date: Thu, 6 Jul 2023 19:28:16 -0600
List-Id: <debbugs-submit.debbugs.gnu.org>

Mathieu and all - back on this report from 2018:
https://bugs.gnu.org/30556.

Mike (Frysinger) and Bogdan both made various patches that together
have, I think, fixed all these issues. Thanks x 2 :).

Here is the patch from Bogdan that I've just pushed to finish it.
Closing, with fingers crossed. --karl

2023-07-06  Bogdan  <[email-masked]>

python: generalize tests.

This change finishes fixing https://bugs.gnu.org/30556.

* t/python-prefix.sh: use $PYTHON if set, not hardwiring "python".
* t/python-virtualenv.sh (get-pyexecdir): new make target;
use it instead of hardwiring $py_site.
diff --git a/t/python-prefix.sh b/t/python-prefix.sh
index df15e4300..766f47258 100644
--- a/t/python-prefix.sh
+++ b/t/python-prefix.sh
@@ -43,7 +43,12 @@ echo-python-exec-prefix:
 	@echo $(PYTHON_EXEC_PREFIX)
 END

-py_version=$(python -c 'import sys; print("%u.%u" % sys.version_info[:2])')
+if test -z "$PYTHON"; then
+  py_exec=python
+else
+  py_exec=$PYTHON
+fi
+py_version=$("$py_exec" -c 'import sys; print("%u.%u" % sys.version_info[:2])')
 py_inst_site=inst/lib/python$py_version/site-packages
 py_instexec_site=instexec/lib/python$py_version/site-packages

diff --git a/t/python-virtualenv.sh b/t/python-virtualenv.sh
index ae5d96ad6..b06964b90 100644
--- a/t/python-virtualenv.sh
+++ b/t/python-virtualenv.sh
@@ -100,6 +100,8 @@ test-run:
 	python -c 'from am_foo import foo_func; assert (foo_func () == 12345)'
 	python -c 'from am_virtenv import old_am; assert (old_am () == "AutoMake")'
 all-local: debug
+get-pyexecdir:
+	@echo $(pyexecdir)
x END

 cat > am_foo.py << 'END'
@@ -127,8 +129,8 @@ check_install ()
   py_installed "$py_site"/am_foo.pyc
   py_installed "$py_site"/am_virtenv/__init__.py
   py_installed "$py_site"/am_virtenv/__init__.pyc
-  test -f      "$py_site"/libquux.a
-  test -f      "$py_site"/am_virtenv/libzardoz.a
+  test -f      "$($MAKE get-pyexecdir ${1+"$@"})"/libquux.a
+  test -f      "$($MAKE get-pyexecdir ${1+"$@"})"/am_virtenv/libzardoz.a
 }

 check_uninstall ()
@@ -139,8 +141,8 @@ check_uninstall ()
   py_installed --not "$py_site"/am_foo.pyc
   test ! -e          "$py_site"/am_virtenv/__init__.py
   py_installed --not "$py_site"/am_virtenv/__init__.pyc
-  test ! -e          "$py_site"/libquux.a
-  test ! -e          "$py_site"/am_virtenv/libzardoz.a
+  test ! -e          "$($MAKE get-pyexecdir ${1+"$@"})"/libquux.a
+  test ! -e          "$($MAKE get-pyexecdir ${1+"$@"})"/am_virtenv/libzardoz.a
 }

 $ACLOCAL

compile finished at Thu Jul  6 18:27:36 2023

Subject: Python tests should run with multiple python versions
From: Mathieu Lirzin <[email-masked]>
To: [email-masked]
Date: Tue, 20 Feb 2018 21:39:14 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

The test suite applies its tests only with the ‘python’ executable which
is an issue since on most systems it corresponds to ‘python2’, and for
systems having only ‘python3’ the tests are simply skipped.

Moreover, when ‘python’ corresponds to ‘python3’ as it is the case on
distributions not following PEP394 [1] like Arch Linux, the test suite
fails (See attached log).

[1] https://www.python.org/dev/peps/pep-0394/

-- 
Mathieu Lirzin
GPG: F2A3 8D7E EB2B 6640 5761  070D 0ADE E100 9460 4D37