From 0f8b83a4998ddb9162417e16ceb3055c8cafb667 Mon Sep 17 00:00:00 2001 From: John Wason Date: Thu, 18 Jan 2024 19:14:19 -0500 Subject: [PATCH] Add Mac OS wheel build action (#69) * Update to tesseract 0.21.4 * Fix LD_LIBRARY_PATH during docs build for wheels workflow * Bump version to 0.3.0 * Add python 3.12 build * Update generated api docs * Update docs requirements * Update docs requirements * Add macos action * run ci * Add macos action * Add macos action * Add macos action * Add macos action * Add macos action * Add macos action * Use setup-python output python-path on mac * Fix delocate-wheel command arguments * Wheels workflow branch trigger * Only build Python 3.12 on macos * DYLD_LIBRARY_PATH during macos build --- .../x64-osx-dynamic-release.cmake | 9 ++ .github/workflows/wheels.yml | 93 ++++++++++++++++++- .../cmake/install_build_wheel.cmake.in | 12 +++ 3 files changed, 110 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/vcpkg_triplets/x64-osx-dynamic-release.cmake diff --git a/.github/workflows/vcpkg_triplets/x64-osx-dynamic-release.cmake b/.github/workflows/vcpkg_triplets/x64-osx-dynamic-release.cmake new file mode 100644 index 000000000..1e296987c --- /dev/null +++ b/.github/workflows/vcpkg_triplets/x64-osx-dynamic-release.cmake @@ -0,0 +1,9 @@ +set(VCPKG_TARGET_ARCHITECTURE x64) +set(VCPKG_CRT_LINKAGE dynamic) +set(VCPKG_LIBRARY_LINKAGE dynamic) + +set(VCPKG_CMAKE_SYSTEM_NAME Darwin) +set(VCPKG_OSX_ARCHITECTURES x86_64) + +set(VCPKG_BUILD_TYPE release) +set(VCPKG_OSX_DEPLOYMENT_TARGET 12.0) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 8c3f7c684..c7cbc5b70 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -4,7 +4,7 @@ on: push: branches: - master - - dev + - 'dev**' pull_request: release: types: @@ -17,11 +17,11 @@ env: tinyxml2 console-bridge assimp urdfdom octomap orocos-kdl pcl gtest benchmark flann jsoncpp - yaml-cpp - blas lapack + yaml-cpp eigen3 + openblas fcl ompl taskflow bullet3[multithreading,double-precision,rtti] - ccd[double-precision] + ccd[double-precision] gperftools jobs: build-ubuntu: runs-on: ${{ matrix.config.runs_on }} @@ -274,10 +274,95 @@ jobs: name: 'build-logs-win-${{ matrix.config.arch }}-python-${{ matrix.config.python_version }}' path: "**/*.log" retention-days: 2 + build-macos: + runs-on: macos-latest + strategy: + fail-fast: false + matrix: + config: + - py_platform: macosx-10.9-x86_64 + python_version: "3.12" + steps: + - uses: actions/checkout@v2 + with: + path: ws/src/tesseract_python + - uses: actions/setup-python@v4 + id: setup-python + with: + python-version: '${{ matrix.config.python_version }}' + - name: brew + run: | + brew install libomp cmake automake autoconf libtool gcc ninja + - name: vcpkg build + uses: johnwason/vcpkg-action@v5 + with: + pkgs: >- + ${{ env.VCPKG_PKGS }} + triplet: x64-osx-dynamic-release + extra-args: --clean-after-build --overlay-triplets=${{ github.workspace }}/ws/src/tesseract_python/.github/workflows/vcpkg_triplets + token: ${{ github.token }} + cache-key: osx-x64-vcpkg + revision: master + - name: pip3 + run: | + python3 -m pip install numpy setuptools wheel pytest delvewheel colcon-common-extensions vcstool delocate + - name: vcs import + working-directory: ws/src + run: vcs import --input tesseract_python/dependencies.rosinstall + - name: colcon build + working-directory: ws + run: | + export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$GITHUB_WORKSPACE/vcpkg/installed/x64-osx-dynamic-release/lib:$GITHUB_WORKSPACE/ws/install/lib + export CMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/vcpkg/installed/x64-osx-dynamic-release + + colcon build --merge-install \ + --packages-ignore tesseract_examples trajopt_ifopt trajopt_sqp ifopt vhacd \ + --event-handlers console_cohesion+ \ + --cmake-force-configure \ + --cmake-args -GNinja -DCMAKE_BUILD_TYPE=Release \ + -DINSTALL_OMPL=OFF -DINSTALL_OMPL_TAG=master -DBUILD_IPOPT=OFF -DBUILD_SNOPT=OFF \ + -DBUILD_SHARED_LIBS=ON -DTESSERACT_ENABLE_EXAMPLES=OFF -DTESSERACT_BUILD_TRAJOPT_IFOPT=OFF \ + -DVCPKG_APPLOCAL_DEPS=OFF -DTESSERACT_ENABLE_TESTING=ON \ + -DCMAKE_OSX_DEPLOYMENT_TARGET=12.0 \ + -DOpenMP_CXX_INCLUDE_DIR=/usr/local/opt/libomp/include \ + -DOpenMP_C_INCLUDE_DIR=/usr/local/opt/libomp/include \ + -DOpenMP_CXX_LIB_NAMES=libomp -DOpenMP_CXX_FLAGS="-Xpreprocessor -fopenmp" \ + -DOpenMP_C_LIB_NAMES=libomp -DOpenMP_C_FLAGS="-Xpreprocessor -fopenmp" \ + -DOpenMP_libomp_LIBRARY=/usr/local/opt/libomp/lib/libomp.dylib \ + -Dtcmalloc_minimal_LIBRARY=${{ github.workspace }}/vcpkg/installed/x64-osx-dynamic-release/lib/libtcmalloc_minimal.dylib \ + -DPYTHON_EXECUTABLE="${{ steps.setup-python.outputs.python-path }}" \ + -DTESSERACT_PYTHON_WHEEL_PLATFORM=${{ matrix.config.py_platform }} \ + -DTESSERACT_PYTHON_BUILD_WHEEL=ON + - name: test + shell: bash + run: | + ${{ steps.setup-python.outputs.python-path }} -m venv venv + source venv/bin/activate + python -m pip install --upgrade pip + python -m pip install ws/build/tesseract_python/python/wheelhouse/* + python -m pip install pytest + export TESSERACT_SUPPORT_DIR=$GITHUB_WORKSPACE/ws/src/tesseract/tesseract_support + export TESSERACT_TASK_COMPOSER_DIR=$GITHUB_WORKSPACE/ws/src/tesseract_planning/tesseract_task_composer + cd ws/src/tesseract_python/tesseract_python + pytest -s + - name: archive wheels + if: always() + uses: actions/upload-artifact@v2 + with: + name: 'python-macos-win-${{matrix.config.python_version}}' + path: ws/build/tesseract_python/python + - name: archive logs + if: failure() + uses: actions/upload-artifact@v2 + with: + name: 'build-logs-macos-${{ matrix.config.arch }}-python-${{ matrix.config.python_version }}' + path: "**/*.log" + retention-days: 2 collect-wheels: needs: - build-win - build-ubuntu + - build-macos runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2 diff --git a/tesseract_python/cmake/install_build_wheel.cmake.in b/tesseract_python/cmake/install_build_wheel.cmake.in index 925f9f0a0..ef7039d99 100644 --- a/tesseract_python/cmake/install_build_wheel.cmake.in +++ b/tesseract_python/cmake/install_build_wheel.cmake.in @@ -14,6 +14,18 @@ if(STATUS AND NOT STATUS EQUAL 0) endif() endforeach() +elseif(APPLE) +execute_process(COMMAND @PYTHON_EXECUTABLE@ setup.py bdist_wheel WORKING_DIRECTORY python RESULT_VARIABLE STATUS) +if(STATUS AND NOT STATUS EQUAL 0) + message(FATAL_ERROR "Python Build Wheel Failed: ${STATUS}") +endif() +file(GLOB wheel_files "${CMAKE_CURRENT_LIST_DIR}/python/dist/*.whl") +foreach(wheel_file ${wheel_files}) +execute_process(COMMAND delocate-wheel --sanitize-rpaths -d -w ${CMAKE_CURRENT_LIST_DIR}/python/wheelhouse ${wheel_file} WORKING_DIRECTORY python RESULT_VARIABLE STATUS) +if(STATUS AND NOT STATUS EQUAL 0) + message(FATAL_ERROR "Python Build Wheel Failed: ${STATUS}") +endif() +endforeach() else() execute_process(COMMAND @PYTHON_EXECUTABLE@ setup.py bdist_wheel --plat-name=@TESSERACT_PYTHON_WHEEL_PLATFORM@ WORKING_DIRECTORY python RESULT_VARIABLE STATUS) if(STATUS AND NOT STATUS EQUAL 0)