Skip to content
Merged
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
95 changes: 56 additions & 39 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,72 +72,76 @@ jobs:
matrix_yaml: |
include:
# x86_64 manylinux
- { spec: cp39-manylinux_x86_64, arch: x86_64, omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp310-manylinux_x86_64, arch: x86_64, omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp311-manylinux_x86_64, arch: x86_64, omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp312-manylinux_x86_64, arch: x86_64, omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp313-manylinux_x86_64, arch: x86_64, omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp314-manylinux_x86_64, arch: x86_64 }
- { spec: cp314t-manylinux_x86_64, arch: x86_64 }
- { spec: cp314-manylinux_x86_64, arch: x86_64, omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp314t-manylinux_x86_64, arch: x86_64, omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp315-manylinux_x86_64, arch: x86_64 }
- { spec: cp315t-manylinux_x86_64, arch: x86_64 }

# x86_64 musllinux
- { spec: cp39-musllinux_x86_64, arch: x86_64, omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp310-musllinux_x86_64, arch: x86_64, omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp311-musllinux_x86_64, arch: x86_64, omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp312-musllinux_x86_64, arch: x86_64, omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp313-musllinux_x86_64, arch: x86_64, omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp314-musllinux_x86_64, arch: x86_64 }
- { spec: cp314t-musllinux_x86_64, arch: x86_64 }
- { spec: cp314-musllinux_x86_64, arch: x86_64, omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp314t-musllinux_x86_64, arch: x86_64, omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp315-musllinux_x86_64, arch: x86_64 }
- { spec: cp315t-musllinux_x86_64, arch: x86_64 }

# i686 manylinux
- { spec: cp39-manylinux_i686, arch: i686, omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp310-manylinux_i686, arch: i686, omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp311-manylinux_i686, arch: i686, omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp312-manylinux_i686, arch: i686, omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp313-manylinux_i686, arch: i686 }
# omit i686 releases > 3.13

# i686 musllinux
- { spec: cp39-musllinux_i686, arch: i686, omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp310-musllinux_i686, arch: i686, omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp311-musllinux_i686, arch: i686 }
# omit i686 releases after 3.11

# aarch64 manylinux
- { spec: cp39-manylinux_aarch64, arch: aarch64 }
- { spec: cp310-manylinux_aarch64, arch: aarch64, omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp311-manylinux_aarch64, arch: aarch64, omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp312-manylinux_aarch64, arch: aarch64, omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp313-manylinux_aarch64, arch: aarch64, omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp314-manylinux_aarch64, arch: aarch64 }
- { spec: cp314t-manylinux_aarch64, arch: aarch64 }
- { spec: cp314-manylinux_aarch64, arch: aarch64, omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp314t-manylinux_aarch64, arch: aarch64, omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp315-manylinux_aarch64, arch: aarch64 }
- { spec: cp315t-manylinux_aarch64, arch: aarch64 }

# aarch64 musllinux
- { spec: cp39-musllinux_aarch64, arch: aarch64, omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp310-musllinux_aarch64, arch: aarch64, omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp311-musllinux_aarch64, arch: aarch64, omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp312-musllinux_aarch64, arch: aarch64, omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp313-musllinux_aarch64, arch: aarch64, omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp314-musllinux_aarch64, arch: aarch64 }
- { spec: cp314t-musllinux_aarch64, arch: aarch64 }
- { spec: cp314-musllinux_aarch64, arch: aarch64, omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp314t-musllinux_aarch64, arch: aarch64, omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp315-musllinux_aarch64, arch: aarch64 }
- { spec: cp315t-musllinux_aarch64, arch: aarch64 }

