-
Notifications
You must be signed in to change notification settings - Fork 34
WASM build #262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
agriyakhetarpal
wants to merge
109
commits into
flintlib:main
Choose a base branch
from
agriyakhetarpal:bld/wasm
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
WASM build #262
Changes from 91 commits
Commits
Show all changes
109 commits
Select commit
Hold shift + click to select a range
7072379
Add a CI job to build `libgmp`, `libmpfr`, `flint`, and `python-flint`
agriyakhetarpal a0c5c63
Find MPFR
agriyakhetarpal ffb88c4
Don't override Python's `PKG_CONFIG_PATH`
agriyakhetarpal d19caaf
Debug
agriyakhetarpal 443d008
Try to export WASM_LIBRARY_DIR properly
agriyakhetarpal 44ef505
Fix missing WASM lib dir
agriyakhetarpal 42f4069
Bump flint to 3.1.0
agriyakhetarpal 304a55c
Run the test suite
agriyakhetarpal 52a5674
Bump `flint` to version 3.1.2
agriyakhetarpal 5583688
is `is`/`is not` for comparison with `NoneType`
agriyakhetarpal cf5f246
Temporarily disable `test_polys` (FSM)
agriyakhetarpal a3af36a
Temporarily disable `test_factor_poly_mpoly`
agriyakhetarpal 35f811e
Cache WASM libs for CI speedups
agriyakhetarpal bcfeb29
Temporarily disable `test_fq_default`
agriyakhetarpal 5dc6770
Temporarily disable `test_fq_default_poly`
agriyakhetarpal 920e9fa
Merge branch 'main' into bld/wasm
agriyakhetarpal db1ef76
Bump to flint version 3.2.0-rc1 for WASM build
agriyakhetarpal c8b28af
Skip build if cache htis
agriyakhetarpal 7bbf568
Remove orphan `print(srcpath)` statement
agriyakhetarpal 6305a5d
Set host for Emscripten
agriyakhetarpal 4ef8028
Try passing `--disable-assembly`
agriyakhetarpal 21f6560
Check out flint HEAD
agriyakhetarpal 382cdec
Disable flint version check for Meson
agriyakhetarpal cf72955
Run `bootstrap.sh`
agriyakhetarpal 70bf4b6
Fix emconfigure command for wasm build
oscarbenjamin 174a9e9
Go back to using FLINT 3.2.0-rc1 instead of main.
oscarbenjamin eb61033
don't change working directory
oscarbenjamin da7dbec
Use FLINT main again for pyodide in CI
oscarbenjamin 7600c8f
Remove extra quotes in shell command
oscarbenjamin d9c39e7
Use --disable-pthread
oscarbenjamin 29fb4d8
Disable test_fmpz_mod
oscarbenjamin 08dc749
Disable several fmpz_mod tests
oscarbenjamin 280e4a7
Disable generic matrices tests
oscarbenjamin 82b1f6c
Disable gr.gen doctest
oscarbenjamin 1d3040d
Disable all doctests
oscarbenjamin 85a74df
uncomment test code
oscarbenjamin a921603
Reenable test_fmpz_mod
oscarbenjamin 8892f92
exit test_fmpz_mod early
oscarbenjamin e982938
Earlier return
oscarbenjamin 0465511
Earlier return
oscarbenjamin 92efdcc
earlier return
oscarbenjamin 43625d2
return later
oscarbenjamin 7ca1c9e
return later
oscarbenjamin 0b4fc94
Use fmpz_mod_discrete_log_pohlig_hellman_init
oscarbenjamin 26847c7
Skip medium modulus
oscarbenjamin 10d2838
Only use small moduli
oscarbenjamin 1a7ab4f
Use only small modulus
oscarbenjamin a850ba9
disable test_polys
oscarbenjamin e1b1ca6
Skip test_polys
oscarbenjamin 4230bb0
Skip factor tests
oscarbenjamin e57165f
test fq_default
oscarbenjamin 5f18365
Add custom fmpz_mod tests
oscarbenjamin 750239a
Comment out gr_nf doctests
oscarbenjamin 86ae85c
Use medium modulus
oscarbenjamin 56a1007
Skip fmpz_mod_ctx.__init__
oscarbenjamin 1021236
Don't cancelk concurrent CI runs
oscarbenjamin b1afaf3
Allow more fmpz_mod_ctx.__init__
oscarbenjamin 6610e3c
Return later
oscarbenjamin f115fee
Use fmpz_isprobabprime
oscarbenjamin 8bf1a8f
test fmpz_is_probabprime(2**127 - 1)
oscarbenjamin 42de9f2
Don't check is_prime in fmpz_mod
oscarbenjamin b5d2143
Use FLINT 3.2.0-rc2
oscarbenjamin 2d0a498
Use rc2 rather than rc1
oscarbenjamin defba52
Remove -C
oscarbenjamin 1e6a64e
Use same xbuildenv for building and installing
agriyakhetarpal 4a55de7
Bump to flint 3.2.2
agriyakhetarpal 4e49877
Use 2025-05-23 nightlies with Emscripten 4.0.9
agriyakhetarpal 24e9b37
Merge main
agriyakhetarpal 1ab75dc
Use `--url` for URL-based Pyodide xbuildenv nightlies
agriyakhetarpal f660e10
Temporarily disable `test_properties_poly_mpoly`
agriyakhetarpal 1bb29ed
Temporarily disable `test_factor_poly_mpoly`
agriyakhetarpal 5924e48
Temporarily disable `test_division_poly_mpoly`
agriyakhetarpal 3beafcf
Temporarily disable `test_use_fmpz_is_probabprime`
agriyakhetarpal bfd7e9c
Cache `python-flint` builds
agriyakhetarpal 80227ae
Use separate scripts for better caching
agriyakhetarpal e78c891
Try to patch `mpn_mod_ctx_clear` for FLINT
agriyakhetarpal 23841bc
Fix shebangs?
agriyakhetarpal a47accc
Skip `test_python_threads` under WASM
agriyakhetarpal d869f47
Drop my patch for mpn_mod_ctx_clear
agriyakhetarpal 2ce48b0
Build from flintlib/flint#2323 for `gr_ctx_clear`
agriyakhetarpal 5a9ca2a
Update signature of `gr_ctx_clear` to `void`
agriyakhetarpal c094491
Bootstrap before building from repo sources
agriyakhetarpal 747b970
Relax FLINT version, allow it to build
agriyakhetarpal 0eb0b28
Reset cache to build FLINT again
agriyakhetarpal a5a8adc
Fix test collection error from `pytest` decorator
agriyakhetarpal f554a0f
Comment gr_complex_algebraic_ca_ctx.new doctests
oscarbenjamin b88693c
Use flint main branch
oscarbenjamin d6cb3c9
Comment gr_nf_fmpz_poly_ctx doctests
oscarbenjamin c4d9f66
Comment out fmpz_poly.hilbert_class doctests
oscarbenjamin 01762bd
Add back is_prime check in fmpz_mod
oscarbenjamin 1785f11
Reenable most tests
oscarbenjamin f7a8c78
Try gr_nf doctests again
oscarbenjamin d9d9772
Comment out gr_nf again
oscarbenjamin 7530b4c
Revert "Relax FLINT version, allow it to build"
agriyakhetarpal 8c66006
Pass `flint_version_check=False` to build backend
agriyakhetarpal 232f4e1
Sort factors from nmod_poly.factor
oscarbenjamin 60c291e
Split out failing test
oscarbenjamin 5245adb
Include all tests
oscarbenjamin aaf3ab6
Fix randomised tests
oscarbenjamin b93a5c5
Sort factors in fq_default_poly.factor
oscarbenjamin b178ec9
skip flakey doctests
oscarbenjamin 83dcae6
skip flakey tests
oscarbenjamin 220ff1a
Reenable fmpz_poly.hilbert_class doctests
oscarbenjamin 1eee325
skip another flakey doctest
oscarbenjamin 02d33a2
Disable hilbert class poly doctests again
oscarbenjamin cf39a48
Skip flakey doctest
oscarbenjamin 6b7637c
reenable fmpz_poly.hilbert_class_poly doctest
oscarbenjamin ee057b4
Reenable gr_nf doctests
oscarbenjamin 8ced2dc
Disable gr_nf doctests again
oscarbenjamin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| name: Run Pyodide CI | ||
|
|
||
| on: | ||
| pull_request: | ||
| workflow_dispatch: | ||
|
|
||
| env: | ||
| FORCE_COLOR: 3 | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | ||
| # cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| PYODIDE_VERSION: "https://github.com/pyodide/pyodide-build-environment-nightly/releases/download/20250523-emscripten_4.0.9/xbuildenv.tar.bz2" | ||
| PYTHON_VERSION: 3.13 # any 3.13.x version works | ||
| EMSCRIPTEN_VERSION: 4.0.9 | ||
| NODE_VERSION: 22 | ||
| steps: | ||
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
|
|
||
| - name: Set up Python ${{ env.PYTHON_VERSION }} | ||
| uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0 | ||
| with: | ||
| python-version: ${{ env.PYTHON_VERSION }} | ||
|
|
||
| - name: Set up Emscripten toolchain | ||
| uses: mymindstorm/setup-emsdk@6ab9eb1bda2574c4ddb79809fc9247783eaf9021 # v14 | ||
| with: | ||
| version: ${{ env.EMSCRIPTEN_VERSION }} | ||
| actions-cache-folder: emsdk-cache | ||
|
|
||
| - name: Set up Node.js | ||
| uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0 | ||
| with: | ||
| node-version: ${{ env.NODE_VERSION }} | ||
|
|
||
| - name: Install pyodide-build | ||
| run: | | ||
| pip install pyodide-build | ||
| pyodide xbuildenv install --url ${{ env.PYODIDE_VERSION }} | ||
|
|
||
| - name: Restore WASM library directory from cache | ||
| id: cache-wasm-library-dir | ||
| uses: actions/cache/restore@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2 | ||
| with: | ||
| path: ${{ github.workspace }}/wasm-library-dir | ||
| key: wasm-library-dir-${{ hashFiles('bin/pyodide_build_libgmp.sh', 'bin/pyodide_build_libmpfr.sh', 'bin/pyodide_build_flint.sh') }}-0 | ||
|
|
||
| - name: Build libgmp | ||
| if: steps.cache-wasm-library-dir.outputs.cache-hit != 'true' | ||
| env: | ||
| CFLAGS: "-fPIC" | ||
| WASM_LIBRARY_DIR: ${{ github.workspace }}/wasm-library-dir | ||
| run: bin/pyodide_build_libgmp.sh | ||
|
|
||
| - name: Build libmpfr | ||
| if: steps.cache-wasm-library-dir.outputs.cache-hit != 'true' | ||
| env: | ||
| CFLAGS: "-fPIC" | ||
| WASM_LIBRARY_DIR: ${{ github.workspace }}/wasm-library-dir | ||
| run: bin/pyodide_build_libmpfr.sh | ||
|
|
||
| - name: Build flint | ||
| if: steps.cache-wasm-library-dir.outputs.cache-hit != 'true' | ||
| env: | ||
| CFLAGS: "-fPIC" | ||
| WASM_LIBRARY_DIR: ${{ github.workspace }}/wasm-library-dir | ||
| run: bin/pyodide_build_flint.sh | ||
|
|
||
| - name: Persist WASM library directory to cache | ||
| uses: actions/cache/save@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2 | ||
| with: | ||
| path: ${{ github.workspace }}/wasm-library-dir | ||
| key: wasm-library-dir-${{ hashFiles('bin/pyodide_build_libgmp.sh', 'bin/pyodide_build_libmpfr.sh', 'bin/pyodide_build_flint.sh') }}-0 | ||
|
|
||
| - name: Restore python-flint build directory from cache | ||
| uses: actions/cache/restore@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2 | ||
| with: | ||
| path: ${{ github.workspace }}/flint_wasm_build | ||
| key: flint-wasm-build-${{ hashFiles('**/meson.build', '**/pyproject.toml', '**/setup.py') }} | ||
|
|
||
| - name: Build python-flint | ||
| env: | ||
| WASM_LIBRARY_DIR: ${{ github.workspace }}/wasm-library-dir | ||
| run: | | ||
| export PKG_CONFIG_PATH="${{ env.WASM_LIBRARY_DIR }}/lib/pkgconfig:${PKG_CONFIG_PATH}" | ||
| export CFLAGS="-I${{ env.WASM_LIBRARY_DIR }}/include ${CFLAGS:-}" | ||
| export LDFLAGS="-L${{ env.WASM_LIBRARY_DIR }}/lib -lflint -lmpfr -lgmp ${LDFLAGS:-}" | ||
|
|
||
| echo "PKG_CONFIG_PATH=${PKG_CONFIG_PATH}" | ||
| echo "CFLAGS=${CFLAGS}" | ||
| echo "LDFLAGS=${LDFLAGS}" | ||
|
|
||
| pkg-config --modversion python3 | ||
| pkg-config --modversion mpfr | ||
| pkg-config --modversion flint | ||
|
|
||
| pyodide build -Cbuild-dir=flint_wasm_build | ||
|
|
||
| - name: Persist python-flint build directory to cache | ||
| uses: actions/cache/save@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2 | ||
| with: | ||
| path: ${{ github.workspace }}/flint_wasm_build | ||
| key: flint-wasm-build-${{ hashFiles('**/meson.build', '**/pyproject.toml', '**/setup.py') }} | ||
|
|
||
| - name: Set up Pyodide virtual environment and test python-flint | ||
| run: | | ||
| pyodide venv .venv-pyodide | ||
|
|
||
| source .venv-pyodide/bin/activate | ||
| pip install dist/*.whl | ||
|
|
||
| cd doc | ||
|
|
||
| pip install pytest hypothesis | ||
| # Don't use the cache provider plugin, as it doesn't work with Pyodide | ||
| # right now: https://github.com/pypa/cibuildwheel/issues/1966 | ||
| pytest -svra -p no:cacheprovider --pyargs flint |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -e | ||
|
|
||
| # curl -L https://github.com/flintlib/flint/releases/download/v3.2.2/flint-3.2.2.tar.xz -o flint-3.2.2.tar.xz | ||
| # tar -xf flint-3.2.2.tar.xz | ||
|
|
||
| git clone https://github.com/flintlib/flint flint-3.2.2 --branch main | ||
|
|
||
| cd flint-3.2.2 | ||
|
|
||
| ./bootstrap.sh | ||
|
|
||
| emconfigure ./configure \ | ||
| --disable-dependency-tracking \ | ||
| --disable-shared \ | ||
| --prefix=$WASM_LIBRARY_DIR \ | ||
| --with-gmp=$WASM_LIBRARY_DIR \ | ||
| --with-mpfr=$WASM_LIBRARY_DIR \ | ||
| --host=wasm32-unknown-emscripten \ | ||
| --disable-assembly \ | ||
| --disable-pthread | ||
|
|
||
| emmake make -j $(nproc) | ||
| emmake make install |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -e | ||
|
|
||
| curl -L https://ftp.gnu.org/gnu/gmp/gmp-6.3.0.tar.xz -o gmp-6.3.0.tar.xz | ||
| tar -xf gmp-6.3.0.tar.xz | ||
|
|
||
| cd gmp-6.3.0 | ||
|
|
||
| emconfigure ./configure \ | ||
| --disable-dependency-tracking \ | ||
| --host none \ | ||
| --disable-shared \ | ||
| --enable-static \ | ||
| --enable-cxx \ | ||
| --prefix=$WASM_LIBRARY_DIR | ||
|
|
||
| emmake make -j $(nproc) | ||
| emmake make install |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -e | ||
|
|
||
| curl -L https://ftp.gnu.org/gnu/mpfr/mpfr-4.2.1.tar.xz -o mpfr-4.2.1.tar.xz | ||
| tar -xf mpfr-4.2.1.tar.xz | ||
|
|
||
| cd mpfr-4.2.1 | ||
|
|
||
| emconfigure ./configure \ | ||
| --disable-dependency-tracking \ | ||
| --disable-shared \ | ||
| --with-gmp=$WASM_LIBRARY_DIR \ | ||
| --prefix=$WASM_LIBRARY_DIR | ||
|
|
||
| emmake make -j $(nproc) | ||
| emmake make install |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -614,20 +614,20 @@ cdef class fmpz_poly(flint_poly): | |
| return u | ||
|
|
||
| @staticmethod | ||
| def hilbert_class_poly(long D): | ||
| def hilbert_class_poly(slong D): | ||
| r""" | ||
| Returns the Hilbert class polynomial `H_D(x)` as an *fmpz_poly*. | ||
|
|
||
| >>> fmpz_poly.hilbert_class_poly(-3) | ||
| x | ||
| >>> fmpz_poly.hilbert_class_poly(-4) | ||
| x + (-1728) | ||
| >>> fmpz_poly.hilbert_class_poly(-59) | ||
| x^3 + 30197678080*x^2 + (-140811576541184)*x + 374643194001883136 | ||
| >>> fmpz_poly.hilbert_class_poly(-5) | ||
| Traceback (most recent call last): | ||
| ... | ||
| ValueError: D must be an imaginary quadratic discriminant | ||
| # >>> fmpz_poly.hilbert_class_poly(-3) | ||
| # x | ||
| # >>> fmpz_poly.hilbert_class_poly(-4) | ||
| # x + (-1728) | ||
| # >>> fmpz_poly.hilbert_class_poly(-59) | ||
| # x^3 + 30197678080*x^2 + (-140811576541184)*x + 374643194001883136 | ||
| # >>> fmpz_poly.hilbert_class_poly(-5) | ||
| # Traceback (most recent call last): | ||
| # ... | ||
| # ValueError: D must be an imaginary quadratic discriminant | ||
|
||
| """ | ||
| cdef fmpz_poly v = fmpz_poly() | ||
| acb_modular_hilbert_class_poly(v.val, D) | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.