Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/pytests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,20 @@ jobs:
- name: Build wheel
run: |
python -m build --wheel

pyodide:
# WebAssembly (32-bit): cibuildwheel builds the wheels and runs the tests
# in Node.
name: Pyodide (WebAssembly)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Build and test
uses: pypa/cibuildwheel@v4.3.5
env:
CIBW_PLATFORM: pyodide
with:
config-file: "{package}/pyproject-cibuildwheel.toml"
22 changes: 21 additions & 1 deletion .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,28 @@ jobs:
path: ./wheelhouse/*.whl
if-no-files-found: error

build_pyodide:
name: Build Pyodide (WebAssembly) wheels
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
submodules: true
- name: Build wheels
uses: pypa/cibuildwheel@v4.3.5
env:
CIBW_PLATFORM: pyodide
with:
config-file: "{package}/pyproject-cibuildwheel.toml"

- uses: actions/upload-artifact@v4
with:
name: wheel-artifact-pyodide
path: ./wheelhouse/*.whl
if-no-files-found: error

upload_all:
needs: [build_wheels, sdist]
needs: [build_wheels, build_pyodide, sdist]
name: Uploading built packages to pypi for release.
runs-on: ubuntu-latest
# Only upload to PyPI when triggered by a tag (not manual workflow_dispatch).
Expand Down
6 changes: 6 additions & 0 deletions pyfusefilter/ffibuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,14 @@
all_src += src.read()


# Under Pyodide (WebAssembly), a wheel is tied to one Pyodide version anyway,
# so the limited API (abi3) gains nothing; and Pyodide 315 names abi3
# extensions with quotes (_xorfilter.abi3-"wasm32-emscripten".so), which
# Python then cannot import.
import sysconfig
ffi.set_source(
"_xorfilter", all_src,
py_limited_api=not sysconfig.get_platform().startswith("emscripten"),
)

ffi.cdef(
Expand Down
6 changes: 6 additions & 0 deletions pyproject-cibuildwheel.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,11 @@ archs = ["x86_64", "universal2", "arm64"]
# The workflow runs on both x86_64 and aarch64 runners; build natively on each.
archs = ["native"]

[tool.cibuildwheel.pyodide]
# WebAssembly wheels, one per Pyodide ABI (cp313: Pyodide 0.28 and 0.29;
# cp314: Pyodide 314; cp315). In a Pyodide venv, the pytest script starts
# with a shebang to a shell script, which macOS cannot run: python -m pytest.
test-command = "python -m pytest {project}/tests -q --import-mode=importlib"

[tool.cibuildwheel.windows]
archs = ["AMD64"]
7 changes: 5 additions & 2 deletions tests/test_fuse16.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from pyfusefilter import Fuse16
from random import sample
from random import randrange
import tempfile, os


Expand Down Expand Up @@ -66,7 +66,10 @@ def test_fuse16_few_segments():
# https://github.com/FastFilter/xor_singleheader/issues/77
for size in (3551, 11504, 11521, 12372, 13224, 37454):
for _ in range(5):
keys = sample(range(1 << 62), size)
keys = set()
while len(keys) < size:
keys.add(randrange(1 << 62))
keys = list(keys)
filter = Fuse16(keys)
for key in keys:
assert key in filter
7 changes: 5 additions & 2 deletions tests/test_fuse8.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from pyfusefilter import Fuse8
from random import sample
from random import randrange
import tempfile, os

def test_readme():
Expand Down Expand Up @@ -65,7 +65,10 @@ def test_fuse8_few_segments():
# https://github.com/FastFilter/xor_singleheader/issues/77
for size in (3551, 11504, 11521, 12372, 13224, 37454):
for _ in range(5):
keys = sample(range(1 << 62), size)
keys = set()
while len(keys) < size:
keys.add(randrange(1 << 62))
keys = list(keys)
filter = Fuse8(keys)
for key in keys:
assert key in filter
Loading