Skip to content

Commit 24467a3

Browse files
committed
feat: Added <api>/check/<test> and added run-all-tests-via-api.py
Although the <api>/check endpoint worked just fine locally, it times out the workload on edge. So we need to be able to call each test one by one. So in addition to this, I added a <api>/list endpoint which lists all tests, then a /check/<test> endpoint which calls a singular test. This allows us to run just a specific test, if need be. Also added instructions on how this works to README.md
1 parent e0107f9 commit 24467a3

File tree

5 files changed

+395
-152
lines changed

5 files changed

+395
-152
lines changed

README.md

Lines changed: 162 additions & 149 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ Buildscripts to build numpy and other wheels for wasix. For convenience, this pa
8484

8585
The build script is controlled by the following environment variables:
8686

87-
* `CC`, `CXX`, `AR`, `LD`, `RANLIB`, etc... : The cross-compiler tools. These should all be normal clang tools, but target wasm32-wasix by default and use the wasix sysroot.
88-
* `WASIX_SYSROOT`: The path to the wasix sysroot that is used by the toolchain. Libraries will get installed here when you run `make install` or when they are required to build a package.
89-
* `INSTALL_DIR`: The path to the python library path. Wheels will get installed here when you run `make install`.
90-
* `WASMER`: The path to the wasmer binary. You must have it registered to handle wasm files as binfmt_misc. You can do this with `sudo $WASMER binfmt reregister`.
87+
- `CC`, `CXX`, `AR`, `LD`, `RANLIB`, etc... : The cross-compiler tools. These should all be normal clang tools, but target wasm32-wasix by default and use the wasix sysroot.
88+
- `WASIX_SYSROOT`: The path to the wasix sysroot that is used by the toolchain. Libraries will get installed here when you run `make install` or when they are required to build a package.
89+
- `INSTALL_DIR`: The path to the python library path. Wheels will get installed here when you run `make install`.
90+
- `WASMER`: The path to the wasmer binary. You must have it registered to handle wasm files as binfmt_misc. You can do this with `sudo $WASMER binfmt reregister`.
9191

9292
The easiest way to setup all the environment variables is to activate the wasix-clang environment using `source wasix-clang/activate`.
9393

@@ -154,111 +154,111 @@ Here is a list of the versions of the wheels and libraries that are included in
154154

155155
#### Wheels
156156

157-
* numpy: numpy/numpy main
158-
* markupsafe: 3.0.2
159-
* pandas: 2.3.2
160-
* pytz: 2025.2
161-
* dateutil: 2.9.0
162-
* tzdata: 2025.2
163-
* six: 1.17.0
164-
* msgpack: 1.1.0
165-
* pycryptodome: 3.23.0
166-
* pycryptodomex: 3.23.0
167-
* pyzbar: 0.1.9
168-
* cpython: 3.1.2
169-
* pypandoc: 1.15
170-
* pypandoc_binary: 1.15
171-
* psycopg: 3.2.9
172-
* psycopg-binary: 3.2.9
173-
* psycopg-pool: pool-3.2.6
174-
* brotlicffi: 1.1.0.0
175-
* cffi: 1.17.1
176-
* pillow: 11.3.0
177-
* matplotlib: 3.10.6
178-
* uvloop: 0.21.0
179-
* mysqlclient: 2.2.7
180-
* python-qrcode: 8.2
181-
* pycparser: 2.22
182-
* pydantic: 2.11.7
183-
* typing_extensions: 4.14.1
184-
* typing-inspection: 0.4.1
185-
* annotated-types: 0.7.0
186-
* shapely: 2.1.1
187-
* mrab-regex: 2025.7.31
188-
* lxml: 6.0.0
189-
* protobuf: 31.1
190-
* grpc: 1.74.1
191-
* numpy: 1.26.5
192-
* numpy: 2.0.2
193-
* numpy: 2.3.2
194-
* python-crc32c: 1.7.1
195-
* requests: 2.32.4
196-
* urllib3: 2.5.0
197-
* idna: 3.10
198-
* certifi: 2025.08.03
199-
* charset-normalizer: 3.4.3
200-
* pypng: 0.20250521.0
201-
* pyarrow: 19.0.1
202-
* pyarrow: 21.0.0
203-
* packaging: 25.0
204-
* pyparsing: 3.2.3
205-
* cycler: 0.12.1
206-
* kiwisolver: 1.4.9
207-
* contourpy: 1.3.3
208-
* pyopenssl: 25.1.0
209-
* aspw: 3.50.4.0
157+
- numpy: numpy/numpy main
158+
- markupsafe: 3.0.2
159+
- pandas: 2.3.2
160+
- pytz: 2025.2
161+
- dateutil: 2.9.0
162+
- tzdata: 2025.2
163+
- six: 1.17.0
164+
- msgpack: 1.1.0
165+
- pycryptodome: 3.23.0
166+
- pycryptodomex: 3.23.0
167+
- pyzbar: 0.1.9
168+
- cpython: 3.1.2
169+
- pypandoc: 1.15
170+
- pypandoc_binary: 1.15
171+
- psycopg: 3.2.9
172+
- psycopg-binary: 3.2.9
173+
- psycopg-pool: pool-3.2.6
174+
- brotlicffi: 1.1.0.0
175+
- cffi: 1.17.1
176+
- pillow: 11.3.0
177+
- matplotlib: 3.10.6
178+
- uvloop: 0.21.0
179+
- mysqlclient: 2.2.7
180+
- python-qrcode: 8.2
181+
- pycparser: 2.22
182+
- pydantic: 2.11.7
183+
- typing_extensions: 4.14.1
184+
- typing-inspection: 0.4.1
185+
- annotated-types: 0.7.0
186+
- shapely: 2.1.1
187+
- mrab-regex: 2025.7.31
188+
- lxml: 6.0.0
189+
- protobuf: 31.1
190+
- grpc: 1.74.1
191+
- numpy: 1.26.5
192+
- numpy: 2.0.2
193+
- numpy: 2.3.2
194+
- python-crc32c: 1.7.1
195+
- requests: 2.32.4
196+
- urllib3: 2.5.0
197+
- idna: 3.10
198+
- certifi: 2025.08.03
199+
- charset-normalizer: 3.4.3
200+
- pypng: 0.20250521.0
201+
- pyarrow: 19.0.1
202+
- pyarrow: 21.0.0
203+
- packaging: 25.0
204+
- pyparsing: 3.2.3
205+
- cycler: 0.12.1
206+
- kiwisolver: 1.4.9
207+
- contourpy: 1.3.3
208+
- pyopenssl: 25.1.0
209+
- aspw: 3.50.4.0
210210
<!-- WHEEL_VERSIONS_END -->
211211

