Skip to content

Commit 5635c1b

Browse files
committed
feat: Setup local testing with pytest
1 parent 088c02e commit 5635c1b

20 files changed

+980
-283
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ __pycache__
1818
/pkgs/*.build
1919
/pkgs/*.prepared
2020
/pkgs/*.sysroot
21+
wasix-site-packages

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.13

README.md

Lines changed: 174 additions & 136 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,149 @@ 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

212-
psycopg3-c is just the sdist of psycopg3-binary
212+
psycopg3-c is just the sdist of psycopg3-binary## Running Tests
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 -->
262+
263+
## Tests
264+
265+
The whole point of these tests is to ensure that the packages works within the wasmer runtime.
266+
So there are two ways of running the tests, natively and with wasmer:
267+
268+
### Native
269+
270+
Requirements:
271+
272+
- Python 3.10+
273+
- `python -m venv env`
274+
- `source venv/bin/activate`
275+
- `pip install .`
276+
- `pip install pytest`
277+
278+
I'm sure it's possible to do via uv, or poetry, or many other ways. But this works also.
279+
280+
Run tests:
281+
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.
286+
287+
### Wasmer
288+
289+
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:
291+
292+
Requirements:
293+
294+
- wasmer 6.1.0-rc.3+
295+
296+
Run tests:
297+
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`
262300

263301
### Notes
264302

@@ -286,7 +324,7 @@ to check which python libraries depend on shared libs. We try to keep that to a
286324

287325
### Structure
288326

289-
<!--
327+
<!--
290328
There is the pkgs folder that contains most stuff
291329
292330
For each project that can be built there are multiple files depending on the type.
@@ -312,52 +350,52 @@ TODO: Make this more understandable
312350

313351
Inside the pkgs/ folder there can be the following directories:
314352

315-
* `*.source`: clean submodule checkout
316-
* `*.prepared`: patched worktree of source
317-
* `*.build`: temporary build directory
318-
* `*.tar.gz`: python sdist
319-
* `*.sdist`: unpacked python sdist
320-
* `*.whl`: compiled python wheel
321-
* `*.wheel`: unpacked python wheel
322-
* `*.lib`: unpacked library/application
323-
* `*.tar.xz`: packed library/application
353+
- `*.source`: clean submodule checkout
354+
- `*.prepared`: patched worktree of source
355+
- `*.build`: temporary build directory
356+
- `*.tar.gz`: python sdist
357+
- `*.sdist`: unpacked python sdist
358+
- `*.whl`: compiled python wheel
359+
- `*.wheel`: unpacked python wheel
360+
- `*.lib`: unpacked library/application
361+
- `*.tar.xz`: packed library/application
324362

325363
#### Base structure
326364

327365
Each project follows a consistent flow through the first three main directories.
328366

329-
* `*.source`
330-
* This is a clean checkout of the project's upstream source code, tracked as a git submodule.
331-
* We avoid modifying this directly, since changes here would slow down git operations in the build-scripts repo.
332-
* `*.prepared`
333-
* A git worktree created from the `*.source` repository.
334-
* If patches are needed, they're applied here.
335-
* If no patches are needed, it's just a clean mirror of the source.
336-
* This directory is persistent and only refreshed if the source changes so new patches can be developed in this directory
337-
* `*.build`
338-
* A copy of the `*.prepared` directory, used for the actual build step.
339-
* Contains all intermediate build artifacts.
340-
* This directory is temporary and may be deleted between builds. Never make manual changes here.
367+
- `*.source`
368+
- This is a clean checkout of the project's upstream source code, tracked as a git submodule.
369+
- We avoid modifying this directly, since changes here would slow down git operations in the build-scripts repo.
370+
- `*.prepared`
371+
- A git worktree created from the `*.source` repository.
372+
- If patches are needed, they're applied here.
373+
- If no patches are needed, it's just a clean mirror of the source.
374+
- This directory is persistent and only refreshed if the source changes so new patches can be developed in this directory
375+
- `*.build`
376+
- A copy of the `*.prepared` directory, used for the actual build step.
377+
- Contains all intermediate build artifacts.
378+
- This directory is temporary and may be deleted between builds. Never make manual changes here.
341379

342380
The remaining steps are different depending on the type of project.
343381

344382
#### Python modules
345383

346-
* The build step creates a `*.tar.gz` sdist from the `*.build` directory.
347-
* The sdist is then extracted into a `*.sdist` folder.
348-
* Finally, a wheel (`*.whl`) is built from the `*.sdist`.
349-
* If you want to you can make a `*.wheel` directory to view the unpacked wheel
384+
- The build step creates a `*.tar.gz` sdist from the `*.build` directory.
385+
- The sdist is then extracted into a `*.sdist` folder.
386+
- Finally, a wheel (`*.whl`) is built from the `*.sdist`.
387+
- If you want to you can make a `*.wheel` directory to view the unpacked wheel
350388

351389
#### WASIX libraries and applications
352390

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

356394
#### Interdependencies
357395

358396
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.
359397

360-
* `*.sysroot`
361-
* Contains the merged builds of multiple other projects
362-
* Useful when a project is using pkg-config to find its dependencies
363-
* Automatically builds a sysroot from its list of prerequisites
398+
- `*.sysroot`
399+
- Contains the merged builds of multiple other projects
400+
- Useful when a project is using pkg-config to find its dependencies
401+
- Automatically builds a sysroot from its list of prerequisites

0 commit comments

Comments
 (0)