From 1e2e1f203cc7ecc11c575e2fc2f72efd17054c44 Mon Sep 17 00:00:00 2001 From: Ralf Gommers Date: Tue, 13 Jan 2026 22:52:11 +0100 Subject: [PATCH 1/2] TST: change one test package to use `PyModEXPORT_FUNC` (PEP 793) --- .../foo/_examplemod.c | 32 +++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/tests/packages/link-library-in-subproject/foo/_examplemod.c b/tests/packages/link-library-in-subproject/foo/_examplemod.c index d69556999..6f52d75c2 100644 --- a/tests/packages/link-library-in-subproject/foo/_examplemod.c +++ b/tests/packages/link-library-in-subproject/foo/_examplemod.c @@ -23,7 +23,23 @@ static PyMethodDef methods[] = { {NULL, NULL, 0, NULL}, }; -static struct PyModuleDef module = { +#if PY_VERSION_HEX >= 0x030F0000 +/* Use `PyModExport_` hook, new in Python 3.15 (PEP 793) */ +static PyModuleDef_Slot example_slots[] = { + {Py_mod_name, "_example"}, + {Py_mod_methods, methods}, + {Py_mod_gil, Py_MOD_GIL_NOT_USED}, + {0, NULL} +}; + +PyMODEXPORT_FUNC +PyModExport__example(void) +{ + return example_slots; +} +#else +/* Use legacy method to create a module dynamically */ +static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, "_example", NULL, @@ -33,5 +49,17 @@ static struct PyModuleDef module = { PyMODINIT_FUNC PyInit__example(void) { - return PyModule_Create(&module); + PyObject *module; + + module = PyModule_Create(&moduledef); + if (module == NULL) { + return module; + } + +#if Py_GIL_DISABLED + PyUnstable_Module_SetGIL(module, Py_MOD_GIL_NOT_USED); +#endif + + return module; } +#endif From db722506a3b67b343d1d28e896718a74f1428ac0 Mon Sep 17 00:00:00 2001 From: Ralf Gommers Date: Tue, 13 Jan 2026 22:55:18 +0100 Subject: [PATCH 2/2] CI: test with Python 3.15.0a3 --- .github/workflows/tests.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 057c35b64..538e4e936 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -49,6 +49,7 @@ jobs: python: - '3.9' - '3.14' + - '3.15.0-alpha.3' meson: - dependencies: @@ -111,7 +112,7 @@ jobs: uses: actions/checkout@v4 - name: Set up target Python - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: python-version: ${{ matrix.python }} @@ -162,7 +163,7 @@ jobs: uses: actions/checkout@v4 - name: Set up target Python - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: python-version: ${{ matrix.python }} @@ -303,7 +304,7 @@ jobs: uses: actions/checkout@v4 - name: Setup Python - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: python-version: 3.9