212212
psycopg3-c is just the sdist of psycopg3-binary
213213

214214
#### Libraries
215215

216-
* libzbar: 0.23.93
217-
* libffi: wasix-org/libffi main
218-
* pandoc: haskell-wasm/pandoc wasm
219-
* postgresql: 17.5
220-
* brotli: 1.1.0
221-
* zlib: develop
222-
* 1.3.1 does not have proper cmake support, so we are using develop for now
223-
* libjpeg-turbo: 3.1.1
224-
* xz: 5.8.1
225-
* libtiff: 4.7.0
226-
* libwebp: 1.5.0
227-
* giflib: 5.2.2
228-
* libpng: 1.6.50
229-
* SDL: 3.2.16
230-
* SDL has all subsystems disabled
231-
* openjpeg: 2.5.3
232-
* libuv: 1.51.0
233-
* mariadb-connector-c: 3.4.6
234-
* openssl: 3.5.1
235-
* bzip2: 1.0.8
236-
* util-linux: 2.41.1
237-
* We only build libuuid from util-linux
238-
* openssh: 10.0p2
239-
* dropbear: 2025.88
240-
* tinyxml2: 11.0.0
241-
* geos: 3.13.1
242-
* libxslt: 1.1.43
243-
* libxml2: 2.14.5
244-
* google-crc32c: 1.1.2
245-
* arrow: 19.0.1
246-
* arrow: 21.0.0
247-
* rapidjson: 1.1.0
248-
* icu: 77.1
249-
* readline: 8.2
250-
* ncurses: 6.4.20230225
251-
* curl: curl/curl ab18c04218ff316cd67b1e928c5cee579b2f66a0
252-
* This was the current commit in the wasix fork. We can probably update to the next release
253-
* pycurl: 7.45.6
254-
* sqlite: 3.50.4
255-
* wasix-libc: wasix-org/wasix-libc e4e5cfcf1009e690207821e9b3a63cdce2ee9e86
256-
* The commit before we removed fork. A few packages don't build if fork is not defined.
257-
* libcxx: wasix-org/llvm-project 6bb93a243f6d15855f485f5aec3810d9e2de150d
258-
* This is the commit that is currently used by wasix-libc
259-
* compiler-rt: wasix-org/llvm-project 6bb93a243f6d15855f485f5aec3810d9e2de150d
260-
* This is the commit that is currently used by wasix-libc
261-
<!-- LIB_VERSIONS_END -->
216+
- libzbar: 0.23.93
217+
- libffi: wasix-org/libffi main
218+
- pandoc: haskell-wasm/pandoc wasm
219+
- postgresql: 17.5
220+
- brotli: 1.1.0
221+
- zlib: develop
222+
- 1.3.1 does not have proper cmake support, so we are using develop for now
223+
- libjpeg-turbo: 3.1.1
224+
- xz: 5.8.1
225+
- libtiff: 4.7.0
226+
- libwebp: 1.5.0
227+
- giflib: 5.2.2
228+
- libpng: 1.6.50
229+
- SDL: 3.2.16
230+
- SDL has all subsystems disabled
231+
- openjpeg: 2.5.3
232+
- libuv: 1.51.0
233+
- mariadb-connector-c: 3.4.6
234+
- openssl: 3.5.1
235+
- bzip2: 1.0.8
236+
- util-linux: 2.41.1
237+
- We only build libuuid from util-linux
238+
- openssh: 10.0p2
239+
- dropbear: 2025.88
240+
- tinyxml2: 11.0.0
241+
- geos: 3.13.1
242+
- libxslt: 1.1.43
243+
- libxml2: 2.14.5
244+
- google-crc32c: 1.1.2
245+
- arrow: 19.0.1
246+
- arrow: 21.0.0
247+
- rapidjson: 1.1.0
248+
- icu: 77.1
249+
- readline: 8.2
250+
- ncurses: 6.4.20230225
251+
- curl: curl/curl ab18c04218ff316cd67b1e928c5cee579b2f66a0
252+
- This was the current commit in the wasix fork. We can probably update to the next release
253+
- pycurl: 7.45.6
254+
- sqlite: 3.50.4
255+
- wasix-libc: wasix-org/wasix-libc e4e5cfcf1009e690207821e9b3a63cdce2ee9e86
256+
- The commit before we removed fork. A few packages don't build if fork is not defined.
257+
- libcxx: wasix-org/llvm-project 6bb93a243f6d15855f485f5aec3810d9e2de150d
258+
- This is the commit that is currently used by wasix-libc
259+
- compiler-rt: wasix-org/llvm-project 6bb93a243f6d15855f485f5aec3810d9e2de150d
260+
- This is the commit that is currently used by wasix-libc
261+
<!-- LIB_VERSIONS_END -->
262262

263263
## Tests
264264

@@ -269,35 +269,48 @@ So there are two ways of running the tests, natively and with wasmer:
269269

270270
Requirements:
271271

272-
* Python 3.10+
273-
* `python -m venv env`
274-
* `source venv/bin/activate`
275-
* `pip install .`
276-
* `pip install pytest`
272+
- Python 3.10+
273+
- `python -m venv env`
274+
- `source venv/bin/activate`
275+
- `pip install .`
276+
- `pip install pytest`
277277

278278
I'm sure it's possible to do via uv, or poetry, or many other ways. But this works also.
279279

280280
Run tests:
281281

282-
* `python -m pytest`
283-
* Discovers files matching `*-test.py`, `*_test.py`, and `test_*.py` under `tests/`.
284-
* Files ending with `.skip.py` are ignored.
285-
* Files ending with `-broken.py` are marked as expected failures (strict). If they pass, the run reports XPASS and fails.
282+
- `python -m pytest`
283+
- Discovers files matching `*-test.py`, `*_test.py`, and `test_*.py` under `tests/`.
284+
- Files ending with `.skip.py` are ignored.
285+
- Files ending with `-broken.py` are marked as expected failures (strict). If they pass, the run reports XPASS and fails.
286286

287287
### Wasmer
288288

289289
These are the instructions as of 2025-10, but there's a shipit looming, which may optimize the flow.
290-
If this doesn't work though, we have a bug:
291290

292291
Requirements:
293292

294-
* wasmer 6.1.0-rc.3+
293+
- wasmer 6.1.0-rc.3+
295294

296295
Run tests:
297296

298-
* `uv pip compile pyproject.toml --python-version=3.13 --universal --extra-index-url https://pythonindex.wasix.org/simple --index-url=https://pypi.org/simple --emit-index-url --only-binary :all: -o wasmer-requirements.txt`
299-
* `uvx pip install -r wasmer-requirements.txt --target wasix-site-packages --platform wasix_wasm32 --only-binary=:all: --python-version=3.13 --compile`
300-
* `wasmer run .`
297+
- `uv pip compile pyproject.toml --python-version=3.13 --universal --extra-index-url https://pythonindex.wasix.org/simple --index-url=https://pypi.org/simple --emit-index-url --only-binary :all: -o wasmer-requirements.txt`
298+
- `uvx pip install -r wasmer-requirements.txt --target wasix-site-packages --platform wasix_wasm32 --only-binary=:all: --python-version=3.13 --compile`
299+
- `TEST_DIR=/tests/ wasmer run . --registry=wasmer.wtf --net --forward-host-env`
300+
- `curl localhost:8081/check`
301+
302+
This will run all tests via fastapi.
303+
304+
You may also run each test individually by:
305+
306+
- `curl localhost:80801/list`
307+
- `curl localhost:8081/check/<test-file>`
308+
309+
This is needed when testing on edge, since `.../check` times out the workload.
310+
In conjunction with this, there is a convenience script which runs all tests each in a separate query.
311+
312+
So you may also run `./run-all-tests-via-api.py --host <hostname> --port <port>`.
313+
This is intended to be run to validate package functionaltiy on edge, as each test becomes a separate workload.
301314

