Skip to content

Commit ff82768

Browse files
committed
Pull pre-built sherpa-onnx instead of building it here
1 parent 0020030 commit ff82768

12 files changed

Lines changed: 172 additions & 522 deletions

File tree

.github/workflows/wheels.yml

Lines changed: 55 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Wheels
1+
name: Python
22

33
on:
44
workflow_dispatch:
@@ -12,11 +12,35 @@ on:
1212
permissions:
1313
contents: read
1414

15-
env:
16-
SHERPA_ONNX_REF: cc9366cb03e06ebcc19a7f3cdfe4c23bf219ee0b
17-
1815
jobs:
1916
build:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Check out repository
21+
uses: actions/checkout@v6
22+
with:
23+
persist-credentials: false
24+
25+
- name: Set up Python
26+
uses: actions/setup-python@v6
27+
with:
28+
python-version: "3.13"
29+
30+
- name: Install build tools
31+
run: python -m pip install --upgrade pip build
32+
33+
- name: Build artifacts
34+
run: python -m build
35+
36+
- name: Upload artifacts
37+
uses: actions/upload-artifact@v4
38+
with:
39+
name: dist
40+
path: dist/*
41+
42+
unit-tests:
43+
needs: build
2044
name: ${{ matrix.name }}
2145
runs-on: ${{ matrix.os }}
2246
strategy:
@@ -25,44 +49,50 @@ jobs:
2549
include:
2650
- name: linux-x86_64
2751
os: ubuntu-latest
52+
python-version: "3.9"
53+
sherpa-onnx-url: https://github.com/wfloat/sherpa-onnx/releases/download/v1.12.23/sherpa_onnx-1.12.23-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
2854
- name: windows-x86_64
2955
os: windows-latest
56+
python-version: "3.10"
57+
sherpa-onnx-url: https://github.com/wfloat/sherpa-onnx/releases/download/v1.12.23/sherpa_onnx-1.12.23-cp310-cp310-win_amd64.whl
3058
- name: macos-x86_64
3159
os: macos-15-intel
60+
python-version: "3.12"
61+
sherpa-onnx-url: https://github.com/wfloat/sherpa-onnx/releases/download/v1.12.23/sherpa_onnx-1.12.23-cp312-cp312-macosx_10_15_x86_64.whl
3262
- name: macos-arm64
3363
os: macos-15
64+
python-version: "3.13"
65+
sherpa-onnx-url: https://github.com/wfloat/sherpa-onnx/releases/download/v1.12.23/sherpa_onnx-1.12.23-cp313-cp313-macosx_11_0_arm64.whl
3466

3567
steps:
36-
- name: Check out wfloat-python
68+
- name: Check out repository
3769
uses: actions/checkout@v6
3870
with:
3971
persist-credentials: false
4072

41-
- name: Check out sherpa-onnx
42-
uses: actions/checkout@v6
73+
- name: Download artifacts
74+
uses: actions/download-artifact@v4
4375
with:
44-
repository: wfloat/sherpa-onnx
45-
ref: ${{ env.SHERPA_ONNX_REF }}
46-
path: sherpa-onnx
47-
persist-credentials: false
76+
name: dist
77+
path: dist
4878

4979
- name: Set up Python
5080
uses: actions/setup-python@v6
5181
with:
52-
python-version: "3.13"
82+
python-version: ${{ matrix.python-version }}
5383

54-
- name: Install cibuildwheel
55-
run: python -m pip install --upgrade pip cibuildwheel==3.4.1
84+
- name: Install sherpa-onnx release wheel
85+
shell: bash
86+
run: |
87+
python -m pip install --upgrade pip
88+
python -m pip install "${{ matrix.sherpa-onnx-url }}"
5689
57-
- name: Build wheels
58-
env:
59-
CIBW_ENVIRONMENT_PASS_LINUX: WFLOAT_SHERPA_ONNX_SOURCE_DIR MACOSX_DEPLOYMENT_TARGET
60-
MACOSX_DEPLOYMENT_TARGET: "13.4"
61-
WFLOAT_SHERPA_ONNX_SOURCE_DIR: ${{ runner.os == 'Linux' && '/project/sherpa-onnx' || format('{0}/sherpa-onnx', github.workspace) }}
62-
run: python -m cibuildwheel --output-dir wheelhouse
90+
- name: Install wfloat artifact
91+
shell: bash
92+
run: python -m pip install --no-deps dist/*.whl
6393

64-
- name: Upload wheels
65-
uses: actions/upload-artifact@v4
66-
with:
67-
name: wheels-${{ matrix.name }}
68-
path: wheelhouse/*.whl
94+
- name: Run unit tests
95+
run: python -m unittest discover -s tests -v
96+
97+
- name: Run integration smoke test
98+
run: python -c "import sherpa_onnx, wfloat; import wfloat._bindings as bindings; print(wfloat.__version__); print(sherpa_onnx.__version__); print(bindings.OfflineTts)"

CONTRIBUTING.md

Lines changed: 28 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -1,156 +1,69 @@
11
# Contributing
22

3-
This package wraps a native `sherpa-onnx` build, so building and publishing it
4-
is a little different from a pure-Python package.
3+
`wfloat` is now a pure Python package. Native code comes from a separately
4+
installed `sherpa-onnx` wheel.
55

66
## Prerequisites
77

8-
You will need:
8+
- Python 3.9+
9+
- a compatible `sherpa-onnx` wheel available from GitHub Releases or another
10+
package source
911

10-
- Python 3.8+
11-
- `cmake`
12-
- a working C/C++ toolchain
13-
- the `sherpa-onnx` source tree available locally
14-
15-
By default, `setup.py` expects the source tree to live at:
16-
17-
```text
18-
../../sherpa-onnx
19-
```
20-
21-
If your checkout lives somewhere else, set:
22-
23-
```bash
24-
export WFLOAT_SHERPA_ONNX_SOURCE_DIR=/absolute/path/to/sherpa-onnx
25-
```
26-
27-
## Local Setup
28-
29-
Create a virtualenv and install the packaging tools:
12+
## Local setup
3013

3114
```bash
3215
python3 -m venv .venv
3316
source .venv/bin/activate
3417
python -m pip install --upgrade pip
35-
python -m pip install setuptools wheel build twine ninja
18+
python -m pip install setuptools wheel build twine
3619
```
3720

38-
`ninja` is recommended for faster native builds, but it is not required.
39-
40-
## Build For Local Development
41-
42-
If you just want to compile the native extension locally, run:
21+
Install `sherpa-onnx` first if you want to exercise the low-level bindings:
4322

4423
```bash
45-
python setup.py build_ext --build-lib ./build-out --build-temp ./build-temp
24+
pip install https://github.com/wfloat/sherpa-onnx/releases/download/<tag>/<wheel>.whl
4625
```
4726

48-
This produces a local install tree under `build-out/` and temporary native build
49-
files under `build-temp/`.
50-
51-
These directories are generated artifacts and should not be committed.
52-
53-
## Build Release Artifacts
54-
55-
For release builds, set `WFLOAT_SHERPA_ONNX_SOURCE_DIR` to an absolute path.
56-
This package's wheel build compiles native code from the sibling
57-
`sherpa-onnx` checkout, and build tools may run parts of the build from a
58-
temporary directory where the default relative path no longer works.
27+
Then install `wfloat`:
5928

6029
```bash
61-
export WFLOAT_SHERPA_ONNX_SOURCE_DIR=/absolute/path/to/sherpa-onnx
30+
pip install -e .
6231
```
6332

64-
To build a release wheel:
33+
## Build release artifacts
6534

6635
```bash
6736
rm -rf build dist
68-
python -m build --wheel --no-isolation
37+
python -m build
6938
```
7039

71-
That should produce:
40+
That produces:
7241

7342
- `dist/*.whl`
43+
- `dist/*.tar.gz`
7444

75-
The package version comes from:
76-
77-
```text
78-
python/wfloat/_version.py
79-
```
80-
81-
Update that file before cutting a new PyPI release.
82-
83-
## CI Wheels
84-
85-
Multi-platform wheels are built in GitHub Actions with `cibuildwheel` via:
45+
## Tests
8646

87-
```text
88-
.github/workflows/wheels.yml
89-
```
90-
91-
That workflow checks out `wfloat-python`, checks out `wfloat/sherpa-onnx` as a
92-
workspace sibling, and builds wheel artifacts for:
93-
94-
- Linux x86_64
95-
- Windows x86_64
96-
- macOS x86_64
97-
- macOS arm64
98-
99-
The `sherpa-onnx` ref is currently controlled in the workflow file with the
100-
`SHERPA_ONNX_REF` environment variable. It is pinned to a specific commit so CI
101-
rebuilds against a stable native dependency.
102-
103-
The CI workflow intentionally builds wheels only. We should not publish an
104-
sdist until the source-distribution story no longer depends on an external
105-
`sherpa-onnx` checkout.
106-
107-
## Publish To PyPI
108-
109-
1. Build a fresh wheel:
47+
Unit tests do not require `sherpa-onnx`:
11048

11149
```bash
112-
rm -rf build dist
113-
python -m build --wheel --no-isolation
50+
python -m unittest discover -s tests -v
11451
```
11552

116-
2. Check the generated wheel:
53+
If you have installed a compatible `sherpa-onnx` wheel, you can also run a
54+
simple smoke check:
11755

11856
```bash
119-
python -m twine check dist/*
57+
python -c "import sherpa_onnx, wfloat; print(wfloat.__version__)"
12058
```
12159

122-
3. Upload to PyPI:
60+
## CI
12361

124-
```bash
125-
python -m twine upload dist/*
126-
```
62+
CI now:
12763

128-
If you want to dry-run the process first, upload to TestPyPI:
64+
- builds pure Python artifacts once
65+
- installs those artifacts on each target platform
66+
- runs the unit test suite
12967

130-
```bash
131-
python -m twine upload --repository testpypi dist/*
132-
```
133-
134-
## Notes
135-
136-
- The package publishes as `wfloat` on PyPI.
137-
- The CLI entrypoint is also `wfloat`.
138-
- Native builds may download third-party dependencies during the CMake step if
139-
they are not already available locally.
140-
- `python -m build` without `WFLOAT_SHERPA_ONNX_SOURCE_DIR` may fail because
141-
the wheel build can run from a temporary unpacked source tree.
142-
- CI wheel builds use normal PEP 517 build isolation through `cibuildwheel`.
143-
- We currently publish wheels, not a self-contained source distribution. The
144-
source distribution path should only be documented after it no longer depends
145-
on an external sibling `sherpa-onnx` checkout.
146-
- Release artifacts should be built from a clean tree so generated files do not
147-
get mixed into the package contents.
148-
149-
## Sanity Checks
150-
151-
Before publishing, it is worth running:
152-
153-
```bash
154-
PYTHONPATH=python python3 -m unittest discover -s tests -v
155-
python -m wfloat --help
156-
```
68+
After `sherpa-onnx` release assets are published, CI can add a platform-specific
69+
install step that pulls those wheel URLs before running integration smoke tests.

MANIFEST.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
include README.md
2-
recursive-include _build_support *.py
32
recursive-include python *.py

README.md

Lines changed: 15 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
# wfloat
22

3-
`wfloat` is the Python package for loading Wfloat-compatible speech models and
4-
generating audio files with `sherpa-onnx` under the hood.
3+
`wfloat` is a high-level Python wrapper around `sherpa-onnx` for loading
4+
Wfloat-compatible speech models and generating audio files.
55

6-
The intended high-level flow is:
6+
## Install
7+
8+
Install a compatible `sherpa-onnx` wheel first, then install `wfloat`:
9+
10+
```bash
11+
pip install https://github.com/wfloat/sherpa-onnx/releases/download/<tag>/<wheel>.whl
12+
pip install ./packages/wfloat-python
13+
```
14+
15+
## Usage
716

817
```python
918
import wfloat
@@ -19,38 +28,11 @@ result = model.generate(
1928
)
2029

2130
result.audio.save("out.wav")
22-
23-
print(result.audio.sample_rate)
24-
print(result.timeline.chunks[0].start_sec)
25-
```
26-
27-
## Status
28-
29-
The package now contains the high-level Python API shape:
30-
31-
- `wfloat.load(...)`
32-
- `model.generate(...)`
33-
- `model.generate_dialogue(...)`
34-
- `result.audio.save(...)`
35-
- timing metadata via `result.timeline`
36-
37-
The Python model asset endpoint still needs to return Python-compatible asset
38-
metadata for live downloads to work end to end.
39-
40-
## CLI
41-
42-
The package also exposes a `wfloat` CLI:
43-
44-
```bash
45-
wfloat synth --text "Hello world." --out out.wav
4631
```
4732

4833
## Notes
4934

50-
- The package is designed to cache model assets locally.
51-
- Voice IDs can be passed as strings such as `narrator_woman` or as numeric
52-
speaker IDs.
35+
- `wfloat` does not build or bundle native libraries.
36+
- Low-level bindings come from the installed `sherpa-onnx` wheel.
5337
- The public API is intentionally high-level; low-level native config objects
54-
are not the primary integration surface.
55-
56-
More implementation detail lives in [DESIGN.md](./DESIGN.md).
38+
are re-exported only for advanced use.

_build_support/__init__.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)