Skip to content
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

MNT: Build wheels with limited API #210

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 32 additions & 5 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
36 changes: 20 additions & 16 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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},
)