302315
### Notes
303316

@@ -325,7 +338,7 @@ to check which python libraries depend on shared libs. We try to keep that to a
325338

326339
### Structure
327340

328-
<!--
341+
<!--
329342
There is the pkgs folder that contains most stuff
330343
331344
For each project that can be built there are multiple files depending on the type.
@@ -351,52 +364,52 @@ TODO: Make this more understandable
351364

352365
Inside the pkgs/ folder there can be the following directories:
353366

354-
* `*.source`: clean submodule checkout
355-
* `*.prepared`: patched worktree of source
356-
* `*.build`: temporary build directory
357-
* `*.tar.gz`: python sdist
358-
* `*.sdist`: unpacked python sdist
359-
* `*.whl`: compiled python wheel
360-
* `*.wheel`: unpacked python wheel
361-
* `*.lib`: unpacked library/application
362-
* `*.tar.xz`: packed library/application
367+
- `*.source`: clean submodule checkout
368+
- `*.prepared`: patched worktree of source
369+
- `*.build`: temporary build directory
370+
- `*.tar.gz`: python sdist
371+
- `*.sdist`: unpacked python sdist
372+
- `*.whl`: compiled python wheel
373+
- `*.wheel`: unpacked python wheel
374+
- `*.lib`: unpacked library/application
375+
- `*.tar.xz`: packed library/application
363376

364377
#### Base structure
365378

366379
Each project follows a consistent flow through the first three main directories.
367380

368-
* `*.source`
369-
* This is a clean checkout of the project's upstream source code, tracked as a git submodule.
370-
* We avoid modifying this directly, since changes here would slow down git operations in the build-scripts repo.
371-
* `*.prepared`
372-
* A git worktree created from the `*.source` repository.
373-
* If patches are needed, they're applied here.
374-
* If no patches are needed, it's just a clean mirror of the source.
375-
* This directory is persistent and only refreshed if the source changes so new patches can be developed in this directory
376-
* `*.build`
377-
* A copy of the `*.prepared` directory, used for the actual build step.
378-
* Contains all intermediate build artifacts.
379-
* This directory is temporary and may be deleted between builds. Never make manual changes here.
381+
- `*.source`
382+
- This is a clean checkout of the project's upstream source code, tracked as a git submodule.
383+
- We avoid modifying this directly, since changes here would slow down git operations in the build-scripts repo.
384+
- `*.prepared`
385+
- A git worktree created from the `*.source` repository.
386+
- If patches are needed, they're applied here.
387+
- If no patches are needed, it's just a clean mirror of the source.
388+
- This directory is persistent and only refreshed if the source changes so new patches can be developed in this directory
389+
- `*.build`
390+
- A copy of the `*.prepared` directory, used for the actual build step.
391+
- Contains all intermediate build artifacts.
392+
- This directory is temporary and may be deleted between builds. Never make manual changes here.
380393

381394
The remaining steps are different depending on the type of project.
382395

383396
#### Python modules
384397

385-
* The build step creates a `*.tar.gz` sdist from the `*.build` directory.
386-
* The sdist is then extracted into a `*.sdist` folder.
387-
* Finally, a wheel (`*.whl`) is built from the `*.sdist`.
388-
* If you want to you can make a `*.wheel` directory to view the unpacked wheel
398+
- The build step creates a `*.tar.gz` sdist from the `*.build` directory.
399+
- The sdist is then extracted into a `*.sdist` folder.
400+
- Finally, a wheel (`*.whl`) is built from the `*.sdist`.
401+
- If you want to you can make a `*.wheel` directory to view the unpacked wheel
389402

390403
#### WASIX libraries and applications
391404

392-
* The build step builds the library and installs it into a `*.lib` folder, following the correct directory structure.
393-
* That folder is then compressed into a final distributable *.tar.xz.
405+
- The build step builds the library and installs it into a `*.lib` folder, following the correct directory structure.
406+
- That folder is then compressed into a final distributable \*.tar.xz.
394407

395408
#### Interdependencies
396409

397410
If a project depends on other project they can either be direct dependencies of that project or you can define a `*.sysroot` target with the dependencies as prerequisites.
398411

399-
* `*.sysroot`
400-
* Contains the merged builds of multiple other projects
401-
* Useful when a project is using pkg-config to find its dependencies
402-
* Automatically builds a sysroot from its list of prerequisites
412+
- `*.sysroot`
413+
- Contains the merged builds of multiple other projects
414+
- Useful when a project is using pkg-config to find its dependencies
415+
- Automatically builds a sysroot from its list of prerequisites

0 commit comments

Comments
 (0)