-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
87899c2
commit 2e89994
Showing
4 changed files
with
137 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,7 @@ jobs: | |
python-version: ["cp37", "cp38", "cp39", "cp310", "cp311", "cp312"] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
|
@@ -38,8 +38,15 @@ jobs: | |
- name: Build wheels | ||
uses: pypa/[email protected] | ||
env: | ||
CIBW_BEFORE_ALL: | | ||
git clone --depth 1 https://github.com/alsa-project/alsa-lib | ||
cd alsa-lib | ||
./gitcompile | ||
cd .. | ||
echo "PWD" | ||
ls -lh /project/alsa-lib/src/.libs | ||
CIBW_ENVIRONMENT: CPLUS_INCLUDE_PATH=/project/alsa-lib/include:$CPLUS_INCLUDE_PATH SHERPA_NCNN_ALSA_LIB_DIR=/project/alsa-lib/src/.libs LD_LIBRARY_PATH=/project/build/bdist.linux-x86_64/wheel/sherpa_ncnn/lib:$SHERPA_NCNN_ALSA_LIB_DIR SHERPA_NCNN_MAKE_ARGS="VERBOSE=1" SHERPA_NCNN_ENABLE_ALSA=1 SHERPA_NCNN_CMAKE_ARGS='-DCMAKE_C_FLAGS="-march=armv8-a" -DCMAKE_CXX_FLAGS="-march=armv8-a"' | ||
CIBW_BUILD: "${{ matrix.python-version}}-* " | ||
CIBW_ENVIRONMENT: SHERPA_NCNN_CMAKE_ARGS='-DCMAKE_C_FLAGS="-march=armv8-a" -DCMAKE_CXX_FLAGS="-march=armv8-a"' | ||
CIBW_SKIP: "cp27-* cp35-* cp36-* *-win32 pp* *-musllinux* *-manylinux_i686" | ||
CIBW_BUILD_VERBOSITY: 3 | ||
CIBW_ARCHS_LINUX: aarch64 | ||
|
@@ -49,10 +56,9 @@ jobs: | |
run: | | ||
ls -lh ./wheelhouse/ | ||
ls -lh ./wheelhouse/*.whl | ||
- uses: actions/upload-artifact@v2 | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ matrix.python-version }} | ||
path: ./wheelhouse/*.whl | ||
|
||
- name: Publish wheels to PyPI | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,33 +26,60 @@ jobs: | |
python-version: ["cp37", "cp38", "cp39", "cp310", "cp311", "cp312"] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/checkout@v4 | ||
|
||
# see https://cibuildwheel.readthedocs.io/en/stable/changelog/ | ||
# for a list of versions | ||
- name: Build wheels | ||
uses: pypa/[email protected] | ||
env: | ||
CIBW_BEFORE_ALL: | | ||
git clone --depth 1 https://github.com/alsa-project/alsa-lib | ||
cd alsa-lib | ||
./gitcompile | ||
cd .. | ||
echo "PWD" | ||
ls -lh /project/alsa-lib/src/.libs | ||
CIBW_ENVIRONMENT: CPLUS_INCLUDE_PATH=/project/alsa-lib/include:$CPLUS_INCLUDE_PATH SHERPA_NCNN_ALSA_LIB_DIR=/project/alsa-lib/src/.libs LD_LIBRARY_PATH=/project/build/bdist.linux-x86_64/wheel/sherpa_ncnn/lib:$SHERPA_NCNN_ALSA_LIB_DIR SHERPA_NCNN_MAKE_ARGS="VERBOSE=1" SHERPA_NCNN_ENABLE_ALSA=1 | ||
CIBW_BUILD: "${{ matrix.python-version}}-* " | ||
CIBW_SKIP: "cp27-* cp35-* *-win32 pp* *-musllinux*" | ||
CIBW_SKIP: "cp27-* cp35-* cp36-* *-win32 pp* *-musllinux* *-manylinux_i686" | ||
CIBW_BUILD_VERBOSITY: 3 | ||
|
||
- name: Display wheels | ||
shell: bash | ||
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 | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ matrix.python-version }} | ||
path: ./wheelhouse/*.whl | ||
|
||
- name: Publish to huggingface | ||
if: matrix.python-version == 'cp38' | ||
env: | ||
HF_TOKEN: ${{ secrets.HF_TOKEN }} | ||
uses: nick-fields/retry@v2 | ||
uses: nick-fields/retry@v3 | ||
with: | ||
max_attempts: 20 | ||
timeout_seconds: 200 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#!/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_ncnn/lib", | ||
f"$ORIGIN/../lib/python{py_version}/dist-packages/sherpa_ncnn/lib", | ||
# | ||
f"$ORIGIN/../lib/python{py_version}/site-packages/sherpa_ncnn/lib64", | ||
f"$ORIGIN/../lib/python{py_version}/dist-packages/sherpa_ncnn/lib64", | ||
# | ||
f"$ORIGIN/../lib/python{py_version}/site-packages/sherpa_ncnn.libs", | ||
] | ||
rpaths = ":".join(rpath_list) | ||
|
||
for filename in glob.glob( | ||
f"{tmp_dir}/sherpa_ncnn-*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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters