Skip to content
Snippets Groups Projects
Commit cd34d867 authored by Guilhem Saurel's avatar Guilhem Saurel
Browse files

manylinux: example-robot-data

parent a482fc17
No related branches found
No related tags found
No related merge requests found
#!/bin/bash -eux
pyver=${1:-all}
pyver="${1:-all}"
pwd="$(pwd -P)"
docker build -t manylinux .
docker run -v "$(pwd -P):/io" -v /local/users/ccache/:/root/.ccache --rm -t manylinux rm -rf /io/dist /io/wheelhouse
docker run -v "$pwd:/io" -v /local/users/ccache/:/root/.ccache --rm -t manylinux rm -rf /io/dist /io/wheelhouse
build() {
for target in eigenpy hpp-fcl pinocchio
do docker run -v "$(pwd -P):/io" -v /local/users/ccache/:/root/.ccache --rm -t manylinux /scripts/setup.sh $target $1
done
build_wheel() {
while read target
do docker run -v "$pwd:/io" -v /local/users/ccache/:/root/.ccache --rm -t manylinux /scripts/setup.sh $target $1
done < config/targets
}
test() {
docker build -f test.Dockerfile --build-arg PYVER=$pyver -t manylinux-test:$pyver .
docker run --rm -t manylinux-test:$pyver
test_wheel() {
docker build -f test.Dockerfile --build-arg PYVER=$1 -t manylinux-test:$1 .
docker run --rm -t manylinux-test:$1
}
if [ "$pyver" = all ]
then
for pyver in 2.7 3.5 3.6 3.7 3.8 3.9
do build $pyver &
for pv in 2.7 3.5 3.6 3.7 3.8 3.9
do build_wheel $pv
done
wait
else
build $pyver
build_wheel $pyver
fi
clear
if [ "$pyver" = all ]
then
for pyver in 2.7 3.5 3.6 3.7 3.8 3.9
do test $pyver
for pv in 2.7 3.5 3.6 3.7 3.8 3.9
do test_wheel $pv
done
else
test $pyver
test_wheel $pyver
fi
from skbuild import setup
try:
with open("README.md", "r") as f:
long_description = f.read()
except FileNotFoundError:
long_description = ""
setup(
name="example-robot-data",
version="VERSION",
description="Set of robot URDFs for benchmarking and developed examples.",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/gepetto/example-robot-data",
install_requires=['pinocchio'],
cmake_minimum_required_version='3.1',
classifiers=[
"Programming Language :: Python :: 2", "Programming Language :: Python :: 3",
"License :: OSI Approved :: BSD License", "Operating System :: POSIX :: Linux"
],
python_requires='>=2.7',
)
import unittest
import example_robot_data
class TestPinocchio(unittest.TestCase):
def test_trivial(self):
self.assertEqual(example_robot_data.load('talos').model.nq, 39)
if __name__ == '__main__':
unittest.main()
eigenpy
hpp-fcl
pinocchio
example-robot-data
......@@ -4,17 +4,17 @@ TARGET=${1:-eigenpy}
PYVER=${2:-3.9}
export CMAKE_PREFIX_PATH="~/.local:/opt/openrobots"
PACKAGE="${TARGET//-/_}"
VERSION="$(grep version setup.py | head -1 | cut -d'"' -f2)"
TARVER="$TARGET-$VERSION"
WHEEL_DIR="${TARGET/-/_}-$VERSION"
PACKAGE="$TARGET"
[ "$TARGET" = "hpp-fcl" ] && PACKAGE=hppfcl
WHEEL_DIR="$PACKAGE-$VERSION"
PYBIN="$(find /opt/python -name "cp${PYVER/.}*")/bin"
INSTALLED_PREFIX="$PWD/_skbuild/linux-x86_64-$PYVER/cmake-install"
SITE_PACKAGES="lib/python$PYVER/site-packages"
USER_PACKAGES="$HOME/.local/$SITE_PACKAGES"
WHEEL_NAME="$WHEEL_DIR-cp${PYVER/.}-"
LIB_DIR="${TARGET/-/_}.libs"
LIB_DIR="$PACKAGE.libs"
[ "$PACKAGE" = "hpp_fcl" ] && PACKAGE=hppfcl
PACKAGE_DIR="$WHEEL_DIR/$WHEEL_DIR.data/data/$SITE_PACKAGES/$PACKAGE"
# Install dependencies
......@@ -25,55 +25,68 @@ PACKAGE_DIR="$WHEEL_DIR/$WHEEL_DIR.data/data/$SITE_PACKAGES/$PACKAGE"
"$PYBIN/python" setup.py bdist_wheel -j"$(nproc)" -DBUILD_TESTING=OFF -DINSTALL_DOCUMENTATION=OFF \
-DCMAKE_INSTALL_LIBDIR=lib -DPYTHON_STANDARD_LAYOUT=ON -DENFORCE_MINIMAL_CXX_STANDARD=ON
# Bundle external shared libraries into the wheels
OTHER_LIB_DIRS=$(find "$USER_PACKAGES" -name '*.libs' | tr '\n' ':')
BINARY_EXTENSIONS="$(find "$INSTALLED_PREFIX/$SITE_PACKAGES/$PACKAGE" -name '*.so*')" || true
if [ -n "$BINARY_EXTENSIONS" ]
then
# Bundle external shared libraries into the wheels
OTHER_LIB_DIRS=$(find "$USER_PACKAGES" -name '*.libs' | tr '\n' ':')
# don't bundle ones already in another wheel
# that's against pypa recomendations, but should work
WHITELISTED="$(/scripts/patch_whitelist.py "$USER_PACKAGES")"
# don't bundle ones already in another wheel
# that's against pypa recomendations, but should work
WHITELISTED="$(/scripts/patch_whitelist.py "$USER_PACKAGES")"
# Repair it
LD_LIBRARY_PATH="$INSTALLED_PREFIX/lib:$OTHER_LIB_DIRS/opt/openrobots/lib:$LD_LIBRARY_PATH" \
auditwheel repair "dist/$WHEEL_NAME"* --plat "$PLAT" -w /io/wheelhouse/
# Repair it
LD_LIBRARY_PATH="$INSTALLED_PREFIX/lib:$OTHER_LIB_DIRS/opt/openrobots/lib:$LD_LIBRARY_PATH" \
auditwheel repair "dist/$WHEEL_NAME"* --plat "$PLAT" -w /io/wheelhouse/
else
mv dist/"$WHEEL_NAME"*-linux*.whl /io/wheelhouse
fi
# Clean build
rm -rf _skbuild dist
# Extract it
wheel unpack /io/wheelhouse/"$WHEEL_NAME"*-manylinux2014*.whl
wheel unpack /io/wheelhouse/"$WHEEL_NAME"*linux*.whl
# set the RPATH right for the installed wheel
# ref https://github.com/pypa/auditwheel/issues/257
patchelf --set-rpath "\$ORIGIN/../$LIB_DIR$WHITELISTED" "$(find "$PACKAGE_DIR" -name '*.so')"
if [ -n "$BINARY_EXTENSIONS" ]
then
# set the RPATH right for the installed wheel
# ref https://github.com/pypa/auditwheel/issues/257
patchelf --set-rpath "\$ORIGIN/../$LIB_DIR$WHITELISTED" "$(find "$PACKAGE_DIR" -name '*.so')"
# Remove moved libs
rm -f "$WHEEL_DIR/$WHEEL_DIR.data/data/lib/"lib*so*
# Remove moved libs
rm -f "$WHEEL_DIR/$WHEEL_DIR.data/data/lib/"lib*so*
# Set the rpath of the other shared libraries in LIB_DIR
for lib in "$WHEEL_DIR/${LIB_DIR}"/*
do patchelf --set-rpath '$ORIGIN' "$lib"
done
# Set the rpath of the other shared libraries in LIB_DIR
for lib in "$WHEEL_DIR/${LIB_DIR}"/*
do patchelf --set-rpath '$ORIGIN' "$lib"
done
# fix .cmake files: remove _skbuild references & update lib name with their hash from auditwheel
MAIN_LIB=$(find "$WHEEL_DIR/$LIB_DIR" -name "lib$TARGET-*.so*") # eigenpy-2.5.0/eigenpy.libs/libeigenpy-0c5e8890.so
MAIN_LIB_NAME=$(basename "$MAIN_LIB") # libeigenpy-0c5e8890.so
MAIN_LIB_NAME_NO_HASH=$(echo "$MAIN_LIB_NAME" | sed 's/-[[:xdigit:]]\{8\}//') # libeigenpy.so
# fix .cmake files: remove _skbuild references & update lib name with their hash from auditwheel
MAIN_LIB=$(find "$WHEEL_DIR/$LIB_DIR" -name "lib$TARGET-*.so") # eigenpy-2.5.0/eigenpy.libs/libeigenpy-0c5e8890.so
MAIN_LIB_NAME=$(basename "$MAIN_LIB") # libeigenpy-0c5e8890.so
MAIN_LIB_NAME_NO_HASH=$(echo "$MAIN_LIB_NAME" | sed 's/-[[:xdigit:]]\{8\}//') # libeigenpy.so
for file in $WHEEL_DIR/$WHEEL_DIR.data/data/lib/cmake/$TARGET/*.cmake
do
sed -i "s:$MAIN_LIB_NAME_NO_HASH:$MAIN_LIB_NAME:" "$file" || true
done
fi
for file in $WHEEL_DIR/$WHEEL_DIR.data/data/lib/cmake/$TARGET/*.cmake
do
sed -i "s:/src/_skbuild/linux-x86_64-.*/cmake-install/lib/\(.*\)\.so:\${_IMPORT_PREFIX}/$SITE_PACKAGES/$LIB_DIR/\1.so:" "$file" || true
sed -i "s:$MAIN_LIB_NAME_NO_HASH:$MAIN_LIB_NAME:" "$file" || true
sed -i "s:/src/_skbuild/linux-x86_64-.*/cmake-install/lib/\([^/]*\)\.so:\${_IMPORT_PREFIX}/$SITE_PACKAGES/$LIB_DIR/\1.so:" "$file" || true
sed -i 's:/src/_skbuild/linux-x86_64-.*/cmake-install/include:${_IMPORT_PREFIX}/include:' "$file" || true
sed -i 's:/src/_skbuild/linux-x86_64-.*/cmake-install/lib:${_IMPORT_PREFIX}/lib:' "$file" || true
done
# Repack and clean
wheel pack "$WHEEL_DIR" -d /io/wheelhouse
rm -rf "${WHEEL_DIR:?}"/ "$TARGET".egg-info/ dist/
rm -rf "${WHEEL_DIR:?}"/ "$TARGET".egg-info
# Install packages and test
"$PYBIN/pip" install --user "$TARGET" --no-index --find-links=/io/wheelhouse/
(cd "$HOME"; "$PYBIN/python" "/io/config/$TARGET/test.py") || touch "/io/wheelhouse/$PYVER-$TARGET"
(cd "$HOME"; "$PYBIN/python" "/io/config/$TARGET/test.py")
mkdir -p /io/dist
mv /io/wheelhouse/"$WHEEL_NAME"*-manylinux2014*.whl /io/dist
mv /io/wheelhouse/"$WHEEL_NAME"*linux*.whl /io/dist
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment