From f322f2baefdf3116f3687bdd28c29f55f5e4b105 Mon Sep 17 00:00:00 2001 From: propelluo Date: Tue, 31 Mar 2026 15:12:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8C=87=E5=AE=9A=E4=BD=BF=E7=94=A8python3.12?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: propelluo --- libfuse/tst-build.sh | 54 +++++++++----------------------------------- 1 file changed, 11 insertions(+), 43 deletions(-) diff --git a/libfuse/tst-build.sh b/libfuse/tst-build.sh index a22325f..146dee0 100755 --- a/libfuse/tst-build.sh +++ b/libfuse/tst-build.sh @@ -18,12 +18,10 @@ build_dep_pkg_list=" make meson ninja-build + python3.12 python3 python3-devel python3-pip - python3-pytest - python3-packaging - python3-py fuse3-devel pkgconf-pkg-config " @@ -38,8 +36,8 @@ ensure_meson_version() { return 0 fi - echo "meson version $current < $required, installing via pip..." - pip3 install -i https://mirrors.tencent.com/pypi/simple/ \ + echo "meson version $current < $required, installing via python3.12 pip..." + python3.12 -m pip install -i https://mirrors.tencent.com/pypi/simple/ \ --trusted-host mirrors.tencent.com \ "meson>=$required" || return 1 @@ -48,48 +46,18 @@ ensure_meson_version() { echo "meson upgraded to $current via pip" } -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 [ "$current_minor" -ge "$required_minor" ]; then - echo "system python3 is 3.$current_minor >= 3.$required_minor, OK" +ensure_pytest() { + if python3.12 -m pytest --version &>/dev/null 2>&1; then + echo "python3.12 pytest ready, OK" return 0 fi - 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 "=== 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/ \ + echo "=== installing pytest for python3.12 ===" + python3.12 -m ensurepip --default-pip 2>/dev/null || true + python3.12 -m pip install -i https://mirrors.tencent.com/pypi/simple/ \ --trusted-host mirrors.tencent.com \ pytest packaging || return 1 - echo "pytest installed for $pybin successfully" + echo "python3.12 pytest ready" } build_tool() { @@ -148,7 +116,7 @@ main() { done ensure_meson_version || return 1 - ensure_python_version || return 1 + ensure_pytest || return 1 mkdir -p "$g_install_dir" if build_tool; then -- Gitee