From e871e928b3a95a88244c6b09c13e027137d4d9f5 Mon Sep 17 00:00:00 2001 From: Mauro Druwel <46003176+MauroDruwel@users.noreply.github.com> Date: Sat, 9 Aug 2025 19:46:33 +0200 Subject: [PATCH] Update install.sh --- install.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/install.sh b/install.sh index 43ccd2d..8a8c428 100644 --- a/install.sh +++ b/install.sh @@ -43,8 +43,23 @@ if [ "${systemName}" = "Raspberry Pi" ] || [ "${systemName}" = "Orange Pi" ] || installAptPackages "libatlas-base-dev libopenblas-dev libblas-dev" installAptPackages "liblapack-dev patchelf gfortran" + # Fix for lxml build failures on aarch64 when installing PaddleOCR dependencies. + # lxml>=5/6 may be built from source if no wheel is available on the mirror. + # Ensure system headers exist so a source build can succeed, and preinstall a + # compatible binary lxml for Python 3.8 to avoid building from source. + installAptPackages "libxml2-dev libxslt1-dev zlib1g-dev pkg-config" + if [ "$oneStepPIP" = false ]; then installPythonPackagesByName "Cython six requests wheel pyyaml" + # Prefer a prebuilt wheel for Python 3.8 to avoid source builds on aarch64 mirrors. + if [ "${pythonVersion}" = "3.8" ]; then + installPythonPackagesByName "lxml==4.9.4" "lxml XML/HTML parser (preinstalled to avoid source build)" + fi + else + # When doing one-step pip, still try to mitigate lxml builds for Py3.8 + if [ "${pythonVersion}" = "3.8" ]; then + installPythonPackagesByName "lxml==4.9.4" "lxml XML/HTML parser (preinstalled to avoid source build)" + fi fi "$venvPythonCmdPath" -m pip show paddlepaddle >/dev/null 2>/dev/null @@ -69,6 +84,17 @@ if [ "${systemName}" = "Raspberry Pi" ] || [ "${systemName}" = "Orange Pi" ] || elif [ "${systemName}" = "Jetson" ]; then + # Ensure system headers for lxml in case a source build is needed by PaddleOCR deps + write "Ensuring system headers for lxml are present..." $color_info + sudo apt-get update -y >/dev/null 2>/dev/null + installAptPackages "libxml2-dev libxslt1-dev zlib1g-dev pkg-config" + writeLine "Done" $color_success + + # For Python 3.8 on Jetson, preinstall a binary lxml to avoid building from source on aarch64 + if [ "${pythonVersion}" = "3.8" ]; then + installPythonPackagesByName "lxml==4.9.4" "lxml XML/HTML parser (preinstalled to avoid source build)" + fi + case "$pythonVersion" in "3.6") wheel_file="paddlepaddle_gpu-2.4.1-cp36-cp36m-linux_aarch64.whl" @@ -159,6 +185,11 @@ if [ "$os" = "macos" ]; then else installPythonPackagesByName "opencv-python" "OpenCV, the Computer Vision library for Python" fi + + # Preinstall lxml to avoid source builds on macOS if PaddleOCR pulls it in + if [ "${pythonVersion}" = "3.8" ]; then + installPythonPackagesByName "lxml==4.9.4" "lxml XML/HTML parser (preinstalled to avoid source build)" + fi fi if [ "${moduleInstallErrors}" = "" ]; then