Fangjun Kuang
Committed by GitHub

Publish osx-arm64 nuget package for .Net (#1003)

... ... @@ -64,7 +64,7 @@ def process_linux(s):
f.write(s)
def process_macos(s):
def process_macos(s, rid):
libs = [
"libespeak-ng.dylib",
"libkaldi-decoder-core.dylib",
... ... @@ -79,18 +79,18 @@ def process_macos(s):
"libsherpa-onnx-kaldifst-core.dylib",
"libucd.dylib",
]
prefix = f"{src_dir}/macos/"
prefix = f"{src_dir}/macos-{rid}/"
libs = [prefix + lib for lib in libs]
libs = "\n ;".join(libs)
d = get_dict()
d["dotnet_rid"] = "osx-x64"
d["dotnet_rid"] = f"osx-{rid}"
d["libs"] = libs
environment = jinja2.Environment()
template = environment.from_string(s)
s = template.render(**d)
with open("./macos/sherpa-onnx.runtime.csproj", "w") as f:
with open(f"./macos-{rid}/sherpa-onnx.runtime.csproj", "w") as f:
f.write(s)
... ... @@ -129,7 +129,8 @@ def process_windows(s, rid):
def main():
s = read_proj_file("./sherpa-onnx.csproj.runtime.in")
process_macos(s)
process_macos(s, "x64")
process_macos(s, "arm64")
process_linux(s)
process_windows(s, "x64")
process_windows(s, "x86")
... ...
... ... @@ -24,14 +24,16 @@ export src_dir
mkdir -p $src_dir
pushd $src_dir
mkdir -p linux macos windows-x64 windows-x86
mkdir -p linux macos-x64 macos-arm64 windows-x64 windows-x86
linux_wheel_filename=sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
linux_wheel=$src_dir/$linux_wheel_filename
macos_wheel_filename=sherpa_onnx-${SHERPA_ONNX_VERSION}-cp39-cp39-macosx_10_14_universal2.whl
macos_wheel=$src_dir/$macos_wheel_filename
macos_x64_wheel_filename=sherpa_onnx-${SHERPA_ONNX_VERSION}-cp39-cp39-macosx_11_0_x86_64.whl
macos_x64_wheel=$src_dir/$macos_x64_wheel_filename
macos_arm64_wheel_filename=sherpa_onnx-${SHERPA_ONNX_VERSION}-cp39-cp39-macosx_11_0_arm64.whl
macos_arm64_wheel=$src_dir/$macos_arm64_wheel_filename
windows_x64_wheel_filename=sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-win_amd64.whl
windows_x64_wheel=$src_dir/$windows_x64_wheel_filename
... ... @@ -60,17 +62,17 @@ if [ ! -f $src_dir/linux/libsherpa-onnx-core.so ]; then
cd ..
fi
if [ ! -f $src_dir/macos/libsherpa-onnx-core.dylib ]; then
echo "--- macOS x86_64/arm64 universal2---"
cd macos
if [ ! -f $src_dir/macos-x64/libsherpa-onnx-core.dylib ]; then
echo "--- macOS x86_64---"
cd macos-x64
mkdir -p wheel
cd wheel
if [ -f $macos_wheel ]; then
cp -v $macos_wheel .
if [ -f $macos_x64_wheel ]; then
cp -v $macos_x64_wheel .
else
curl -OL https://$HF_MIRROR/csukuangfj/sherpa-onnx-wheels/resolve/main/$macos_wheel_filename
curl -OL https://$HF_MIRROR/csukuangfj/sherpa-onnx-wheels/resolve/main/$macos_x64_wheel_filename
fi
unzip $macos_wheel_filename
unzip $macos_x64_wheel_filename
cp -v sherpa_onnx/lib/*.dylib ../
cd ..
... ... @@ -83,6 +85,28 @@ if [ ! -f $src_dir/macos/libsherpa-onnx-core.dylib ]; then
cd ..
fi
if [ ! -f $src_dir/macos-arm64/libsherpa-onnx-core.dylib ]; then
echo "--- macOS arm64---"
cd macos-arm64
mkdir -p wheel
cd wheel
if [ -f $macos_arm64_wheel ]; then
cp -v $macos_arm64_wheel .
else
curl -OL https://$HF_MIRROR/csukuangfj/sherpa-onnx-wheels/resolve/main/$macos_arm64_wheel_filename
fi
unzip $macos_arm64_wheel_filename
cp -v sherpa_onnx/lib/*.dylib ../
cd ..
rm -v libcargs.dylib
rm -v libonnxruntime.dylib
rm -v libpiper_phonemize.1.2.0.dylib libpiper_phonemize.dylib
rm -rf wheel
ls -lh
cd ..
fi
if [ ! -f $src_dir/windows-x64/sherpa-onnx-core.dll ]; then
echo "---windows x64---"
... ... @@ -124,7 +148,7 @@ fi
popd
mkdir -p macos linux windows-x64 windows-x86 all
mkdir -p macos-x64 macos-arm64 linux windows-x64 windows-x86 all
cp ./*.cs all
... ... @@ -135,7 +159,12 @@ dotnet build -c Release
dotnet pack -c Release -o ../packages
popd
pushd macos
pushd macos-x64
dotnet build -c Release
dotnet pack -c Release -o ../packages
popd
pushd macos-arm64
dotnet build -c Release
dotnet pack -c Release -o ../packages
popd
... ...
... ... @@ -5,7 +5,7 @@
<OutputType>Library</OutputType>
<LangVersion>10.0</LangVersion>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<RuntimeIdentifiers>linux-x64;osx-x64;win-x64</RuntimeIdentifiers>
<RuntimeIdentifiers>linux-x64;osx-x64;osx-arm64;win-x64;win-x86</RuntimeIdentifiers>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AssemblyName>sherpa-onnx</AssemblyName>
<Version>{{ version }}</Version>
... ... @@ -50,6 +50,7 @@
<ItemGroup>
<PackageReference Include="org.k2fsa.sherpa.onnx.runtime.linux-x64" Version="{{ version }}" />
<PackageReference Include="org.k2fsa.sherpa.onnx.runtime.osx-x64" Version="{{ version }}" />
<PackageReference Include="org.k2fsa.sherpa.onnx.runtime.osx-arm64" Version="{{ version }}" />
<PackageReference Include="org.k2fsa.sherpa.onnx.runtime.win-x64" Version="{{ version }}" />
<PackageReference Include="org.k2fsa.sherpa.onnx.runtime.win-x86" Version="{{ version }}" />
</ItemGroup>
... ...