# ppc64le manylinux
- { spec: cp39-manylinux_ppc64le, arch: ppc64le, test_args: '{package}/src/c', omit: ${{ env.skip_slow_jobs }} }
- { spec: cp310-manylinux_ppc64le, arch: ppc64le, test_args: '{package}/src/c', omit: ${{ env.skip_slow_jobs || env.skip_ci_redundant_jobs }} }
- { spec: cp310-manylinux_ppc64le, arch: ppc64le, test_args: '{package}/src/c', omit: ${{ env.skip_slow_jobs }} }
- { spec: cp311-manylinux_ppc64le, arch: ppc64le, test_args: '{package}/src/c', omit: ${{ env.skip_slow_jobs || env.skip_ci_redundant_jobs }} }
- { spec: cp312-manylinux_ppc64le, arch: ppc64le, test_args: '{package}/src/c', omit: ${{ env.skip_slow_jobs || env.skip_ci_redundant_jobs }} }
- { spec: cp313-manylinux_ppc64le, arch: ppc64le, test_args: '{package}/src/c', omit: ${{ env.skip_slow_jobs || env.skip_ci_redundant_jobs }} }
- { spec: cp314-manylinux_ppc64le, arch: ppc64le, omit: ${{ env.skip_slow_jobs }} }
- { spec: cp314t-manylinux_ppc64le, arch: ppc64le, omit: ${{ env.skip_slow_jobs }} }
- { spec: cp314-manylinux_ppc64le, arch: ppc64le, test_args: '{package}/src/c', omit: ${{ env.skip_slow_jobs || env.skip_ci_redundant_jobs }} }
- { spec: cp314t-manylinux_ppc64le, arch: ppc64le, test_args: '{package}/src/c', omit: ${{ env.skip_slow_jobs || env.skip_ci_redundant_jobs }} }
- { spec: cp315-manylinux_ppc64le, arch: ppc64le, test_args: '{package}/src/c', omit: ${{ env.skip_slow_jobs }} }
- { spec: cp315t-manylinux_ppc64le, arch: ppc64le, test_args: '{package}/src/c', omit: ${{ env.skip_slow_jobs }} }

# s390x manylinux
- { spec: cp39-manylinux_s390x, arch: s390x, test_args: '{package}/src/c', omit: ${{ env.skip_slow_jobs }} }
- { spec: cp310-manylinux_s390x, arch: s390x, test_args: '{package}/src/c', omit: ${{ env.skip_slow_jobs || env.skip_ci_redundant_jobs }} }
- { spec: cp310-manylinux_s390x, arch: s390x, test_args: '{package}/src/c', omit: ${{ env.skip_slow_jobs }} }
- { spec: cp311-manylinux_s390x, arch: s390x, test_args: '{package}/src/c', omit: ${{ env.skip_slow_jobs || env.skip_ci_redundant_jobs }} }
- { spec: cp312-manylinux_s390x, arch: s390x, test_args: '{package}/src/c', omit: ${{ env.skip_slow_jobs || env.skip_ci_redundant_jobs }} }
- { spec: cp313-manylinux_s390x, arch: s390x, test_args: '{package}/src/c', omit: ${{ env.skip_slow_jobs || env.skip_ci_redundant_jobs }} }
- { spec: cp314-manylinux_s390x, arch: s390x, omit: ${{ env.skip_slow_jobs }} }
- { spec: cp314t-manylinux_s390x, arch: s390x, omit: ${{ env.skip_slow_jobs }} }
- { spec: cp314-manylinux_s390x, arch: s390x, test_args: '{package}/src/c', omit: ${{ env.skip_slow_jobs || env.skip_ci_redundant_jobs }} }
- { spec: cp314t-manylinux_s390x, arch: s390x, test_args: '{package}/src/c', omit: ${{ env.skip_slow_jobs || env.skip_ci_redundant_jobs }} }
- { spec: cp315-manylinux_s390x, arch: s390x, test_args: '{package}/src/c', omit: ${{ env.skip_slow_jobs }} }
- { spec: cp315t-manylinux_s390x, arch: s390x, test_args: '{package}/src/c', omit: ${{ env.skip_slow_jobs }} }

