cds-astro / cds-healpix-python

cdshealpix python package
https://cds-astro.github.io/cds-healpix-python/
BSD 3-Clause "New" or "Revised" License
6 stars 3 forks source link

publish wheels for pyodide #15

Closed ManonMarchand closed 1 year ago

ManonMarchand commented 1 year ago

PyO3 should allow to build wheels compatible with micropip in theory, so we could try that.

ManonMarchand commented 1 year ago

might require to drop dependency to 'astropy-healpix' that is currently not available from pyodide

ManonMarchand commented 1 year ago

I could build a wheel but I don't know what the next step is so I opened an issue on pyodide github : https://github.com/pyodide/pyodide/issues/3675

ManonMarchand commented 1 year ago

Seen in ypy actions:

  wasm:
    runs-on: ubuntu-20.04
    # Pyodide began supporting `micropip.install` from emscripten-compiled binary wheels
    # in Pyodide 0.21.0 (Aug 2022), so no need to build wheels for versions before then.
    # As of Nov 2022, the matrix for emscripten/python versions since then is simple. 
    # Update this matrix when new Pyodide versions come out that bump the Python interpreter
    # or emscripten version. Ref: https://pyodide.org/en/stable/project/changelog.html
    strategy:
      matrix:
        python-version: ["3.10.*"]
        emscripten-version: ["3.1.14"]
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-python@v2
        with:
          python-version: ${{ matrix.python-version }}
          architecture: x64
      - name: Install Rust
        # if this isn't here, wasm wheel build fails with error: failed to run `rustc` to learn about target-specific information
        uses: actions-rs/toolchain@v1
        with:
            # maturin build will generate args -Z link-native-libraries=no which is only accepted on nightly compiler
            toolchain: nightly
            profile: minimal
            override: true
      - name: Rustup add wasm32 target
        # maturin build --target wasm32-unknown-emscripten requires rust to add that target first
        run: rustup target add wasm32-unknown-emscripten
      - name: Setup emsdk
        uses: mymindstorm/setup-emsdk@v11
        with: 
          version: ${{ matrix.emscripten-version }}
      - name: Build wheels
        uses: messense/maturin-action@v1
        with:
          target: wasm32-unknown-emscripten
          args: --release --out wasm_wheel --find-interpreter
      - name: Upload wheels
        uses: actions/upload-artifact@v2
        with:
          name: wasm_wheel
          path: wasm_wheel
ManonMarchand commented 1 year ago

Compilation and tests done. Wheels can be downloaded from here (the assets on github release). Next step will be to upload on micropip-forge when it exists.