Skip to content

Commit

Permalink
Add Mac OS wheel build action (#69)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
johnwason authored Jan 19, 2024
1 parent 59a3529 commit 0f8b83a
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -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)
93 changes: 89 additions & 4 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches:
- master
- dev
- 'dev**'
pull_request:
release:
types:
Expand All @@ -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 }}
Expand Down Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions tesseract_python/cmake/install_build_wheel.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 0f8b83a

Please sign in to comment.