From b4f85647bd9140927e02cf1773802a6ad50c743c Mon Sep 17 00:00:00 2001 From: Simon McVittie <smcv@collabora.com> Date: Fri, 3 Apr 2020 15:27:04 +0100 Subject: [PATCH] scripts: Assert that we have the desired Python version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In Steam Runtime 1 'scout' and Steam Runtime 1½ 'heavy' SDK environments, we have a backport of python3.5 in order to run Meson, and meson.build automatically selects it if available. In newer environments like a developer's laptop, we expect to have a strictly newer Python version, like the python3.7 in Debian 10. One notable exception is that we only require Python 3.4+ for scripts that are meant to run on test machines or on non-developer Steam users' systems, which right now just means the test UI. This version was chosen because SteamOS 2 'brewmaster' and Ubuntu 14.04 'trusty' both have 3.4. Ubuntu 12.04 'precise' only has 3.2, but the Steam client doesn't actually work on 12.04 any more for orthogonal reasons. Signed-off-by: Simon McVittie <smcv@collabora.com> --- build-relocatable-install.py | 4 ++++ debian/control | 1 + debian/gitlab-ci.yml | 2 +- debian/tests/relocatable-install | 8 +++++++- pressure-vessel-test-ui | 2 ++ tests/cheap-copy.py | 5 +++++ tests/relocatable-install.py | 4 ++++ 7 files changed, 24 insertions(+), 2 deletions(-) diff --git a/build-relocatable-install.py b/build-relocatable-install.py index 6d6a0149e..3238f1ec0 100755 --- a/build-relocatable-install.py +++ b/build-relocatable-install.py @@ -30,6 +30,7 @@ import os import re import shutil import subprocess +import sys import tempfile try: @@ -659,6 +660,9 @@ def main(): if __name__ == '__main__': + assert sys.version_info >= (3, 5), \ + 'Python 3.5+ is required (configure with -Dpython=python3.5 ' \ + 'if necessary)' logging.basicConfig() main() diff --git a/debian/control b/debian/control index eb432da46..59eb42a4d 100644 --- a/debian/control +++ b/debian/control @@ -24,6 +24,7 @@ Multi-Arch: foreign Depends: bubblewrap, libcapsule-tools-relocatable, + python3 (>= 3.5) | python3.5, steam-runtime-tools-bin, ${misc:Depends}, ${shlibs:Depends}, diff --git a/debian/gitlab-ci.yml b/debian/gitlab-ci.yml index 42d869aed..552551ae0 100644 --- a/debian/gitlab-ci.yml +++ b/debian/gitlab-ci.yml @@ -153,7 +153,7 @@ build:scout: --archive "$(pwd)/_build" \ ${CI_ALLOW_MISSING_SOURCES:+--allow-missing-sources} \ ${NULL+} - prove -v ./tests/relocatable-install.py :: \ + prove -epython3.5 -v ./tests/relocatable-install.py :: \ "$(pwd)/_build/relocatable-install" fi diff --git a/debian/tests/relocatable-install b/debian/tests/relocatable-install index 5a623a1df..4543ad76d 100755 --- a/debian/tests/relocatable-install +++ b/debian/tests/relocatable-install @@ -20,7 +20,13 @@ apt-get -y install \ --output "${AUTOPKGTEST_TMP}/relocatable-install" \ --archive "${AUTOPKGTEST_TMP}" -./tests/relocatable-install.py "${AUTOPKGTEST_TMP}/relocatable-install" +if command -v python3.5; then + PYTHON=python3.5 +else + PYTHON=python3 +fi + +"$PYTHON" ./tests/relocatable-install.py "${AUTOPKGTEST_TMP}/relocatable-install" for archive in "${AUTOPKGTEST_TMP}"/*.tar.*; do echo "==== $(basename "$archive") ====" diff --git a/pressure-vessel-test-ui b/pressure-vessel-test-ui index dbb93d939..fe8f27ff2 100755 --- a/pressure-vessel-test-ui +++ b/pressure-vessel-test-ui @@ -43,6 +43,8 @@ from gi.repository import Gtk logger = logging.getLogger('pressure-vessel-test-ui') +assert sys.version_info >= (3, 4), 'Python 3.4+ is required for this script' + def tristate_environment(name): # type: (str) -> typing.Optional[bool] diff --git a/tests/cheap-copy.py b/tests/cheap-copy.py index c01f4ffe1..e44ed55d7 100755 --- a/tests/cheap-copy.py +++ b/tests/cheap-copy.py @@ -5,6 +5,7 @@ import os import subprocess +import sys import tempfile import unittest @@ -121,6 +122,10 @@ class TestCheapCopy(unittest.TestCase): if __name__ == '__main__': + assert sys.version_info >= (3, 5), \ + 'Python 3.5+ is required (configure with -Dpython=python3.5 ' \ + 'if necessary)' + try: from tap.runner import TAPTestRunner except ImportError: diff --git a/tests/relocatable-install.py b/tests/relocatable-install.py index 0110424ba..04897a368 100755 --- a/tests/relocatable-install.py +++ b/tests/relocatable-install.py @@ -232,6 +232,10 @@ def main(): if __name__ == '__main__': + assert sys.version_info >= (3, 5), \ + 'Python 3.5+ is required (configure with -Dpython=python3.5 ' \ + 'if necessary)' + main() # vi: set sw=4 sts=4 et: -- GitLab