From 40a7373fecba395ea8645b79b28556489509f7f2 Mon Sep 17 00:00:00 2001 From: Vojta Tuma Date: Mon, 17 Feb 2025 10:41:20 +0100 Subject: [PATCH] Python wheel: add qhull dep --- python_wrapper/buildconfig | 2 +- python_wrapper/post-build.sh | 10 ++++++++++ python_wrapper/post-compile.sh | 6 +++++- python_wrapper/pre-compile.sh | 21 +++++++++++++++++++++ 4 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 python_wrapper/post-build.sh create mode 100644 python_wrapper/pre-compile.sh diff --git a/python_wrapper/buildconfig b/python_wrapper/buildconfig index e25f910e7..3c0e54650 100644 --- a/python_wrapper/buildconfig +++ b/python_wrapper/buildconfig @@ -11,6 +11,6 @@ # TODO we duplicate information -- pyproject.toml's `name` and `packages` are derivable from $NAME and must stay consistent NAME="atlas" -CMAKE_PARAMS="-Deckit_ROOT=/tmp/atlas/prereqs/eckitlib" # -DENABLE_TESSELATION=1" # TODO tesselation requires Qhull in precompile +CMAKE_PARAMS="-Deckit_ROOT=/tmp/atlas/prereqs/eckitlib -DQhull_ROOT=/tmp/qhull/target -DENABLE_TESSELATION=1" PYPROJECT_DIR="python_wrapper" DEPENDENCIES='["eckitlib"]' diff --git a/python_wrapper/post-build.sh b/python_wrapper/post-build.sh new file mode 100644 index 000000000..f2357778e --- /dev/null +++ b/python_wrapper/post-build.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +# NOTE auditwheel is problematic since it changes libnames -- all is well from +# the pov # of this very package's libs, but subsequent packages compiled with +# this as a dependency end up not working +# if [ "$(uname)" != "Darwin" ] ; then +# auditwheel repair -w /tmp/eccodes/auditwheel /tmp/eccodes/build/wheel/*whl +# fi + +# TODO macos we actually need to use the `otool` here diff --git a/python_wrapper/post-compile.sh b/python_wrapper/post-compile.sh index 7c3e11707..f815aa78c 100644 --- a/python_wrapper/post-compile.sh +++ b/python_wrapper/post-compile.sh @@ -1,6 +1,10 @@ #!/bin/bash + +# NOTE we need to strip here because vanilla atlas is for some reason huge +# We don't strip in general since that has caused some linker problem downstream, but here so far seems to work + if [ "$(uname)" != "Darwin" ] ; then strip --strip-unneeded /tmp/atlas/target/atlas/lib64/libatlas.so else - strip --strip-unneeded /tmp/atlas/target/atlas/lib/libatlas.so # TODO test this + strip --strip-unneeded -x /tmp/atlas/target/atlas/lib/libatlas.dylib fi diff --git a/python_wrapper/pre-compile.sh b/python_wrapper/pre-compile.sh new file mode 100644 index 000000000..cae86c09f --- /dev/null +++ b/python_wrapper/pre-compile.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# the procedure for adding a new ext dependency to be bundled in here: +# - add git checkout, compile, etc +# - ensure the version ends up in python_wrapper/src/versions.txt +# - ensure the licence ends up in python_wrapper/src/copying/, and fname is referenced in copying/list.json +# - ensure the .so ends up in target/lib64/ with the expected libname +# - validate that the resulting wheel contains all the above +# additionally, make sure this script is aligned with /buildscripts/compile.sh and /buildscripts/wheel-linux.sh, +# in particular when it comes to install targets and package data, etc + +bash ./tools/install-qhull.sh --prefix /tmp/qhull/target +# copy the libs, instead of having auditwheel done it later. This is a bit risky because cmake will later write in this +# very directory... but it works +cp /tmp/qhull/target/lib/libqhull_r.* /tmp/atlas/target/atlas/lib64/ + +wget https://raw.githubusercontent.com/qhull/qhull/blob/master/COPYING.txt -O python_wrapper/src/copying/libqhull.txt +echo '{"libqhull_r": {"path": "copying/libqhull.txt", "home": "https://github.com/qhull/qhull"}}' > python_wrapper/src/copying/list.json + + +