From 7e7aefad58cbf1a37adc874bdec093826f78f2ec Mon Sep 17 00:00:00 2001 From: Michael MIGLIORE Date: Sat, 5 Aug 2023 11:12:43 +0200 Subject: [PATCH] Add python wheels (#76) --- .github/workflows/wheels.yml | 107 +++++++++++++++++++++++++++++++++++ projects/assimp.cmake | 3 +- projects/vtk.cmake | 10 ++-- 3 files changed, 114 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/wheels.yml diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml new file mode 100644 index 00000000..6aecc63b --- /dev/null +++ b/.github/workflows/wheels.yml @@ -0,0 +1,107 @@ +name: Python wheels + +# TODO: use sscache to speed up this workflow +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build_wheels: + name: Build wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macOS-latest] + + # fetch-depth: 0 is required to get the tags used to determine f3d version + steps: + - name: Checkout f3d-superbuild + uses: actions/checkout@v3 + with: + submodules: true + path: 'f3d-superbuild' + + # TODO: We are currently building wheels for master, it should be possible to select a tag + - name: Checkout f3d + uses: actions/checkout@v3 + with: + repository: 'f3d-app/f3d' + ref: 'master' + fetch-depth: 0 + path: 'f3d' + + - name: Recover VTK version to build + working-directory: ${{github.workspace}} + shell: bash + run: | + echo VTK_COMMIT_SHA=`cat ./f3d/.github/actions/vtk_commit_sha` >> $GITHUB_ENV + + - name: Setup Ninja Windows + if: runner.os == 'Windows' + shell: bash + run: | + choco install ninja + echo CMAKE_GENERATOR=Ninja >> $GITHUB_ENV + + - name: Setup MSVC Windows + if: runner.os == 'Windows' + uses: TheMrMilchmann/setup-msvc-dev@v2 + with: + arch: x64 + + - name: Escaping backslashes Windows + if: runner.os == 'Windows' + shell: bash + run: echo "ESCAPED_WS=${{github.workspace}}" | tr '\\' '/' >> $GITHUB_ENV + + - name: Build wheels + uses: pypa/cibuildwheel@v2.13.1 + with: + package-dir: ${{github.workspace}}/f3d + output-dir: ${{github.workspace}}/wheelhouse + config-file: ${{github.workspace}}/f3d/pyproject.toml + env: + CIBW_SKIP: '*-musl*' + # TODO: cross-compile ARM too + CIBW_ARCHS: native + CIBW_BUILD_VERBOSITY: 1 + CIBW_ENVIRONMENT: > + CMAKE_PREFIX_PATH=../f3d-superbuild-build/install + SKBUILD_CMAKE_ARGS=" + -DF3D_DEPENDENCIES_DIR=${{ env.ESCAPED_WS }}/f3d-superbuild-build/install/bin; + -DF3D_PLUGIN_BUILD_ALEMBIC=ON; + -DF3D_PLUGIN_BUILD_ASSIMP=ON; + -DF3D_PLUGIN_BUILD_DRACO=ON; + -DF3D_PLUGIN_BUILD_OCCT=ON; + -DF3D_PLUGIN_OCCT_COLORING_SUPPORT=ON; + -DF3D_MODULE_EXR=ON; + -DF3D_MODULE_EXTERNAL_RENDERING=ON" + CIBW_ENVIRONMENT_PASS_LINUX: > + CMAKE_PREFIX_PATH + SKBUILD_CMAKE_ARGS + CIBW_REPAIR_WHEEL_COMMAND: '' + CIBW_BEFORE_ALL: > + cmake -S f3d-superbuild -B f3d-superbuild-build + -DBUILD_SHARED_LIBS=OFF + -DCMAKE_BUILD_TYPE=Release + -DENABLE_f3d=OFF + -DENABLE_alembic=ON + -DENABLE_assimp=ON + -DENABLE_draco=ON + -DENABLE_occt=ON + -DENABLE_openexr=ON + -DENABLE_ospray=OFF + -DENABLE_pybind11=ON + -DENABLE_tbb=ON + -DENABLE_vtk=ON + -DOCCT_ENABLE_COLORING=ON + -Dvtk_SOURCE_SELECTION=git + -Dvtk_GIT_TAG=${{ env.VTK_COMMIT_SHA }} && + cmake --build f3d-superbuild-build + + - uses: actions/upload-artifact@v3 + with: + name: ${{ runner.os }}-wheels + path: ./wheelhouse/*.whl diff --git a/projects/assimp.cmake b/projects/assimp.cmake index c6cfe525..574a00f4 100644 --- a/projects/assimp.cmake +++ b/projects/assimp.cmake @@ -2,6 +2,7 @@ superbuild_add_project(assimp BUILD_SHARED_LIBS_INDEPENDENT LICENSE_FILES LICENSE + DEPENDS zlib CMAKE_ARGS -DASSIMP_BUILD_ALL_IMPORTERS_BY_DEFAULT=OFF -DASSIMP_BUILD_ASSIMP_TOOLS=OFF @@ -11,7 +12,7 @@ superbuild_add_project(assimp -DASSIMP_BUILD_OFF_IMPORTER=ON -DASSIMP_BUILD_SAMPLES=OFF -DASSIMP_BUILD_TESTS=OFF - -DASSIMP_BUILD_ZLIB=ON + -DASSIMP_BUILD_ZLIB=OFF -DASSIMP_NO_EXPORT=ON -DASSIMP_WARNINGS_AS_ERRORS=OFF -DCMAKE_BUILD_TYPE=Release diff --git a/projects/vtk.cmake b/projects/vtk.cmake index 45305e2e..701bff69 100644 --- a/projects/vtk.cmake +++ b/projects/vtk.cmake @@ -10,12 +10,12 @@ if (UNIX) endif () endif () -set(vtk_smp_type "STDThread") -set(vtk_smp_enable_stdthread OFF) +set(vtk_smp_type "Sequential") +set(vtk_smp_enable_sequential OFF) if (tbb_enabled) set(vtk_smp_type "TBB") else () - set(vtk_smp_enable_stdthread ON) + set(vtk_smp_enable_sequential ON) endif () superbuild_add_project(vtk @@ -58,8 +58,8 @@ superbuild_add_project(vtk -DVTK_MODULE_ENABLE_VTK_RenderingVolumeOpenGL2=YES -DVTK_MODULE_ENABLE_VTK_TestingCore=YES -DVTK_OPENGL_HAS_EGL=${egl_enabled} - -DVTK_SMP_ENABLE_SEQUENTIAL=OFF - -DVTK_SMP_ENABLE_STDTHREAD=${vtk_smp_enable_stdthread} + -DVTK_SMP_ENABLE_SEQUENTIAL=${vtk_smp_enable_sequential} + -DVTK_SMP_ENABLE_STDTHREAD=OFF -DVTK_SMP_ENABLE_TBB=${tbb_enabled} -DVTK_SMP_IMPLEMENTATION_TYPE=${vtk_smp_type} -DVTK_VERSIONED_INSTALL=OFF