Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
xuning
/
sherpaonnx
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Fangjun Kuang
2023-08-07 20:16:05 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Committed by
GitHub
2023-08-07 20:16:05 +0800
Commit
6235cb9f1beddc802e4a7458ecab496edff753aa
6235cb9f
1 parent
f7c05b15
Fix building wheels for Linux (#240)
隐藏空白字符变更
内嵌
并排对比
正在显示
3 个修改的文件
包含
109 行增加
和
2 行删除
.github/workflows/build-wheels.yaml
CMakeLists.txt
scripts/wheel/patch_wheel.py
.github/workflows/build-wheels.yaml
查看文件 @
6235cb9
...
...
@@ -41,7 +41,24 @@ jobs:
run
:
|
ls -lh ./wheelhouse/
ls -lh ./wheelhouse/*.whl
-
name
:
Install patchelf
if
:
matrix.os == 'ubuntu-latest'
shell
:
bash
run
:
|
sudo apt-get update -q
sudo apt-get install -q -y patchelf
patchelf --help
-
name
:
Patch wheels
shell
:
bash
if
:
matrix.os == 'ubuntu-latest'
run
:
|
mkdir ./wheels
sudo ./scripts/wheel/patch_wheel.py --in-dir ./wheelhouse --out-dir ./wheels
ls -lh ./wheels/
rm -rf ./wheelhouse
mv ./wheels ./wheelhouse
-
uses
:
actions/upload-artifact@v2
with
:
...
...
CMakeLists.txt
查看文件 @
6235cb9
cmake_minimum_required
(
VERSION 3.13 FATAL_ERROR
)
project
(
sherpa-onnx
)
set
(
SHERPA_ONNX_VERSION
"1.6.
0
"
)
set
(
SHERPA_ONNX_VERSION
"1.6.
1
"
)
# Disable warning about
#
...
...
scripts/wheel/patch_wheel.py
0 → 100755
查看文件 @
6235cb9
#!/usr/bin/env python3
# Copyright 2023 Xiaomi Corp. (authors: Fangjun Kuang)
import
argparse
import
glob
import
shutil
import
subprocess
import
sys
from
pathlib
import
Path
def
get_args
():
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"--in-dir"
,
type
=
Path
,
required
=
True
,
help
=
"Input directory."
,
)
parser
.
add_argument
(
"--out-dir"
,
type
=
Path
,
required
=
True
,
help
=
"Output directory."
,
)
return
parser
.
parse_args
()
def
process
(
out_dir
:
Path
,
whl
:
Path
):
tmp_dir
=
out_dir
/
"tmp"
subprocess
.
check_call
(
f
"unzip {whl} -d {tmp_dir}"
,
shell
=
True
)
if
"cp37"
in
str
(
whl
):
py_version
=
"3.7"
elif
"cp38"
in
str
(
whl
):
py_version
=
"3.8"
elif
"cp39"
in
str
(
whl
):
py_version
=
"3.9"
elif
"cp310"
in
str
(
whl
):
py_version
=
"3.10"
elif
"cp311"
in
str
(
whl
):
py_version
=
"3.11"
else
:
py_version
=
"3.12"
rpath_list
=
[
f
"$ORIGIN/../lib/python{py_version}/site-packages/sherpa_onnx/lib"
,
f
"$ORIGIN/../lib/python{py_version}/dist-packages/sherpa_onnx/lib"
,
#
f
"$ORIGIN/../lib/python{py_version}/site-packages/sherpa_onnx/lib64"
,
f
"$ORIGIN/../lib/python{py_version}/dist-packages/sherpa_onnx/lib64"
,
#
f
"$ORIGIN/../lib/python{py_version}/site-packages/sherpa_onnx.libs"
,
]
rpaths
=
":"
.
join
(
rpath_list
)
for
filename
in
glob
.
glob
(
f
"{tmp_dir}/sherpa_onnx-*data/data/bin/*"
,
recursive
=
True
):
print
(
filename
)
existing_rpath
=
(
subprocess
.
check_output
([
"patchelf"
,
"--print-rpath"
,
filename
])
.
decode
()
.
strip
()
)
target_rpaths
=
rpaths
+
":"
+
existing_rpath
subprocess
.
check_call
(
f
"patchelf --force-rpath --set-rpath '{target_rpaths}' {filename}"
,
shell
=
True
,
)
outwheel
=
Path
(
shutil
.
make_archive
(
whl
,
"zip"
,
tmp_dir
))
Path
(
outwheel
)
.
rename
(
out_dir
/
whl
.
name
)
shutil
.
rmtree
(
tmp_dir
)
def
main
():
args
=
get_args
()
print
(
args
)
in_dir
=
args
.
in_dir
out_dir
=
args
.
out_dir
out_dir
.
mkdir
(
exist_ok
=
True
,
parents
=
True
)
for
whl
in
in_dir
.
glob
(
"*.whl"
):
process
(
out_dir
,
whl
)
if
__name__
==
"__main__"
:
main
()
...
...
请
注册
或
登录
后发表评论