From 2d92432363cbd3e2d737f2cc2d173004fa7e71c7 Mon Sep 17 00:00:00 2001 From: propelluo Date: Tue, 31 Mar 2026 14:28:55 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E4=BE=8B=E8=BF=90=E8=A1=8C=E6=9C=80?= =?UTF-8?q?=E4=BD=8E=E9=9C=80=E8=A6=81python3.8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: propelluo --- libfuse/tst-build.sh | 49 ++++++++++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 13 deletions(-) diff --git a/libfuse/tst-build.sh b/libfuse/tst-build.sh index 80de80c..a22325f 100755 --- a/libfuse/tst-build.sh +++ b/libfuse/tst-build.sh @@ -48,25 +48,48 @@ ensure_meson_version() { echo "meson upgraded to $current via pip" } -ensure_pytest_deps() { - local pyver - pyver=$(python3 -c 'import sys; print(sys.version_info[:2])' 2>/dev/null) +ensure_python_version() { + local required_minor=8 + local current_minor + current_minor=$(python3 -c 'import sys; print(sys.version_info.minor)' 2>/dev/null || echo "0") - if python3 -c 'import importlib_metadata' 2>/dev/null; then - echo "importlib_metadata already available, OK" + if [ "$current_minor" -ge "$required_minor" ]; then + echo "system python3 is 3.$current_minor >= 3.$required_minor, OK" return 0 fi - if python3 -c 'import importlib.metadata' 2>/dev/null; then - echo "importlib.metadata (stdlib) available, OK" - return 0 + echo "system python3 is 3.$current_minor < 3.$required_minor, need higher version" + + local pybin="" + for ver in 39 38; do + local dotver="3.${ver#3}" # 39->3.9, 38->3.8 + if command -v "python${dotver}" &>/dev/null; then + pybin="python${dotver}" + echo "found existing $pybin" + break + fi + echo "trying to install python${ver}..." + if yum install -y "python${ver}" 2>/dev/null; then + hash -r + if command -v "python${dotver}" &>/dev/null; then + pybin="python${dotver}" + echo "installed $pybin successfully" + break + fi + fi + done + + if [ -z "$pybin" ]; then + echo "ERROR: failed to install python >= 3.$required_minor" + return 1 fi - echo "Python $pyver lacks importlib.metadata, installing backport via pip..." - pip3 install -i https://mirrors.tencent.com/pypi/simple/ \ + echo "=== installing pytest and dependencies for $pybin ===" + "$pybin" -m ensurepip --default-pip 2>/dev/null || true + "$pybin" -m pip install -i https://mirrors.tencent.com/pypi/simple/ \ --trusted-host mirrors.tencent.com \ - 'importlib-metadata<5.0' 'typing_extensions>=3.6.4' 'zipp>=0.5' || return 1 - echo "importlib-metadata installed successfully" + pytest packaging || return 1 + echo "pytest installed for $pybin successfully" } build_tool() { @@ -125,7 +148,7 @@ main() { done ensure_meson_version || return 1 - ensure_pytest_deps || return 1 + ensure_python_version || return 1 mkdir -p "$g_install_dir" if build_tool; then -- Gitee