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 #!/bin/bash -eux
pyver=${1:-all} pyver="${1:-all}"
pwd="$(pwd -P)"
docker build -t manylinux . 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() { build_wheel() {
for target in eigenpy hpp-fcl pinocchio while read target
do docker run -v "$(pwd -P):/io" -v /local/users/ccache/:/root/.ccache --rm -t manylinux /scripts/setup.sh $target $1 do docker run -v "$pwd:/io" -v /local/users/ccache/:/root/.ccache --rm -t manylinux /scripts/setup.sh $target $1
done done < config/targets
} }
test() { test_wheel() {
docker build -f test.Dockerfile --build-arg PYVER=$pyver -t manylinux-test:$pyver . docker build -f test.Dockerfile --build-arg PYVER=$1 -t manylinux-test:$1 .
docker run --rm -t manylinux-test:$pyver docker run --rm -t manylinux-test:$1
} }
if [ "$pyver" = all ] if [ "$pyver" = all ]
then then
for pyver in 2.7 3.5 3.6 3.7 3.8 3.9 for pv in 2.7 3.5 3.6 3.7 3.8 3.9
do build $pyver & do build_wheel $pv
done done
wait
else else
build $pyver build_wheel $pyver
fi fi
clear clear
if [ "$pyver" = all ] if [ "$pyver" = all ]
then then
for pyver in 2.7 3.5 3.6 3.7 3.8 3.9 for pv in 2.7 3.5 3.6 3.7 3.8 3.9
do test $pyver do test_wheel $pv
done done
else else
test $pyver test_wheel $pyver
fi 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 eigenpy
hpp-fcl hpp-fcl
pinocchio pinocchio
example-robot-data
...@@ -4,17 +4,17 @@ TARGET=${1:-eigenpy} ...@@ -4,17 +4,17 @@ TARGET=${1:-eigenpy}
PYVER=${2:-3.9} PYVER=${2:-3.9}
export CMAKE_PREFIX_PATH="~/.local:/opt/openrobots" export CMAKE_PREFIX_PATH="~/.local:/opt/openrobots"
PACKAGE="${TARGET//-/_}"
VERSION="$(grep version setup.py | head -1 | cut -d'"' -f2)" VERSION="$(grep version setup.py | head -1 | cut -d'"' -f2)"
TARVER="$TARGET-$VERSION" TARVER="$TARGET-$VERSION"
WHEEL_DIR="${TARGET/-/_}-$VERSION" WHEEL_DIR="$PACKAGE-$VERSION"
PACKAGE="$TARGET"
[ "$TARGET" = "hpp-fcl" ] && PACKAGE=hppfcl
PYBIN="$(find /opt/python -name "cp${PYVER/.}*")/bin" PYBIN="$(find /opt/python -name "cp${PYVER/.}*")/bin"
INSTALLED_PREFIX="$PWD/_skbuild/linux-x86_64-$PYVER/cmake-install" INSTALLED_PREFIX="$PWD/_skbuild/linux-x86_64-$PYVER/cmake-install"
SITE_PACKAGES="lib/python$PYVER/site-packages" SITE_PACKAGES="lib/python$PYVER/site-packages"
USER_PACKAGES="$HOME/.local/$SITE_PACKAGES" USER_PACKAGES="$HOME/.local/$SITE_PACKAGES"
WHEEL_NAME="$WHEEL_DIR-cp${PYVER/.}-" 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" PACKAGE_DIR="$WHEEL_DIR/$WHEEL_DIR.data/data/$SITE_PACKAGES/$PACKAGE"
# Install dependencies # Install dependencies
...@@ -25,55 +25,68 @@ PACKAGE_DIR="$WHEEL_DIR/$WHEEL_DIR.data/data/$SITE_PACKAGES/$PACKAGE" ...@@ -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 \ "$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 -DCMAKE_INSTALL_LIBDIR=lib -DPYTHON_STANDARD_LAYOUT=ON -DENFORCE_MINIMAL_CXX_STANDARD=ON
# Bundle external shared libraries into the wheels BINARY_EXTENSIONS="$(find "$INSTALLED_PREFIX/$SITE_PACKAGES/$PACKAGE" -name '*.so*')" || true
OTHER_LIB_DIRS=$(find "$USER_PACKAGES" -name '*.libs' | tr '\n' ':') 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 # don't bundle ones already in another wheel
# that's against pypa recomendations, but should work # that's against pypa recomendations, but should work
WHITELISTED="$(/scripts/patch_whitelist.py "$USER_PACKAGES")" WHITELISTED="$(/scripts/patch_whitelist.py "$USER_PACKAGES")"
# Repair it # Repair it
LD_LIBRARY_PATH="$INSTALLED_PREFIX/lib:$OTHER_LIB_DIRS/opt/openrobots/lib:$LD_LIBRARY_PATH" \ 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/ auditwheel repair "dist/$WHEEL_NAME"* --plat "$PLAT" -w /io/wheelhouse/
else
mv dist/"$WHEEL_NAME"*-linux*.whl /io/wheelhouse
fi
# Clean build # Clean build
rm -rf _skbuild dist rm -rf _skbuild dist
# Extract it # 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 if [ -n "$BINARY_EXTENSIONS" ]
# ref https://github.com/pypa/auditwheel/issues/257 then
patchelf --set-rpath "\$ORIGIN/../$LIB_DIR$WHITELISTED" "$(find "$PACKAGE_DIR" -name '*.so')" # 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 # Remove moved libs
rm -f "$WHEEL_DIR/$WHEEL_DIR.data/data/lib/"lib*so* rm -f "$WHEEL_DIR/$WHEEL_DIR.data/data/lib/"lib*so*
# Set the rpath of the other shared libraries in LIB_DIR # Set the rpath of the other shared libraries in LIB_DIR
for lib in "$WHEEL_DIR/${LIB_DIR}"/* for lib in "$WHEEL_DIR/${LIB_DIR}"/*
do patchelf --set-rpath '$ORIGIN' "$lib" do patchelf --set-rpath '$ORIGIN' "$lib"
done 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 for file in $WHEEL_DIR/$WHEEL_DIR.data/data/lib/cmake/$TARGET/*.cmake
MAIN_LIB=$(find "$WHEEL_DIR/$LIB_DIR" -name "lib$TARGET-*.so") # eigenpy-2.5.0/eigenpy.libs/libeigenpy-0c5e8890.so do
MAIN_LIB_NAME=$(basename "$MAIN_LIB") # libeigenpy-0c5e8890.so sed -i "s:$MAIN_LIB_NAME_NO_HASH:$MAIN_LIB_NAME:" "$file" || true
MAIN_LIB_NAME_NO_HASH=$(echo "$MAIN_LIB_NAME" | sed 's/-[[:xdigit:]]\{8\}//') # libeigenpy.so done
fi
for file in $WHEEL_DIR/$WHEEL_DIR.data/data/lib/cmake/$TARGET/*.cmake for file in $WHEEL_DIR/$WHEEL_DIR.data/data/lib/cmake/$TARGET/*.cmake
do 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:/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/include:${_IMPORT_PREFIX}/include:' "$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 sed -i 's:/src/_skbuild/linux-x86_64-.*/cmake-install/lib:${_IMPORT_PREFIX}/lib:' "$file" || true
done done
# Repack and clean # Repack and clean
wheel pack "$WHEEL_DIR" -d /io/wheelhouse 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 # Install packages and test
"$PYBIN/pip" install --user "$TARGET" --no-index --find-links=/io/wheelhouse/ "$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 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