linux:
needs: [python_sdist, make_linux_matrix]
Expand All @@ -163,6 +167,7 @@ jobs:
CFLAGS: -Dffi_call=cffistatic_ffi_call # override name for ffi_call to break hard if we linked against someone else's libffi
CIBW_ARCHS_LINUX: all
CIBW_BUILD: ${{ matrix.spec }}
CIBW_ENABLE: cpython-prerelease
CIBW_BEFORE_BUILD: |
set -eux && \
curl -L -O https://github.com/libffi/libffi/archive/v3.4.6.tar.gz && \
Expand Down Expand Up @@ -218,22 +223,24 @@ jobs:
matrix_yaml: |
include:
# x86_64 macos
- { spec: cp39-macosx_x86_64, runs_on: [macos-15-intel], omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp310-macosx_x86_64, runs_on: [macos-15-intel], omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp311-macosx_x86_64, runs_on: [macos-15-intel], omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp312-macosx_x86_64, runs_on: [macos-15-intel], omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp313-macosx_x86_64, runs_on: [macos-15-intel], omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp314-macosx_x86_64, runs_on: [macos-15-intel] }
- { spec: cp314t-macosx_x86_64, runs_on: [macos-15-intel] }
- { spec: cp314-macosx_x86_64, runs_on: [macos-15-intel], omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp314t-macosx_x86_64, runs_on: [macos-15-intel], omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp315-macosx_x86_64, runs_on: [macos-15-intel] }
- { spec: cp315t-macosx_x86_64, runs_on: [macos-15-intel] }

# arm64 macos
- { spec: cp39-macosx_arm64, deployment_target: '11.0', run_wrapper: 'arch -arm64 bash --noprofile --norc -eo pipefail {0}', omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp310-macosx_arm64, deployment_target: '11.0', run_wrapper: 'arch -arm64 bash --noprofile --norc -eo pipefail {0}', omit: ${{ env.skip_ci_redundant_jobs}} }
- { spec: cp310-macosx_arm64, deployment_target: '11.0', run_wrapper: 'arch -arm64 bash --noprofile --norc -eo pipefail {0}', omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp311-macosx_arm64, deployment_target: '11.0', run_wrapper: 'arch -arm64 bash --noprofile --norc -eo pipefail {0}', omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp312-macosx_arm64, deployment_target: '11.0', run_wrapper: 'arch -arm64 bash --noprofile --norc -eo pipefail {0}', omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp313-macosx_arm64, deployment_target: '11.0', run_wrapper: 'arch -arm64 bash --noprofile --norc -eo pipefail {0}', omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp314-macosx_arm64, deployment_target: '11.0', run_wrapper: 'arch -arm64 bash --noprofile --norc -eo pipefail {0}' }
- { spec: cp314t-macosx_arm64, deployment_target: '11.0', run_wrapper: 'arch -arm64 bash --noprofile --norc -eo pipefail {0}' }
- { spec: cp314-macosx_arm64, deployment_target: '11.0', run_wrapper: 'arch -arm64 bash --noprofile --norc -eo pipefail {0}', omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp314t-macosx_arm64, deployment_target: '11.0', run_wrapper: 'arch -arm64 bash --noprofile --norc -eo pipefail {0}', omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp315-macosx_arm64, deployment_target: '11.0', run_wrapper: 'arch -arm64 bash --noprofile --norc -eo pipefail {0}' }
- { spec: cp315t-macosx_arm64, deployment_target: '11.0', run_wrapper: 'arch -arm64 bash --noprofile --norc -eo pipefail {0}' }

