diff --git a/docker/manylinux2014/config/example-robot-data/setup.py b/docker/manylinux2014/config/example-robot-data/setup.py index 0d342ad7c0c1c0b681b81c53b75725caf81620af..f02d5fb9d156aaa2a4138e1247b8a7f6c0e22834 100644 --- a/docker/manylinux2014/config/example-robot-data/setup.py +++ b/docker/manylinux2014/config/example-robot-data/setup.py @@ -1,20 +1,23 @@ -from skbuild import setup +from setuptools import setup +import os -try: - with open("README.md", "r") as f: - long_description = f.read() -except FileNotFoundError: - long_description = "" +def read_text(path): + with open(path) as f: + return f.read().decode('utf-8').strip() + +def data_files(*paths): + return [(root, [os.path.join(root, f) for f in files]) for path in paths for root, _, files in os.walk(path)] setup( name="example-robot-data", - version="VERSION", + packages=['example_robot_data'], 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', + data_files=data_files("include", "lib", "share"), + version=read_text('.version'), + long_description=read_text("README.md"), + long_description_content_type="text/markdown", classifiers=[ "Programming Language :: Python :: 2", "Programming Language :: Python :: 3", "License :: OSI Approved :: BSD License", "Operating System :: POSIX :: Linux" diff --git a/docker/manylinux2014/scripts/build_wheels.sh b/docker/manylinux2014/scripts/build_wheels.sh index 04ef01b1d62e6025dc823417f7ec954c7aef450a..b61ade70f06f683d18e0c2f719c1e04f43ced358 100755 --- a/docker/manylinux2014/scripts/build_wheels.sh +++ b/docker/manylinux2014/scripts/build_wheels.sh @@ -5,14 +5,13 @@ PYVER=${2:-3.9} export CMAKE_PREFIX_PATH="~/.local:/opt/openrobots" PACKAGE="${TARGET//-/_}" -VERSION="$(grep version setup.py | head -1 | cut -d'"' -f2)" +VERSION="$(cat .version)" TARVER="$TARGET-$VERSION" 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/.}-" +USER_SITE="$("$PYBIN/python" -c 'import site; print(site.USER_SITE)')" +SITE_PACKAGES="$("$PYBIN/python" -c "import site; print(site.USER_SITE.replace(site.USER_BASE + '/', ''))")" LIB_DIR="$PACKAGE.libs" [ "$PACKAGE" = "hpp_fcl" ] && PACKAGE=hppfcl PACKAGE_DIR="$WHEEL_DIR/$WHEEL_DIR.data/data/$SITE_PACKAGES/$PACKAGE" @@ -21,34 +20,38 @@ PACKAGE_DIR="$WHEEL_DIR/$WHEEL_DIR.data/data/$SITE_PACKAGES/$PACKAGE" "$PYBIN/pip" install --user --find-links=/io/dist/ \ $(grep install_requires setup.py | sed "s/.*\['//;s/'\].*//;s/,//") -# Build wheels -"$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 - -BINARY_EXTENSIONS="$(find "$INSTALLED_PREFIX/$SITE_PACKAGES/$PACKAGE" -name '*.so*')" || true -if [ -n "$BINARY_EXTENSIONS" ] +if grep -q skbuild setup.py then + # Build binary wheel + "$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' ':') + OTHER_LIB_DIRS=$(find "$USER_SITE" -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")" + WHITELISTED="$(/scripts/patch_whitelist.py "$USER_SITE")" # 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/ + auditwheel repair dist/*.whl --plat "$PLAT" -w /io/wheelhouse/ else - mv dist/"$WHEEL_NAME"*-linux*.whl /io/wheelhouse + # Build pure wheel + cmake -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_INSTALL_PREFIX=. . + make install + python setup.py bdist_wheel --universal + mkdir -p /io/wheelhouse + mv dist/*.whl /io/wheelhouse fi # Clean build -rm -rf _skbuild dist +rm -rf _skbuild dist inst # Extract it -wheel unpack /io/wheelhouse/"$WHEEL_NAME"*linux*.whl +wheel unpack /io/wheelhouse/*.whl -if [ -n "$BINARY_EXTENSIONS" ] +if grep -q skbuild setup.py then # set the RPATH right for the installed wheel # ref https://github.com/pypa/auditwheel/issues/257 @@ -89,4 +92,4 @@ rm -rf "${WHEEL_DIR:?}"/ "$TARGET".egg-info (cd "$HOME"; "$PYBIN/python" "/io/config/$TARGET/test.py") mkdir -p /io/dist -mv /io/wheelhouse/"$WHEEL_NAME"*linux*.whl /io/dist +mv /io/wheelhouse/*.whl /io/dist diff --git a/docker/manylinux2014/scripts/setup.py b/docker/manylinux2014/scripts/setup.py deleted file mode 100644 index b2939af18f2a4684457fc858480130f2defdd966..0000000000000000000000000000000000000000 --- a/docker/manylinux2014/scripts/setup.py +++ /dev/null @@ -1,22 +0,0 @@ -from skbuild import setup - -try: - with open("README.md", "r") as f: - long_description = f.read() -except FileNotFoundError: - long_description = "" - -setup( - name="TARGET", - version="VERSION", - description="DESCRIPTION", - long_description=long_description, - long_description_content_type="text/markdown", - url="https://github.com/ORG/TARGET", - install_requires=INSTALL_REQUIRES, - classifiers=[ - "Programming Language :: Python :: 2", "Programming Language :: Python :: 3", - "License :: OSI Approved :: BSD License", "Operating System :: POSIX :: Linux" - ], - python_requires='>=2.7', -) diff --git a/docker/manylinux2014/scripts/setup.sh b/docker/manylinux2014/scripts/setup.sh index 3f3afb0e5213c8e2619ec3a024f1fc920dbc34f8..ab7c3e936e341d6038ee8b75264ace75efdda0b9 100755 --- a/docker/manylinux2014/scripts/setup.sh +++ b/docker/manylinux2014/scripts/setup.sh @@ -15,8 +15,6 @@ curl -sSL "$URL/releases/download/v$VERSION/$TARGET-$VERSION.tar.gz" \ cp "/io/config/$TARGET/setup.py" . cp /scripts/pyproject.toml . -sed -i "s/VERSION/$VERSION/" setup.py - # Fix CMake for scikit-build find . -name CMakeLists.txt | xargs sed -i 's/PYTHON_INCLUDE_DIRS/PYTHON_INCLUDE_DIR/' sed -i 's/REQUIRED COMPONENTS Interpreter Development/REQUIRED COMPONENTS Interpreter/' cmake/python.cmake