-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENH: fix support for Python limited API / stable ABI wheels
Meson gained support for building Python extension modules targeting the Python limited API, therefore it is time for meson-python to properly support tagging the build wheels as targeting the stable ABI. Unfortunately there isn't a reliable and cross-platform way to detect when extension modules are build for the limited API. Therefore, we need to add an explicit "limited-api" configuration option in the [tool.meson-python] section in pyproject.toml.
- Loading branch information
Showing
8 changed files
with
171 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# SPDX-FileCopyrightText: 2023 The meson-python developers | ||
# | ||
# SPDX-License-Identifier: MIT | ||
|
||
project('limited-api', 'c', version: '1.0.0') | ||
|
||
py = import('python').find_installation(pure: false) | ||
|
||
py.extension_module( | ||
'module', | ||
'module.c', | ||
limited_api: '3.7', | ||
install: true, | ||
) | ||
|
||
if get_option('extra') | ||
py.extension_module( | ||
'extra', | ||
'module.c', | ||
install: true, | ||
) | ||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# SPDX-FileCopyrightText: 2023 The meson-python developers | ||
# | ||
# SPDX-License-Identifier: MIT | ||
|
||
option('extra', type: 'boolean', value: false) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// SPDX-FileCopyrightText: 2023 The meson-python developers | ||
// | ||
// SPDX-License-Identifier: MIT | ||
|
||
#include <Python.h> | ||
|
||
static PyObject* add(PyObject *self, PyObject *args) { | ||
int a, b; | ||
|
||
if (!PyArg_ParseTuple(args, "ii", &a, &b)) | ||
return NULL; | ||
|
||
return PyLong_FromLong(a + b); | ||
} | ||
|
||
static PyMethodDef methods[] = { | ||
{"add", add, METH_VARARGS, NULL}, | ||
{NULL, NULL, 0, NULL}, | ||
}; | ||
|
||
static struct PyModuleDef module = { | ||
PyModuleDef_HEAD_INIT, | ||
"plat", | ||
NULL, | ||
-1, | ||
methods, | ||
}; | ||
|
||
PyMODINIT_FUNC PyInit_module(void) { | ||
return PyModule_Create(&module); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# SPDX-FileCopyrightText: 2023 The meson-python developers | ||
# | ||
# SPDX-License-Identifier: MIT | ||
|
||
[build-system] | ||
build-backend = 'mesonpy' | ||
requires = ['meson-python'] | ||
|
||
[tool.meson-python] | ||
limited-api = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters