diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index ca37e422d0..af3ea8b93c 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -57,6 +57,31 @@ jobs: name: wheels-${{ matrix.platform }} path: ./wheelhouse/*.whl + build_universal_wheel: + name: Build universal wheel for Pyodide + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.11' + + - name: Install dependencies + run: pip install numpy versioneer wheel + + - name: Build universal wheel + run: | + PYODIDE=1 python setup.py bdist_wheel --universal + + - uses: actions/upload-artifact@v4 + with: + name: universal_wheel + path: dist/*.whl + check_dist: name: Check dist needs: [make_sdist,build_wheels] @@ -103,6 +128,11 @@ jobs: path: dist merge-multiple: true + - uses: actions/download-artifact@v4 + with: + name: universal_wheel + path: dist + - uses: pypa/gh-action-pypi-publish@v1.9.0 with: user: __token__ diff --git a/setup.py b/setup.py index 3f8eb225d8..09202a658c 100755 --- a/setup.py +++ b/setup.py @@ -1,4 +1,6 @@ #!/usr/bin/env python +import os + import numpy import versioneer from setuptools import Extension, setup @@ -11,17 +13,26 @@ NAME: str = dist.get_name() # type: ignore +# Check if building for Pyodide +is_pyodide = os.getenv("PYODIDE", "0") == "1" + +if is_pyodide: + # For pyodide we build a universal wheel that must be pure-python + # so we must omit the cython-version of scan. + ext_modules = [] +else: + ext_modules = [ + Extension( + name="pytensor.scan.scan_perform", + sources=["pytensor/scan/scan_perform.pyx"], + include_dirs=[numpy.get_include()], + ), + ] if __name__ == "__main__": setup( name=NAME, version=versioneer.get_version(), cmdclass=versioneer.get_cmdclass(), - ext_modules=[ - Extension( - name="pytensor.scan.scan_perform", - sources=["pytensor/scan/scan_perform.pyx"], - include_dirs=[numpy.get_include()], - ), - ], + ext_modules=ext_modules, )