Skip to content

Commit d21e27e

Browse files
committed
CI: Refactor mac wheel build to use delocate rather than manual
1 parent 9089e52 commit d21e27e

File tree

2 files changed

+32
-73
lines changed

2 files changed

+32
-73
lines changed

.github/workflows/build.yml

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414

1515
build-linux:
1616
runs-on: ubuntu-latest
17-
if: true
17+
if: false
1818
env:
1919
MKL_URL: ""
2020
# MKL_URL: "https://registrationcenter-download.intel.com/akdlm/irc_nas/tec/16917/l_mkl_2020.4.304.tgz"
@@ -117,7 +117,7 @@ jobs:
117117
118118
build-windows:
119119
runs-on: windows-2025
120-
if: true
120+
if: false
121121
env:
122122
VS_VERSION: vs2022
123123
PLATFORM_TOOLSET: v143
@@ -350,7 +350,7 @@ jobs:
350350
351351
- name: Install dependencies for python build
352352
run: |
353-
python3 -m pip install --break-system-packages --user --upgrade setuptools wheel
353+
python3 -m pip install --break-system-packages --user --upgrade setuptools wheel delocate
354354
355355
- name: Build Python wheel
356356
run: |
@@ -359,6 +359,20 @@ jobs:
359359
${{ steps.cache-native-binaries-restore.outputs.cache-hit == 'true' && 'KALDIAG_BUILD_SKIP_NATIVE=1' || '' }} python3 setup.py bdist_wheel
360360
ls -al dist/
361361
362+
- name: Repair Mac wheel with delocate
363+
run: |
364+
shopt -s nullglob
365+
for whl in dist/*.whl; do
366+
echo "Wheel: $whl"
367+
python3 -m delocate.cmd.delocate_listdeps $whl
368+
python3 -m delocate.cmd.delocate_wheel -v -w wheelhouse --require-archs arm64 $whl
369+
done
370+
ls -al wheelhouse/
371+
for whl in wheelhouse/*.whl; do
372+
echo "Repaired Wheel: $whl"
373+
python3 -m delocate.cmd.delocate_listdeps $whl
374+
done
375+
362376
- name: Save cached native binaries
363377
if: steps.cache-native-binaries-restore.outputs.cache-hit != 'true'
364378
uses: actions/cache/save@v4
@@ -379,6 +393,7 @@ jobs:
379393
path: dist/*
380394

381395
- name: Examine results
396+
if: always()
382397
run: |
383398
for whl in dist/*.whl; do
384399
echo "Wheel: $whl"
@@ -387,7 +402,7 @@ jobs:
387402
388403
build-macos-intel:
389404
runs-on: macos-13
390-
if: true
405+
if: false
391406
env:
392407
MACOSX_DEPLOYMENT_TARGET: "10.9"
393408
MKL_URL: ""
@@ -449,7 +464,7 @@ jobs:
449464
450465
- name: Install dependencies for python build
451466
run: |
452-
python3 -m pip install --break-system-packages --user --upgrade setuptools wheel
467+
python3 -m pip install --break-system-packages --user --upgrade setuptools wheel delocate
453468
454469
- name: Build Python wheel
455470
run: |
@@ -458,6 +473,16 @@ jobs:
458473
${{ steps.cache-native-binaries-restore.outputs.cache-hit == 'true' && 'KALDIAG_BUILD_SKIP_NATIVE=1' || '' }} python3 setup.py bdist_wheel
459474
ls -al dist/
460475
476+
- name: Repair Mac wheel with delocate
477+
run: |
478+
shopt -s nullglob
479+
for whl in dist/*.whl; do
480+
echo "Repairing wheel: $whl"
481+
python3 -m delocate.cmd.delocate_wheel --require-archs x86_64 $whl
482+
python3 -m delocate.cmd.delocate_listdeps $whl
483+
done
484+
ls -al dist/
485+
461486
- name: Save cached native binaries
462487
if: steps.cache-native-binaries-restore.outputs.cache-hit != 'true'
463488
uses: actions/cache/save@v4
@@ -491,7 +516,7 @@ jobs:
491516
- build-windows
492517
- build-macos-arm
493518
- build-macos-intel
494-
if: ${{ always() && true }} # Run even if some build jobs failed
519+
if: ${{ always() && false }} # Run even if some build jobs failed
495520
defaults:
496521
run:
497522
shell: bash

CMakeLists.txt

Lines changed: 1 addition & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -23,33 +23,7 @@ set(BINARIES
2323
set(LIBRARIES
2424
src/lib/libkaldi-dragonfly${CMAKE_SHARED_LIBRARY_SUFFIX}
2525
)
26-
27-
# For MacOS, we handle all the "indirect" shared libraries manually.
28-
if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Darwin")
29-
list(APPEND LIBRARIES
30-
tools/openfst/lib/libfst${CMAKE_SHARED_LIBRARY_SUFFIX}
31-
tools/openfst/lib/libfstscript${CMAKE_SHARED_LIBRARY_SUFFIX}
32-
src/lib/libkaldi-base${CMAKE_SHARED_LIBRARY_SUFFIX}
33-
src/lib/libkaldi-chain${CMAKE_SHARED_LIBRARY_SUFFIX}
34-
src/lib/libkaldi-cudamatrix${CMAKE_SHARED_LIBRARY_SUFFIX}
35-
src/lib/libkaldi-decoder${CMAKE_SHARED_LIBRARY_SUFFIX}
36-
src/lib/libkaldi-feat${CMAKE_SHARED_LIBRARY_SUFFIX}
37-
src/lib/libkaldi-fstext${CMAKE_SHARED_LIBRARY_SUFFIX}
38-
src/lib/libkaldi-gmm${CMAKE_SHARED_LIBRARY_SUFFIX}
39-
src/lib/libkaldi-hmm${CMAKE_SHARED_LIBRARY_SUFFIX}
40-
src/lib/libkaldi-ivector${CMAKE_SHARED_LIBRARY_SUFFIX}
41-
src/lib/libkaldi-lat${CMAKE_SHARED_LIBRARY_SUFFIX}
42-
src/lib/libkaldi-lm${CMAKE_SHARED_LIBRARY_SUFFIX}
43-
src/lib/libkaldi-matrix${CMAKE_SHARED_LIBRARY_SUFFIX}
44-
src/lib/libkaldi-nnet2${CMAKE_SHARED_LIBRARY_SUFFIX}
45-
src/lib/libkaldi-nnet3${CMAKE_SHARED_LIBRARY_SUFFIX}
46-
src/lib/libkaldi-online2${CMAKE_SHARED_LIBRARY_SUFFIX}
47-
src/lib/libkaldi-rnnlm${CMAKE_SHARED_LIBRARY_SUFFIX}
48-
src/lib/libkaldi-transform${CMAKE_SHARED_LIBRARY_SUFFIX}
49-
src/lib/libkaldi-tree${CMAKE_SHARED_LIBRARY_SUFFIX}
50-
src/lib/libkaldi-util${CMAKE_SHARED_LIBRARY_SUFFIX}
51-
)
52-
endif()
26+
# FIXME: Should we add other libraries, so they get stripped too?
5327

5428
if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows")
5529
message(FATAL_ERROR "CMake build not supported on Windows")
@@ -124,44 +98,4 @@ if(NOT "${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows")
12498
)
12599
endif()
126100

127-
# Fix dynamic libraries loading paths on macOS. The libraries and
128-
# executables are built with RPATH settings embedded in them, pointing
129-
# to the locations in temporary directories used to build the
130-
# binaries. After package installation is done, these directories are
131-
# deleted and the dynamic libraries cannot be loaded. The following
132-
# commands generate a shell script that fixes the paths to the dynamic
133-
# libraries in the built executables and the libraries themselves, so
134-
# that they can be loaded when placed in the same directory.
135-
# Also the commands add a custom target to invoke the generated script
136-
# after the external project (kaldi) has been built. An alternative
137-
# would be to change the kaldi engine build system to accept a path to
138-
# where the binaries would be placed and point RPATH to that location.
139-
if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Darwin")
140-
string (REPLACE ";" " " BINARIES_STR "${BINARIES}")
141-
string (REPLACE ";" " " LIBRARIES_STR "${LIBRARIES}")
142-
file(GENERATE OUTPUT name_fixer
143-
CONTENT
144-
"for a in ${BINARIES_STR} ; do
145-
a_bare=$\{a##*/\}
146-
install_name_tool -change ${PROJECT_BINARY_DIR}/kaldi-prefix/src/kaldi/tools/openfst-1.6.7/lib/libfst.10.dylib \"@loader_path/libfst.dylib\" ${DST}$a_bare
147-
install_name_tool -change ${PROJECT_BINARY_DIR}/kaldi-prefix/src/kaldi/tools/openfst-1.6.7/lib/libfstscript.10.dylib \"@loader_path/libfstscript.dylib\" ${DST}$a_bare
148-
for b in ${LIBRARIES_STR} ; do
149-
b_bare=$\{b##*/\}
150-
install_name_tool -change \"@rpath/$b_bare\" \"@loader_path/$b_bare\" ${DST}$a_bare
151-
done
152-
done
153-
for a in ${LIBRARIES_STR} ; do
154-
a_bare=$\{a##*/\}
155-
install_name_tool -id \"@loader_path/$a_bare\" ${DST}$a_bare
156-
install_name_tool -change ${PROJECT_BINARY_DIR}/kaldi-prefix/src/kaldi/tools/openfst-1.6.7/lib/libfst.10.dylib \"@loader_path/libfst.dylib\" ${DST}$a_bare
157-
install_name_tool -change ${PROJECT_BINARY_DIR}/kaldi-prefix/src/kaldi/tools/openfst-1.6.7/lib/libfstscript.10.dylib \"@loader_path/libfstscript.dylib\" ${DST}$a_bare
158-
for b in ${LIBRARIES_STR} ; do
159-
b_bare=$\{b##*/\}
160-
install_name_tool -change \"@rpath/$b_bare\" \"@loader_path/$b_bare\" ${DST}$a_bare
161-
done
162-
done")
163-
add_custom_target(fixer ALL COMMAND /bin/sh name_fixer)
164-
add_dependencies(fixer kaldi)
165-
endif()
166-
167101
install(CODE "MESSAGE(\"Installed kaldi engine binaries.\")")

0 commit comments

Comments
 (0)