Skip to content

Commit

Permalink
CI/RLS: upgrade to libspatialindex-2.0.0 (#316)
Browse files Browse the repository at this point in the history
* Upgrade libspatialindex from 1.9.3 to 2.0.0
* Remove the unneeded ci/CMakeLists.txt
* Use cmake install, removing the unneeded lib subdirs
* Remove the soversion number and symlinks for the library name (via CMAKE_PLATFORM_NO_VERSIONED_SONAME=ON)
* It turns out the cibuildwheel tests on different python versions (via tox) was misleading, as it was not testing the built-wheel but the local source tree and sidx library build. This is fixed with `pytest --import-mode=importlib` 
* Consequently, the musllinux wheels on PyPI are "broken". This is resolved by setting rpath for libspatialindex described next.
* Use `CMAKE_INSTALL_RPATH` only for macOS. On Linux, `$ORIGIN` seems to confuse auditwheel and prevents creation of `Rtree.libs`. It want's LD_LIBRARY_PATH set while repairing the wheel. But the `$ORIGIN`  rpath is still needed for musllinux, so manually add this last step in repair_wheel.py
* Simplify copying directory trees in setup.py with copy_tree
  • Loading branch information
mwtoews authored Jul 9, 2024
1 parent bb9925a commit 86d4e28
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 324 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ jobs:
matrix:
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
sidx-version: ['1.8.5', '1.9.3']
# test oldesst and newest libspatialindex versions
sidx-version: ['1.8.5', '2.0.0']
exclude:
- os: 'macos-latest'
- sidx-version: '1.8.5'
Expand Down
237 changes: 0 additions & 237 deletions ci/CMakeLists.txt

This file was deleted.

63 changes: 24 additions & 39 deletions ci/install_libspatialindex.bash
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,15 @@
set -xe

# A simple script to install libspatialindex from a Github Release
VERSION=1.9.3
SHA256=63a03bfb26aa65cf0159f925f6c3491b6ef79bc0e3db5a631d96772d6541187e
VERSION=2.0.0
SHA256=8caa4564c4592824acbf63a2b883aa2d07e75ccd7e9bf64321c455388a560579

# where to copy resulting files
# this has to be run before `cd`-ing anywhere
libtarget() {
install_prefix() {
OURPWD=$PWD
cd "$(dirname "$0")"
mkdir -p ../rtree/lib
cd ../rtree/lib
arr=$(pwd)
cd "$OURPWD"
echo $arr
}

headertarget() {
OURPWD=$PWD
cd "$(dirname "$0")"
mkdir -p ../rtree/include
cd ../rtree/include
cd ../rtree
arr=$(pwd)
cd "$OURPWD"
echo $arr
Expand All @@ -36,48 +25,44 @@ scriptloc() {
}
# note that we're doing this convoluted thing to get
# an absolute path so mac doesn't yell at us
LIBTARGET=`libtarget`
HEADERTARGET=`headertarget`
INSTALL_PREFIX=`install_prefix`
SL=`scriptloc`

rm $VERSION.zip || true
curl -L -O https://github.com/libspatialindex/libspatialindex/archive/$VERSION.zip
rm -f $VERSION.zip
curl -LOs --retry 5 --retry-max-time 120 https://github.com/libspatialindex/libspatialindex/archive/${VERSION}.zip

# check the file hash
echo "${SHA256} ${VERSION}.zip" | sha256sum -c -

rm -rf "libspatialindex-${VERSION}" || true
rm -rf "libspatialindex-${VERSION}"
unzip -q $VERSION
cd libspatialindex-${VERSION}

mkdir build
cd build

cp "${SL}/CMakeLists.txt" ..

printenv

if [ "$(uname)" == "Darwin" ]; then
CMAKE_ARGS="-DCMAKE_OSX_ARCHITECTURES=${ARCHFLAGS##* }"
CMAKE_ARGS="-D CMAKE_OSX_ARCHITECTURES=${ARCHFLAGS##* } \
-D CMAKE_INSTALL_RPATH=@loader_path"
fi

cmake -DCMAKE_BUILD_TYPE=Release ${CMAKE_ARGS} ..
cmake ${CMAKE_ARGS} \
-D CMAKE_BUILD_TYPE=Release \
-D BUILD_SHARED_LIBS=ON \
-D CMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
-D CMAKE_INSTALL_LIBDIR=lib \
-D CMAKE_PLATFORM_NO_VERSIONED_SONAME=ON \
..
make -j 4

# copy built libraries relative to path of this script
# -d means copy links as links rather than duplicate files
# macos uses "bsd cp" and needs special handling
if [ "$(uname)" == "Darwin" ]; then
# change the rpath in the dylib to point to the same directory
install_name_tool -change @rpath/libspatialindex.6.dylib @loader_path/libspatialindex.dylib bin/libspatialindex_c.dylib
# copy the dylib files to the target director
cp bin/libspatialindex.dylib $LIBTARGET
cp bin/libspatialindex_c.dylib $LIBTARGET
cp -r ../include/* $HEADERTARGET
else
cp -L bin/* $LIBTARGET
cp -r ../include/* $HEADERTARGET
fi
make install

# remove unneeded extras in lib
rm -rfv ${INSTALL_PREFIX}/lib/cmake
rm -rfv ${INSTALL_PREFIX}/lib/pkgconfig

ls $LIBTARGET
ls -R $HEADERTARGET
ls -R ${INSTALL_PREFIX}/lib
ls -R ${INSTALL_PREFIX}/include
30 changes: 17 additions & 13 deletions ci/install_libspatialindex.bat
Original file line number Diff line number Diff line change
@@ -1,29 +1,33 @@
python -c "import sys; print(sys.version)"

set SIDX_VERSION=1.9.3
set SIDX_VERSION=2.0.0

curl -OL "https://github.com/libspatialindex/libspatialindex/archive/%SIDX_VERSION%.zip"
curl -LO --retry 5 --retry-max-time 120 "https://github.com/libspatialindex/libspatialindex/archive/%SIDX_VERSION%.zip"

tar xvf "%SIDX_VERSION%.zip"

REM unzip 1.9.3.zip
REM copy %~dp0\CMakeLists.txt libspatialindex-1.9.3\CMakeLists.txt
cd libspatialindex-%SIDX_VERSION%

mkdir build
cd build

pip install ninja

cmake -D CMAKE_BUILD_TYPE=Release -G Ninja ..
set INSTALL_PREFIX=%~dp0\..\rtree

ninja
cmake -G Ninja ^
-D CMAKE_BUILD_TYPE=Release ^
-D BUILD_SHARED_LIBS="ON" ^
-D CMAKE_INSTALL_PREFIX="%INSTALL_PREFIX%" ^
-D CMAKE_INSTALL_BINDIR=lib ^
-D CMAKE_INSTALL_LIBDIR=libdir ^
..

mkdir %~dp0\..\rtree\lib
copy bin\*.dll %~dp0\..\rtree\lib
xcopy /S ..\include\* %~dp0\..\rtree\include\
rmdir /Q /S bin
ninja install

dir %~dp0\..\rtree\
dir %~dp0\..\rtree\lib
dir %~dp0\..\rtree\include
:: remove unneeded libdir
rmdir %INSTALL_PREFIX%\libdir /s /q

dir %INSTALL_PREFIX%
dir %INSTALL_PREFIX%\lib
dir %INSTALL_PREFIX%\include /s
Loading

0 comments on commit 86d4e28

Please sign in to comment.