From 820c47c34bbccc1ab6c3be06579ecba20b2910cf Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Wed, 11 Oct 2023 10:51:15 -0400 Subject: [PATCH 1/2] MNT: Enable building with the limited Python API --- pyproject.toml | 1 + setup.py | 36 ++++++++++++++++++++---------------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index c6cd3afd..3b02400b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,7 @@ [build-system] requires = [ "setuptools", + "wheel", "setuptools_scm[toml]>=6.2", "cython", # As of numpy 1.25, you can now build against older APIs. diff --git a/setup.py b/setup.py index 3974b51f..8c8646fb 100755 --- a/setup.py +++ b/setup.py @@ -4,27 +4,31 @@ This file only contains cython components. See pyproject.toml for the remaining configuration. """ -from setuptools import setup +from setuptools import setup, Extension +from wheel.bdist_wheel import bdist_wheel +from Cython.Build import cythonize +from numpy import get_include -try: - from setuptools import Extension - from Cython.Build import cythonize - from numpy import get_include - # add Cython extensions to the setup options - exts = [ +class bdist_wheel_abi3(bdist_wheel): + def get_tag(self): + python, abi, plat = super().get_tag() + + # We support back to cp38 + if python.startswith('cp3'): + python, abi = 'cp38', 'abi3' + + return python, abi, plat + +setup( + ext_modules=[ Extension( 'nitime._utils', ['nitime/_utils.pyx'], include_dirs=[get_include()], define_macros=[('NPY_NO_DEPRECATED_API', 'NPY_1_7_API_VERSION')], + py_limited_api=True, ) - ] - opts = {'ext_modules': cythonize(exts, language_level='3')} -except ImportError: - # no loop for you! - opts = {} - -# Now call the actual setup function -if __name__ == '__main__': - setup(**opts) + ], + cmdclass={'bdist_wheel': bdist_wheel_abi3}, +) From a7a4b3143cf3427718046cccdbd2e6ed6491614c Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Wed, 11 Oct 2023 11:44:35 -0400 Subject: [PATCH 2/2] CI: Reduce build matrix, add test matrix [build wheels] --- .github/workflows/wheels.yml | 37 +++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 1838751d..93a622b9 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -58,13 +58,11 @@ jobs: fail-fast: false matrix: buildplat: + - [ubuntu-20.04, manylinux_x86_64] - [ubuntu-20.04, musllinux_x86_64] - [macos-12, macosx_*] - [windows-2019, win_amd64] - python: ["cp38", "cp39", "cp310", "cp311", "cp312"] - include: - # Manylinux builds are cheap, do all in one - - { buildplat: ["ubuntu-20.04", "manylinux_x86_64"], python: "*" } + python: ["cp312"] steps: - uses: actions/checkout@v3 @@ -108,9 +106,38 @@ jobs: - name: Run tests run: pytest -v --pyargs nitime + test-wheel: + name: Test wheel + needs: [build-wheel] + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: ['ubuntu-latest', 'windows-latest', 'macos-latest'] + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] + steps: + - uses: actions/download-artifact@v3 + with: + path: dist/ + - name: Consolidate and list wheels + run: | + mkdir wheelhouse + mv dist/*/*.whl wheelhouse + - uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Display Python version + run: python -c "import sys; print(sys.version)" + - name: Install wheel + run: pip install --find-links ./wheelhouse --pre nitime + - run: python -c 'import nitime; print(nitime.__version__)' + - name: Install pytest + run: pip install pytest + - name: Run tests + run: pytest -v --pyargs nitime + pre-publish: runs-on: ubuntu-latest - needs: [test-sdist, build-wheel] + needs: [test-sdist, test-wheel] steps: - uses: actions/download-artifact@v3 with: