diff --git a/.github/workflows/macos-build.sh b/.github/workflows/macos-build.sh new file mode 100755 index 0000000..9f240b1 --- /dev/null +++ b/.github/workflows/macos-build.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +X86_TRIPLET=x86_64-apple-macos10.9 +ARM_TRIPLET=arm64-apple-macos11 + +git clone --depth=1 https://github.com/neubig/kytea.git +cd kytea + +rm -rf src/lib/.libs-arm64 src/lib/.libs-x86_64 src/lib/.libs.combined + +./configure --host="arm-apple-darwin22.1.0 " CXX="clang++ -target $ARM_TRIPLET" CC="clang -target $ARM_TRIPLET" + +make clean +make -j$(sysctl -n hw.logicalcpu_max) + +mv src/lib/.libs src/lib/.libs-arm64 + +./configure --host="x86_64-apple-darwin20.6.0" CXX="clang++ -target $X86_TRIPLET" CC="clang -target $X86_TRIPLET" + +make clean +make -j$(sysctl -n hw.logicalcpu_max) + +mv src/lib/.libs src/lib/.libs-x86_64 + +rm -rf src/lib/.libs.combined +mkdir src/lib/.libs.combined + +lipo -create src/lib/.libs-arm64/libkytea.0.dylib src/lib/.libs-x86_64/libkytea.0.dylib -output src/lib/.libs.combined/libkytea.0.dylib + +lipo -create src/lib/.libs-arm64/libkytea.a src/lib/.libs-x86_64/libkytea.a -output src/lib/.libs.combined/libkytea.a + +cp src/lib/.libs-arm64/libkytea.lai src/lib/.libs.combined/libkytea.lai + +ls -l src/lib/.libs-arm64/*.o | wihle read line; do + file=$(basename $file) + echo $file + lipo -create src/lib/.libs-arm64/$file src/lib/.libs-x86_64/$file -output src/lib/.libs.combined/$file +done + +cd src/lib/.libs.combined +ln -s libkytea.0.dylib libkytea.dylib +ln -s ../libkytea.a libkytea.a +cd ../../.. +mv src/lib/.libs.combined src/lib/.libs + +sudo make install +cd .. + +python -m cibuildwheel --output-dir wheelhouse diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 298bc9e..f6ed2b7 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -2,7 +2,6 @@ name: Build and upload to PyPI on: push: - pull_request: release: types: - published @@ -109,13 +108,11 @@ jobs: cp kytea\lib\libkytea.lib lib\kytea\ - name: Build wheels + if: runner.os != 'macOS' env: CIBW_BUILD: cp${{ matrix.python }}-${{ matrix.platform_id }} CIBW_ARCHS: all CIBW_BUILD_VERBOSITY: 3 - CIBW_REPAIR_WHEEL_COMMAND_MACOS: > - delocate-listdeps {wheel} && - delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel} CIBW_BEFORE_ALL_LINUX: > yum install -y wget && wget http://www.phontron.com/kytea/download/kytea-0.4.7.tar.gz && @@ -131,6 +128,17 @@ jobs: brew install kytea && swig -Wall -c++ -python -shadow -I$(brew --prefix)/include lib/kytea/mykytea.i run: python -m cibuildwheel --output-dir wheelhouse + - name: Build wheels if macOS + if: runner.os == 'macOS' + env: + CIBW_BUILD: cp${{ matrix.python }}-${{ matrix.platform_id }} + CIBW_REPAIR_WHEEL_COMMAND_MACOS: > + delocate-listdeps {wheel} && + delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel} + CIBW_ARCHS: x86_64,arm64,universal2 + CIBW_PLATFORM: macos + CIBW_BUILD_VERBOSITY: 3 + run: .github/workflows/macos-build.sh - uses: actions/upload-artifact@v4 with: