Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
try newer version of the build script, fingers crossed
Browse files Browse the repository at this point in the history
  • Loading branch information
chrstnbwnkl committed Jun 21, 2024
1 parent 9644f23 commit 8208d4d
Showing 1 changed file with 31 additions and 39 deletions.
70 changes: 31 additions & 39 deletions scripts/build_linux_do.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@ set -e

cd valhalla-py

# this circumvents when I locally clone valhalla but try to reset the patches in the container
git config --global --add safe.directory /valhalla-py/upstream

# locally extend the PATH to avoid problems
PATH="${PATH}:/opt/_internal/cpython-3.10.11/bin"

# install conan
apt-get update
apt-get install -y python3-pip
pip3 install conan
python3.10 -m pip install --upgrade pip "conan<2.0.0"
# NOTE, those paths will likely need to get updated over time
conan config set "storage.path=$PWD/upstream/conan_data"
conan install --install-folder conan_build .

Expand All @@ -16,60 +21,51 @@ git apply --reject --whitespace=fix ../upstream_patches/*
popd

# build valhalla
cmake -B upstream/build -S upstream/ -DENABLE_CCACHE=OFF -DBUILD_SHARED_LIBS=OFF -DENABLE_BENCHMARKS=OFF -DENABLE_PYTHON_BINDINGS=ON -DENABLE_TESTS=OFF -DENABLE_TOOLS=OFF -DENABLE_SERVICES=OFF -DENABLE_HTTP=OFF -DENABLE_CCACHE=OFF -DCMAKE_BUILD_TYPE=Release
cmake -B upstream/build -S upstream/ -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DENABLE_CCACHE=OFF -DBUILD_SHARED_LIBS=OFF -DENABLE_BENCHMARKS=OFF -DENABLE_PYTHON_BINDINGS=OFF -DENABLE_TESTS=OFF -DENABLE_TOOLS=OFF -DENABLE_DATA_TOOLS=OFF -DENABLE_SERVICES=OFF -DENABLE_HTTP=OFF -DENABLE_CCACHE=OFF -DCMAKE_BUILD_TYPE=Release
cmake --build upstream/build -- -j$(nproc)

echo "copying all headers"
deps="libcurl4-openssl-dev libgeos++-dev libgeos-dev libluajit-5.1-dev libprotobuf-dev libspatialite-dev libsqlite3-dev"
for dep in $deps; do
for path in $(dpkg -L ${dep}); do
# find and copy the headers
if [[ ${path} == *"/include/x86_64-linux-gnu/"* ]]; then
rel_dest=include/linux/${path##*/x86_64-linux-gnu/}
elif [[ ${path} == *"/include/"* ]]; then
rel_dest=include/linux/${path##*/include/}
else
continue
fi
if [[ -f $path ]]; then
mkdir -p $(dirname ${rel_dest})
cp $path $(dirname ${rel_dest})
fi
done
done
cp -arf /usr/include/curl include/linux

# protobuf is installed in /usr/local
rm -r include/linux/google
cp -arf /usr/local/include/google include/linux

# copy valhalla headers from upstream to include/common after deleting the old ones for safety reasons
# also rm the old setup.py build folder: if the version doesn't change, setuptools simply won't update the .so,
# so we'd get old builds fact.. wtf..
rm -r include/common/valhalla
cp -r upstream/valhalla include/common
if [[ -d build ]]; then
rm -r build
fi
cp -r upstream/valhalla include/common
mv include/common/valhalla/config.h.cmake include/common/valhalla/config.h
mv include/common/valhalla/valhalla.h.in include/common/valhalla/valhalla.h

# copy most recent valhalla_build_config.py
cp upstream/scripts/valhalla_build_config valhalla/valhalla_build_config.py

# copy libvalhalla so it's available for setup.py in its most recent version
# copy libvalhalla and libprotobuf-dev so it's available for setup.py in its most recent version
cp -f upstream/build/src/libvalhalla.a lib/linux
cp -f /usr/local/lib64/libprotobuf-lite.a lib/linux

# build the proto files into the include/linux/valhalla/proto directory before building the bindings
if [[ -d include/linux/valhalla/proto ]]; then
rm -r include/linux/valhalla/proto
fi
mkdir -p include/linux/valhalla/proto
/usr/local/bin/protoc --proto_path=$PWD/upstream/proto --cpp_out=$PWD/include/linux/valhalla/proto $PWD/upstream/proto/*.proto

# make the bindings so we can see which libraries it exactly links to and also for testing
/opt/python/cp310-cp310/bin/pip install -r build-requirements.txt
/opt/python/cp310-cp310/bin/python3 setup.py bdist_wheel
python3.10 -m pip install -r build-requirements.txt
python3.10 setup.py bdist_wheel

echo "copying all libraries"
deps="libprotobuf-lite libcurl libz"
deps="libcurl libz"
# prints all linked library paths
for path in $(ldd build/lib.linux-x86_64-3.10/valhalla/_valhalla.cpython-310-x86_64-linux-gnu.so | awk 'NF == 4 {print $3}; NF == 2 {print $1}'); do
for path in $(ldd build/lib.linux-x86_64-cpython-310/valhalla/_valhalla.cpython-310-x86_64-linux-gnu.so | awk 'NF == 4 {print $3}; NF == 2 {print $1}'); do
for dep in ${deps}; do
echo "Copying library ${dep} from ${path}"
if [[ ${path} == *${dep}* ]]; then
if [[ ${path} == *"/x86_64-linux-gnu/"* ]]; then
rel_dest=lib/linux/${path##*/x86_64-linux-gnu/}
else
rel_dest=lib/linux/${path##*/lib/}
fi
rel_dest=lib/linux/${path##*/lib64/}
# make the directory before
mkdir -p $(dirname ${rel_dest})
# follow symlinks and copy the actual file
Expand All @@ -78,13 +74,9 @@ for path in $(ldd build/lib.linux-x86_64-3.10/valhalla/_valhalla.cpython-310-x86
done
done

# build the proto files into the include/linux/valhalla/proto directory
mkdir -p include/linux/valhalla/proto
/usr/bin/protoc --proto_path=upstream/proto --cpp_out=include/linux/valhalla/proto upstream/proto/*.proto

# now checkout the unpatched valhalla version again
git -C upstream checkout .

for so in dist/*; do
auditwheel repair --plat manylinux_2_24_x86_64 "${so}"
auditwheel repair --plat manylinux_2_28_x86_64 "${so}"
done

0 comments on commit 8208d4d

Please sign in to comment.