macos:
needs: [python_sdist, make_macos_matrix]
Expand Down Expand Up @@ -268,6 +275,7 @@ jobs:
id: build
env:
CIBW_BUILD: ${{ matrix.spec }}
CIBW_ENABLE: cpython-prerelease
CIBW_TEST_REQUIRES: pytest setuptools
CIBW_TEST_COMMAND: pip install pip --upgrade; cd {project}; PYTHONUNBUFFERED=1 pytest
MACOSX_DEPLOYMENT_TARGET: ${{ matrix.deployment_target || '10.13' }}
Expand Down Expand Up @@ -309,24 +317,30 @@ jobs:
- { spec: cp311-win_amd64, omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp312-win_amd64, omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp313-win_amd64, omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp314-win_amd64 }
- { spec: cp314t-win_amd64 }
- { spec: cp314-win_amd64, omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp314t-win_amd64, omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp315-win_amd64 }
- { spec: cp315t-win_amd64 }

# x86 windows
- { spec: cp39-win32, omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp310-win32, omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp311-win32, omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp312-win32, omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp313-win32, omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp314-win32 }
- { spec: cp314t-win32 }
- { spec: cp314-win32, omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp314t-win32, omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp315-win32 }
- { spec: cp315t-win32 }

# arm64 windows
- { spec: cp311-win_arm64, runs_on: windows-11-arm, omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp312-win_arm64, runs_on: windows-11-arm, omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp313-win_arm64, runs_on: windows-11-arm, omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp314-win_arm64, runs_on: windows-11-arm }
- { spec: cp314t-win_arm64, runs_on: windows-11-arm }
- { spec: cp314-win_arm64, runs_on: windows-11-arm, omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp314t-win_arm64, runs_on: windows-11-arm, omit: ${{ env.skip_ci_redundant_jobs }} }
- { spec: cp315-win_arm64, runs_on: windows-11-arm }
- { spec: cp315t-win_arm64, runs_on: windows-11-arm }

windows:
needs: [python_sdist, make_windows_matrix]
Expand All @@ -351,6 +365,7 @@ jobs:
id: build
env:
CIBW_BUILD: ${{ matrix.spec }}
CIBW_ENABLE: cpython-prerelease
CIBW_TEST_REQUIRES: pytest setuptools
CIBW_TEST_COMMAND: ${{ matrix.test_cmd || 'python -m pytest {package}/src/c' }}
# FIXME: /testing takes ~45min on Windows and has some failures...
Expand Down Expand Up @@ -393,10 +408,12 @@ jobs:
# arm64 iOS device
- { spec: cp313-ios_arm64_iphoneos, platform: 'iphoneos' }
- { spec: cp314-ios_arm64_iphoneos, platform: 'iphoneos' }
- { spec: cp315-ios_arm64_iphoneos, platform: 'iphoneos' }

# arm64 iOS simulator
- { spec: cp313-ios_arm64_iphonesimulator, platform: 'iphonesimulator' }
- { spec: cp314-ios_arm64_iphonesimulator, platform: 'iphonesimulator' }
- { spec: cp315-ios_arm64_iphonesimulator, platform: 'iphonesimulator' }

ios:
needs: [python_sdist, make_ios_matrix]
Expand Down Expand Up @@ -504,9 +521,9 @@ jobs:
with:
matrix_yaml: |
include:
- { runner: ubuntu-24.04, python-version: 3.14t }
- { runner: macos-26, python-version: 3.14t }
- { runner: windows-2025, python-version: 3.14t }
- { runner: ubuntu-24.04, python-version: 3.15t-dev }
- { runner: macos-26, python-version: 3.15t-dev }
- { runner: windows-2025, python-version: 3.15t-dev }

pytest-run-parallel:
needs: make_run_parallel_matrix
Expand Down Expand Up @@ -536,7 +553,7 @@ jobs:

clang_TSAN:
runs-on: ubuntu-24.04
container: ghcr.io/nascheme/numpy-tsan:3.14t
container: ghcr.io/nascheme/numpy-tsan:3.15t-dev
steps:
- uses: actions/checkout@v4

