|
1 | 1 | # Contributing |
2 | 2 |
|
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. |
5 | 5 |
|
6 | 6 | ## Prerequisites |
7 | 7 |
|
8 | | -You will need: |
| 8 | +- Python 3.9+ |
| 9 | +- a compatible `sherpa-onnx` wheel available from GitHub Releases or another |
| 10 | + package source |
9 | 11 |
|
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 |
30 | 13 |
|
31 | 14 | ```bash |
32 | 15 | python3 -m venv .venv |
33 | 16 | source .venv/bin/activate |
34 | 17 | 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 |
36 | 19 | ``` |
37 | 20 |
|
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: |
43 | 22 |
|
44 | 23 | ```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 |
46 | 25 | ``` |
47 | 26 |
|
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`: |
59 | 28 |
|
60 | 29 | ```bash |
61 | | -export WFLOAT_SHERPA_ONNX_SOURCE_DIR=/absolute/path/to/sherpa-onnx |
| 30 | +pip install -e . |
62 | 31 | ``` |
63 | 32 |
|
64 | | -To build a release wheel: |
| 33 | +## Build release artifacts |
65 | 34 |
|
66 | 35 | ```bash |
67 | 36 | rm -rf build dist |
68 | | -python -m build --wheel --no-isolation |
| 37 | +python -m build |
69 | 38 | ``` |
70 | 39 |
|
71 | | -That should produce: |
| 40 | +That produces: |
72 | 41 |
|
73 | 42 | - `dist/*.whl` |
| 43 | +- `dist/*.tar.gz` |
74 | 44 |
|
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 |
86 | 46 |
|
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`: |
110 | 48 |
|
111 | 49 | ```bash |
112 | | -rm -rf build dist |
113 | | -python -m build --wheel --no-isolation |
| 50 | +python -m unittest discover -s tests -v |
114 | 51 | ``` |
115 | 52 |
|
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: |
117 | 55 |
|
118 | 56 | ```bash |
119 | | -python -m twine check dist/* |
| 57 | +python -c "import sherpa_onnx, wfloat; print(wfloat.__version__)" |
120 | 58 | ``` |
121 | 59 |
|
122 | | -3. Upload to PyPI: |
| 60 | +## CI |
123 | 61 |
|
124 | | -```bash |
125 | | -python -m twine upload dist/* |
126 | | -``` |
| 62 | +CI now: |
127 | 63 |
|
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 |
129 | 67 |
|
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. |
0 commit comments