From ae433fbe033b5bb5fde7e5c811afe796e35d8e05 Mon Sep 17 00:00:00 2001 From: Yashas Ambati Date: Wed, 19 Feb 2025 22:51:52 -0500 Subject: [PATCH] Create initial workflow for cibuildwheel --- .github/workflows/build-cibw.yml | 53 +++++++++++++++++++++++++++ .gitignore | 2 +- build_tools/wheels/build_wheels.sh | 7 ++++ build_tools/wheels/cibw_before_all.sh | 28 ++++++++++++++ 4 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/build-cibw.yml create mode 100644 build_tools/wheels/build_wheels.sh create mode 100644 build_tools/wheels/cibw_before_all.sh diff --git a/.github/workflows/build-cibw.yml b/.github/workflows/build-cibw.yml new file mode 100644 index 000000000..ef9603719 --- /dev/null +++ b/.github/workflows/build-cibw.yml @@ -0,0 +1,53 @@ +name: Build Wheels (cibuildwheel) + +on: [workflow_dispatch] + +jobs: + build_wheels: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-latest + python_version: "3.10" + cibw_python_version: 310 + platform_id: manylinux_x86_64 + manylinux_image: manylinux2014 + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python_version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python_version }} + + - name: Install Dependencies + run: | + sudo apt-get install -y wget libicu-dev python3-pip python3-setuptools libboost-all-dev ninja-build + python3 -m pip install -r python/dev_requirements.txt + + - name: Run CMake + run: | + cmake .. -DGTSAM_BUILD_PYTHON=1 -DGTSAM_PYTHON_VERSION=${{ matrix.python_version }} + + - name: Build and test wheels + env: + CIBW_BUILD: cp${{ matrix.cibw_python_version }}-${{ matrix.platform_id }} + CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.manylinux_image }} + CIBW_ARCHS: all + + CIBW_BUILD_FRONTEND: "build" + CIBW_BEFORE_ALL: bash {project}/build_tools/wheels/cibw_before_all.sh ${{ matrix.python_version }} {project} + + CIBW_BUILD_VERBOSITY: 1 + + run: bash {project}/build_tools/wheels/build_wheels.sh + + - name: Store artifacts + uses: actions/upload-artifact@v4 + with: + name: cibw-wheels-cp${{ matrix.cibw_python_version }}-${{ matrix.platform_id }} + path: wheelhouse/*.whl diff --git a/.gitignore b/.gitignore index 7496190b5..bca6a479f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -/build* +/build /debug* .idea *.pyc diff --git a/build_tools/wheels/build_wheels.sh b/build_tools/wheels/build_wheels.sh new file mode 100644 index 000000000..b8f0750a3 --- /dev/null +++ b/build_tools/wheels/build_wheels.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +set -e +set -x + +python -m pip install cibuildwheel +python -m cibuildwheel build/python --output-dir wheelhouse \ No newline at end of file diff --git a/build_tools/wheels/cibw_before_all.sh b/build_tools/wheels/cibw_before_all.sh new file mode 100644 index 000000000..0607a67ac --- /dev/null +++ b/build_tools/wheels/cibw_before_all.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +set -e +set -x + +PYTHON_VERSION="$1" +PROJECT_DIR="$2" + +export PYTHON="python${PYTHON_VERSION}" + +rm -rf /build/python + +export CMAKE_GENERATOR=Ninja +cmake $PROJECT_DIR \ + -B build \ + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \ + -DGTSAM_BUILD_TESTS=OFF \ + -DGTSAM_BUILD_UNSTABLE=${GTSAM_BUILD_UNSTABLE:-ON} \ + -DGTSAM_USE_QUATERNIONS=OFF \ + -DGTSAM_WITH_TBB=${GTSAM_WITH_TBB:-OFF} \ + -DGTSAM_BUILD_EXAMPLES_ALWAYS=OFF \ + -DGTSAM_BUILD_WITH_MARCH_NATIVE=OFF \ + -DGTSAM_BUILD_PYTHON=ON \ + -DGTSAM_UNSTABLE_BUILD_PYTHON=${GTSAM_BUILD_UNSTABLE:-ON} \ + -DGTSAM_PYTHON_VERSION=$PYTHON_VERSION \ + -DPYTHON_EXECUTABLE:FILEPATH=$(which $PYTHON) \ + -DGTSAM_ALLOW_DEPRECATED_SINCE_V43=OFF \ + -DCMAKE_INSTALL_PREFIX=$PROJECT_DIR/gtsam_install \ No newline at end of file