Expand Down
13 changes: 11 additions & 2 deletions src/cffi/_cffi_include.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,13 @@
#if !defined(_CFFI_USE_EMBEDDING) && !defined(Py_LIMITED_API)
# ifdef _MSC_VER
# if !defined(_DEBUG) && !defined(Py_DEBUG) && !defined(Py_TRACE_REFS) && !defined(Py_REF_DEBUG) && !defined(_CFFI_NO_LIMITED_API)
# define Py_LIMITED_API
# if !defined(Py_GIL_DISABLED)
# define Py_LIMITED_API
# else
# define Py_LIMITED_API 0x030f0000
# endif
# endif

# include <pyconfig.h>
/* sanity-check: Py_LIMITED_API will cause crashes if any of these
are also defined. Normally, the Python file PC/pyconfig.h does not
Expand All @@ -49,7 +54,11 @@
# else
# include <pyconfig.h>
# if !defined(Py_DEBUG) && !defined(Py_TRACE_REFS) && !defined(Py_REF_DEBUG) && !defined(_CFFI_NO_LIMITED_API)
# define Py_LIMITED_API
# if !defined(Py_GIL_DISABLED)
# define Py_LIMITED_API
# else
# define Py_LIMITED_API 0x030f0000
# endif
# endif
# endif
#endif
Expand Down
4 changes: 3 additions & 1 deletion src/cffi/recompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
VERSION_EMBEDDED = 0x2701
VERSION_CHAR16CHAR32 = 0x2801

FREE_THREADED_BUILD = sysconfig.get_config_var("Py_GIL_DISABLED")
USE_LIMITED_API = ((sys.platform != 'win32' or sys.version_info < (3, 0) or
sys.version_info >= (3, 5)) and
not sysconfig.get_config_var("Py_GIL_DISABLED")) # free-threaded doesn't yet support limited API
# free-threaded build doesn't support the stable ABI until Python 3.15
(not FREE_THREADED_BUILD or sys.version_info >= (3, 15)))

class GlobalExpr:
def __init__(self, name, address, type_op, size=0, check_value=0):
Expand Down
10 changes: 6 additions & 4 deletions src/cffi/setuptools_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,12 @@ def _set_py_limited_api(Extension, kwds):
kwds['py_limited_api'] = True

if sysconfig.get_config_var("Py_GIL_DISABLED"):
if kwds.get('py_limited_api'):
log.info("Ignoring py_limited_api=True for free-threaded build.")

kwds['py_limited_api'] = False
if sys.version_info < (3, 15):
if kwds.get('py_limited_api'):
log.info("Ignoring py_limited_api=True for free-threaded build.")
kwds['py_limited_api'] = False
else:
kwds.setdefault("define_macros", []).append(("Py_TARGET_ABI3T", "0x030f0000"))

if kwds.get('py_limited_api') is False:
# avoid setting Py_LIMITED_API if py_limited_api=False
Expand Down
5 changes: 4 additions & 1 deletion testing/cffi0/test_zintegration.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,10 @@ def test_set_py_limited_api(self):
pytest.skip(str(e))
orig_version = setuptools.__version__
# free-threaded Python does not yet support limited API
expecting_limited_api = not hasattr(sys, 'gettotalrefcount') and not sysconfig.get_config_var("Py_GIL_DISABLED")
expecting_limited_api = (
not hasattr(sys, 'gettotalrefcount') and not
(sysconfig.get_config_var("Py_GIL_DISABLED") and sys.version_info < (3, 15))
)
try:
setuptools.__version__ = '26.0.0'
from setuptools import Extension
Expand Down
1 change: 1 addition & 0 deletions testing/cffi1/test_verify1.py
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,7 @@ def test_get_set_errno():
ffi = FFI()
ffi.cdef("int foo(int);")
lib = ffi.verify("""
#include <errno.h>
Comment thread
mattip marked this conversation as resolved.
static int foo(int x)
{
errno += 1;
Expand Down
Loading