From 6d1546cdfd67052998b96f22bf0609dc5a5c03a8 Mon Sep 17 00:00:00 2001 From: Thomas Wiecki Date: Wed, 10 Jul 2024 18:25:40 +0300 Subject: [PATCH 01/10] Add building of pyodide universal wheels --- .github/workflows/pypi.yml | 33 ++++++++++++++++++++++++++++++--- setup.py | 26 ++++++++++++++++---------- 2 files changed, 46 insertions(+), 13 deletions(-) diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index ca37e422d0..9963535078 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -11,13 +11,10 @@ on: # Cancels all previous workflow runs for pull requests that have not completed. concurrency: - # The concurrency group contains the workflow name and the branch name for pull requests - # or the commit hash for any other events. group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} cancel-in-progress: true jobs: - # The job to build precompiled pypi wheels. make_sdist: name: Make SDist runs-on: ubuntu-latest @@ -57,6 +54,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.10' + + - name: Install dependencies + run: pip install numpy versioneer + + - name: Build universal wheel + run: | + PYODIDE=1 python setup.py bdist_wheel --universal + + - uses: actions/upload-artifact@v3 + with: + name: universal_wheel + path: dist/*.whl + check_dist: name: Check dist needs: [make_sdist,build_wheels] @@ -103,6 +125,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..fc7bab95e8 100755 --- a/setup.py +++ b/setup.py @@ -1,27 +1,33 @@ #!/usr/bin/env python import numpy -import versioneer from setuptools import Extension, setup from setuptools.dist import Distribution - +import os +import versioneer dist = Distribution() dist.parse_config_files() +NAME = dist.get_name() # type: ignore -NAME: str = dist.get_name() # type: ignore +# Check if building for Pyodide +is_pyodide = os.getenv('PYODIDE', '0') == '1' +# Define the ext_modules conditionally +ext_modules = [] +if not is_pyodide: + 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, ) From 24172829a2bc60bf0e38fbb5c5972cecc8c84151 Mon Sep 17 00:00:00 2001 From: Thomas Wiecki Date: Wed, 10 Jul 2024 18:29:28 +0300 Subject: [PATCH 02/10] precommit --- setup.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index fc7bab95e8..f4a506eb66 100755 --- a/setup.py +++ b/setup.py @@ -1,17 +1,20 @@ #!/usr/bin/env python +import os + import numpy from setuptools import Extension, setup from setuptools.dist import Distribution -import os + import versioneer + dist = Distribution() dist.parse_config_files() NAME = dist.get_name() # type: ignore # Check if building for Pyodide -is_pyodide = os.getenv('PYODIDE', '0') == '1' +is_pyodide = os.getenv("PYODIDE", "0") == "1" # Define the ext_modules conditionally ext_modules = [] From 42b333eff98eb2daab3b3aef775fa09c5ae5e8d6 Mon Sep 17 00:00:00 2001 From: Thomas Wiecki Date: Wed, 10 Jul 2024 19:00:20 +0300 Subject: [PATCH 03/10] Fix precommit. Readd comment. --- .github/workflows/pypi.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index 9963535078..ea621bb715 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -11,6 +11,8 @@ on: # Cancels all previous workflow runs for pull requests that have not completed. concurrency: + # The concurrency group contains the workflow name and the branch name for pull requests + # or the commit hash for any other events. group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} cancel-in-progress: true @@ -72,7 +74,7 @@ jobs: - name: Build universal wheel run: | - PYODIDE=1 python setup.py bdist_wheel --universal + PYODIDE=1 venv-sdist/bin/python setup.py bdist_wheel --universal - uses: actions/upload-artifact@v3 with: From 29b59bc92c5fc56ec1e701251961a4aaaee0236b Mon Sep 17 00:00:00 2001 From: Thomas Wiecki Date: Wed, 10 Jul 2024 19:26:44 +0300 Subject: [PATCH 04/10] Fix precommit2 --- .github/workflows/pypi.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index ea621bb715..2e0096bc10 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -74,7 +74,7 @@ jobs: - name: Build universal wheel run: | - PYODIDE=1 venv-sdist/bin/python setup.py bdist_wheel --universal + PYODIDE=1 python setup.py bdist_wheel --universal - uses: actions/upload-artifact@v3 with: From cc39616b9f45ce5403bad454220684a315e35e92 Mon Sep 17 00:00:00 2001 From: Ben Mares Date: Thu, 11 Jul 2024 09:43:28 +0200 Subject: [PATCH 05/10] Minor improvement to ext_modules conditional definition --- setup.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index f4a506eb66..6b5fa8f352 100755 --- a/setup.py +++ b/setup.py @@ -16,9 +16,11 @@ # Check if building for Pyodide is_pyodide = os.getenv("PYODIDE", "0") == "1" -# Define the ext_modules conditionally -ext_modules = [] -if not is_pyodide: +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", From 5e3bab68cf61bff90c951612b980f17324c251be Mon Sep 17 00:00:00 2001 From: Ben Mares Date: Thu, 11 Jul 2024 09:44:18 +0200 Subject: [PATCH 06/10] Bump Python version so that tomllib is included This way versioneer can read pyproject.toml --- .github/workflows/pypi.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index 2e0096bc10..2819e49702 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -67,7 +67,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: '3.10' + python-version: '3.11' - name: Install dependencies run: pip install numpy versioneer From b61d0486a252f03f24f7dd4267f9330a0c455070 Mon Sep 17 00:00:00 2001 From: Ben Mares Date: Thu, 11 Jul 2024 10:15:33 +0200 Subject: [PATCH 07/10] Add wheel package to build dependencies --- .github/workflows/pypi.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index 2819e49702..d0f78ce2dd 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -70,7 +70,7 @@ jobs: python-version: '3.11' - name: Install dependencies - run: pip install numpy versioneer + run: pip install numpy versioneer wheel - name: Build universal wheel run: | From 1eb15860f0a97749ea731c8f37f637e2935ed7d9 Mon Sep 17 00:00:00 2001 From: Thomas Wiecki Date: Fri, 9 Aug 2024 23:09:52 +0200 Subject: [PATCH 08/10] Update .github/workflows/pypi.yml --- .github/workflows/pypi.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index d0f78ce2dd..802c5c8c55 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -76,7 +76,7 @@ jobs: run: | PYODIDE=1 python setup.py bdist_wheel --universal - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: universal_wheel path: dist/*.whl From 68e533871b8d9a681f5d6c52b37a7a7b821bf5ff Mon Sep 17 00:00:00 2001 From: Thomas Wiecki Date: Fri, 9 Aug 2024 23:13:53 +0200 Subject: [PATCH 09/10] Revert unnecessary --- .github/workflows/pypi.yml | 1 + setup.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index 802c5c8c55..af3ea8b93c 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -17,6 +17,7 @@ concurrency: cancel-in-progress: true jobs: + # The job to build precompiled pypi wheels. make_sdist: name: Make SDist runs-on: ubuntu-latest diff --git a/setup.py b/setup.py index 6b5fa8f352..bc330ed459 100755 --- a/setup.py +++ b/setup.py @@ -11,7 +11,8 @@ dist = Distribution() dist.parse_config_files() -NAME = dist.get_name() # type: ignore + +NAME: str = dist.get_name() # type: ignore # Check if building for Pyodide is_pyodide = os.getenv("PYODIDE", "0") == "1" From 19cf45e72ce7b7addff48cd9004eefa5d81d7521 Mon Sep 17 00:00:00 2001 From: Thomas Wiecki Date: Sat, 10 Aug 2024 22:40:45 +0200 Subject: [PATCH 10/10] ruff --- setup.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/setup.py b/setup.py index bc330ed459..09202a658c 100755 --- a/setup.py +++ b/setup.py @@ -2,11 +2,10 @@ import os import numpy +import versioneer from setuptools import Extension, setup from setuptools.dist import Distribution -import versioneer - dist = Distribution() dist.parse_config_files()