Skip to content
Draft
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
7 changes: 4 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ jobs:
python:
- '3.9'
- '3.14'
- '3.15.0-alpha.3'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to set allow-prereleases: true in the actions/setup-python uses and specify this simply as 3.15 so we don't need to do anything when Python 3.15 is released.

meson:
-
dependencies:
Expand Down Expand Up @@ -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 }}

Expand Down Expand Up @@ -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 }}

Expand Down Expand Up @@ -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

Expand Down
32 changes: 30 additions & 2 deletions tests/packages/link-library-in-subproject/foo/_examplemod.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,23 @@ static PyMethodDef methods[] = {
{NULL, NULL, 0, NULL},
};

static struct PyModuleDef module = {
#if PY_VERSION_HEX >= 0x030F0000
/* Use `PyModExport_<modname>` 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,
Expand All @@ -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
Loading