From cf0e492279f5744bf30a2a93983da80644a538a9 Mon Sep 17 00:00:00 2001 From: 0x3878f <1757941716@qq.com> Date: Sun, 29 Dec 2024 15:31:05 +0000 Subject: [PATCH] fix: remove auditwheel repair due to libpaddle && add PYTHON_LIBRARY on non-Windows platforms --- .github/workflows/scripts/entrypoint.sh | 31 ++++++++++++++----------- setup.py | 6 +++++ 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/.github/workflows/scripts/entrypoint.sh b/.github/workflows/scripts/entrypoint.sh index a2edaba57..d805c0dd7 100644 --- a/.github/workflows/scripts/entrypoint.sh +++ b/.github/workflows/scripts/entrypoint.sh @@ -61,20 +61,25 @@ export PIP_EXTRA_INDEX_URL="https://www.paddlepaddle.org.cn/packages/nightly/cpu # Build Paddle2ONNX wheels $PYTHON_COMMAND -m build --wheel || { echo "Building wheels failed."; exit 1; } -# Bundle external shared libraries into the wheels -# find -exec does not preserve failed exit codes, so use an output file for failures -failed_wheels=$PWD/failed-wheels -rm -f "$failed_wheels" -find . -type f -iname "*-linux*.whl" -exec sh -c "auditwheel repair '{}' -w \$(dirname '{}') --plat '${PLAT}' || { echo 'Repairing wheels failed.'; auditwheel show '{}' >> '$failed_wheels'; }" \; +# ============================================================================ +# Due to libpaddle’s limitations, it can only maintain a restricted platform tag of ‘linux_x86_64’. +# ============================================================================ +# export LD_LIBRARY_PATH=/opt/python/${PY_VER}/lib/python${PY_VERSION}/site-packages/paddle/base/:$LD_LIBRARY_PATH +# export LD_LIBRARY_PATH=/opt/python/${PY_VER}/lib/python${PY_VERSION}/site-packages/paddle/libs/:$LD_LIBRARY_PATH +# # Bundle external shared libraries into the wheels +# # find -exec does not preserve failed exit codes, so use an output file for failures +# failed_wheels=$PWD/failed-wheels +# rm -f "$failed_wheels" +# find . -type f -iname "*-linux*.whl" -exec sh -c "auditwheel repair '{}' -w \$(dirname '{}') --plat '${PLAT}' || { echo 'Repairing wheels failed.'; auditwheel show '{}' >> '$failed_wheels'; }" \; -if [[ -f "$failed_wheels" ]]; then - echo "Repairing wheels failed:" - cat failed-wheels - exit 1 -fi +# if [[ -f "$failed_wheels" ]]; then +# echo "Repairing wheels failed:" +# cat failed-wheels +# exit 1 +# fi -# Remove useless *-linux*.whl; only keep manylinux*.whl -rm -f dist/*-linux*.whl +# # Remove useless *-linux*.whl; only keep manylinux*.whl +# rm -f dist/*-linux*.whl echo "Successfully build wheels:" -find . -type f -iname "*manylinux*.whl" +# find . -type f -iname "*manylinux*.whl" # uncomment this line when libpaddle supports manylinux2014 diff --git a/setup.py b/setup.py index 3d59a7926..ac91daa62 100644 --- a/setup.py +++ b/setup.py @@ -138,6 +138,12 @@ def run(self): else: cmake_args.extend(["-A", "Win32", "-T", "host=x86"]) cmake_args.extend(["-G", "Visual Studio 16 2019"]) + else: + cmake_args.append( + "-DPYTHON_LIBRARY={}".format( + sysconfig.get_python_lib(standard_lib=True) + ) + ) if "CMAKE_ARGS" in os.environ: extra_cmake_args = shlex.split(os.environ["CMAKE_ARGS"]) # prevent crossfire with downstream scripts