diff --git a/.github/workflows/build_arm64_mac_wheels.yml b/.github/workflows/build_arm64_mac_wheels.yml new file mode 100644 index 000000000..ac83c1e8a --- /dev/null +++ b/.github/workflows/build_arm64_mac_wheels.yml @@ -0,0 +1,98 @@ +name: Build and Publish Wheels (Mac OSX Arm64) + +on: + workflow_dispatch: + release: + types: [published] + pull_request: + branches: + - "**" +jobs: + build-mac: + name: Mac OSX Arm64 Python ${{ matrix.python-version }} - Build Wheels + runs-on: macos-14 + strategy: + matrix: + python-version: ["3.8", "3.9", "3.10", "3.11"] + include: + - python-version: "3.8" + PYTHON_VERSION_CODE: cp38-cp38 + PYTHON_VERSION_NUMBER: "3.8" + - python-version: "3.9" + PYTHON_VERSION_CODE: cp39-cp39 + PYTHON_VERSION_NUMBER: "3.9" + - python-version: "3.10" + PYTHON_VERSION_CODE: cp310-cp310 + PYTHON_VERSION_NUMBER: "3.10" + - python-version: "3.11" + PYTHON_VERSION_CODE: cp311-cp311 + PYTHON_VERSION_NUMBER: "3.11" + steps: + - name: Check out the repo + uses: actions/checkout@v2 + - name: Select Python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + architecture: "arm64" + - name: Set variables + run: | + VER=$(cat ./VERSION.txt) + echo "VERSION=$VER" + echo "VERSION=$VER" >> $GITHUB_ENV + - name: Test environment + run: | + echo "VERSION=${{ env.VERSION }}" + echo "PYTHON_VERSION_CODE=${{ matrix.PYTHON_VERSION_CODE }}" + echo "PYTHON_VERSION_NUMBER=${{ matrix.PYTHON_VERSION_NUMBER }}" + - name: Install pytest, wheel, auditwheel, pybind11-stubgen, numpy and torch + run: python -m pip install pytest wheel auditwheel numpy torch + - name: Install dependencies + run: ci/mac/install_dependencies.sh + - name: Build wheel + run: | + cd ci/mac + ./build_wheels_arm64.sh + env: + PYTHON: ${{ matrix.PYTHON }} + ARCHFLAGS: "-arch arm64" + CFLAGS: "-arch arm64" + CXXFLAGS: "-arch arm64" + _PYTHON_HOST_PLATFORM: "macosx-11.0-arm64" + PYTHON_VERSION: ${{ matrix.PYTHON_VERSION_CODE }} + PYTHON_VERSION_NUMBER: ${{ matrix.PYTHON_VERSION_NUMBER }} + DYLD_PRINT_LIBRARIES: 1 + - name: Publish artifact + uses: actions/upload-artifact@v4 + with: + name: nimblephysics-${{ env.VERSION }}-${{ matrix.PYTHON_VERSION_CODE }}-macosx_11_0_arm64.whl + path: wheelhouse/nimblephysics-${{ env.VERSION }}-${{ matrix.PYTHON_VERSION_CODE }}-macosx_11_0_arm64.whl +# publish: +# name: Publish to PyPI +# runs-on: ubuntu-latest +# needs: [build-mac] +# steps: +# - name: Download artifacts +# uses: actions/download-artifact@v2 +# with: +# path: wheelhouse +# - name: Display structure of downloaded files before flattening +# run: ls -R +# working-directory: wheelhouse +# - name: Flatten files +# run: | +# mkdir wheelhouse2 +# find wheelhouse -type f -exec mv {} wheelhouse2 \; +# rm -rf wheelhouse +# mv wheelhouse2 wheelhouse +# - name: Display structure of downloaded files after flattening +# run: ls -R +# working-directory: wheelhouse +# - name: Publish package to PyPI +# uses: pypa/gh-action-pypi-publish@release/v1.8 +# with: +# user: __token__ +# password: ${{ secrets.PYPI_API_TOKEN }} +# packages_dir: wheelhouse/ +# skip_existing: true +# verbose: true diff --git a/.github/workflows/build_x86_mac_wheels.yml b/.github/workflows/build_x86_mac_wheels.yml index 8140680c1..4e2654a22 100644 --- a/.github/workflows/build_x86_mac_wheels.yml +++ b/.github/workflows/build_x86_mac_wheels.yml @@ -1,4 +1,4 @@ -name: Build and Publish Wheels (Mac OSX x86_64 only) +name: Build and Publish Wheels (Mac OSX x86_64) on: workflow_dispatch: @@ -6,7 +6,7 @@ on: types: [published] jobs: build-mac: - name: Mac OSX Python ${{ matrix.python-version }} - Build Wheels + name: Mac OSX x86_64 Python ${{ matrix.python-version }} - Build Wheels runs-on: macos-12 strategy: matrix: diff --git a/ci/mac/build_wheels_arm64.sh b/ci/mac/build_wheels_arm64.sh new file mode 100644 index 000000000..495beb140 --- /dev/null +++ b/ci/mac/build_wheels_arm64.sh @@ -0,0 +1,38 @@ +#!/bin/bash +set -e + +export VERSION=$(cat ../../VERSION.txt) + +# Find our python paths +export PYTHON_INCLUDE=$(python3-config --includes) +echo "PYTHON_INCLUDE=${PYTHON_INCLUDE}" +export PYTHON_LIB=$(python3-config --libs) +echo "PYTHON_LIB=${PYTHON_LIB}" + +pushd ../.. + +mkdir -p bin +ln -sfn $(which python3) ./bin/python +export PATH=$(pwd)/bin:${PATH} +echo "python=$(which python)" + +rm -rf dist/* +rm -rf build/* +# rm -rf wheelhouse/* + +# Actually build the code +python setup.py sdist bdist_wheel --plat-name macosx-11.0-arm64 + +# Install delocate, to bundle dependencies into the wheel +pushd dist +WHEEL_NAME=$(ls *.whl) +echo "WHEEL_NAME=${WHEEL_NAME}" +DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:/usr/local/lib" delocate-wheel -w ../wheelhouse -v --dylibs-only ${WHEEL_NAME} +popd + +# Replace the ABI tag with a more general version if needed +# mv wheelhouse/nimblephysics-0.0.2-cp38-cp38-macosx_11_0_arm64.whl wheelhouse/nimblephysics-0.0.2-cp38-abi3-macosx_11_0_arm64.whl + +# Actually push the wheel to PyPI +# python3 -m pip install --user --upgrade twine +# python3 -m twine upload --repository pypi wheelhouse/* diff --git a/ci/mac/install_dependencies.sh b/ci/mac/install_dependencies.sh index 3f552995b..23cc8f05d 100755 --- a/ci/mac/install_dependencies.sh +++ b/ci/mac/install_dependencies.sh @@ -61,7 +61,7 @@ rm -rf libccd # Install ASSIMP git clone https://github.com/assimp/assimp.git pushd assimp -git checkout v5.0.1 +git checkout v5.4.3 mkdir build pushd build cmake .. @@ -240,7 +240,7 @@ PROTOBUF_VERSION="3.14.0" # brew install xz zlib bzip2 # Install grpc -git clone --recurse-submodules -b v1.33.2 https://github.com/grpc/grpc +git clone --recurse-submodules -b v1.67.0 https://github.com/grpc/grpc pushd grpc pushd third_party/protobuf git checkout v${PROTOBUF_VERSION}