forked from capnproto/pycapnp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add custom build backend to support build args
This implements a custom build backend, inspired by the [solution used by Pillow.](python-pillow/Pillow#7171) install-option is deprecated and was removed with pip 23.1. The comonly accepted solution seems to be to define a custom build backend for now pypa/setuptools#2491 (comment) This commit changes the usage from `--install-option` to `--config-settings`.
- Loading branch information
Showing
8 changed files
with
199 additions
and
47 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import sys | ||
|
||
from setuptools.build_meta import * # noqa: F401, F403 | ||
from setuptools.build_meta import build_wheel | ||
|
||
backend_class = build_wheel.__self__.__class__ | ||
|
||
|
||
class _CustomBuildMetaBackend(backend_class): | ||
def run_setup(self, setup_script="setup.py"): | ||
if self.config_settings: | ||
flags = [] | ||
if self.config_settings.get("force-bundled-libcapnp"): | ||
flags.append("--force-bundled-libcapnp") | ||
if self.config_settings.get("force-system-libcapnp"): | ||
flags.append("--force-system-libcapnp") | ||
if self.config_settings.get("libcapnp-url"): | ||
flags.append("--libcapnp-url") | ||
flags.append(self.config_settings["libcapnp-url"]) | ||
if flags: | ||
sys.argv = sys.argv[:1] + ["build_ext"] + flags + sys.argv[1:] | ||
return super().run_setup(setup_script) | ||
|
||
def build_wheel( | ||
self, wheel_directory, config_settings=None, metadata_directory=None | ||
): | ||
self.config_settings = config_settings | ||
return super().build_wheel(wheel_directory, config_settings, metadata_directory) | ||
|
||
|
||
build_wheel = _CustomBuildMetaBackend().build_wheel |
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,125 @@ | ||
/* Generated by Cython 0.29.36 */ | ||
|
||
#ifndef __PYX_HAVE_API__capnp__lib__capnp | ||
#define __PYX_HAVE_API__capnp__lib__capnp | ||
#ifdef __MINGW64__ | ||
#define MS_WIN64 | ||
#endif | ||
#include "Python.h" | ||
|
||
static PyObject *(*__pyx_api_f_5capnp_3lib_5capnp_wrap_dynamic_struct_reader)( ::capnp::Response< ::capnp::DynamicStruct> &) = 0; | ||
#define wrap_dynamic_struct_reader __pyx_api_f_5capnp_3lib_5capnp_wrap_dynamic_struct_reader | ||
static ::kj::Promise<void> *(*__pyx_api_f_5capnp_3lib_5capnp_call_server_method)(PyObject *, char *, ::capnp::CallContext< ::capnp::DynamicStruct, ::capnp::DynamicStruct> &) = 0; | ||
#define call_server_method __pyx_api_f_5capnp_3lib_5capnp_call_server_method | ||
static PyObject *(*__pyx_api_f_5capnp_3lib_5capnp_wrap_kj_exception)( ::kj::Exception &) = 0; | ||
#define wrap_kj_exception __pyx_api_f_5capnp_3lib_5capnp_wrap_kj_exception | ||
static PyObject *(*__pyx_api_f_5capnp_3lib_5capnp_wrap_kj_exception_for_reraise)( ::kj::Exception &) = 0; | ||
#define wrap_kj_exception_for_reraise __pyx_api_f_5capnp_3lib_5capnp_wrap_kj_exception_for_reraise | ||
static PyObject *(*__pyx_api_f_5capnp_3lib_5capnp_get_exception_info)(PyObject *, PyObject *, PyObject *) = 0; | ||
#define get_exception_info __pyx_api_f_5capnp_3lib_5capnp_get_exception_info | ||
static void (*__pyx_api_f_5capnp_3lib_5capnp_promise_task_add_done_callback)(PyObject *, PyObject *, ::kj::PromiseFulfiller<void> &) = 0; | ||
#define promise_task_add_done_callback __pyx_api_f_5capnp_3lib_5capnp_promise_task_add_done_callback | ||
static void (*__pyx_api_f_5capnp_3lib_5capnp_promise_task_cancel)(PyObject *) = 0; | ||
#define promise_task_cancel __pyx_api_f_5capnp_3lib_5capnp_promise_task_cancel | ||
static void (*__pyx_api_f_5capnp_3lib_5capnp__asyncio_stream_write_start)(PyObject *, ::kj::ArrayPtr< ::kj::ArrayPtr<uint8_t const > const > , ::kj::PromiseFulfiller<void> &) = 0; | ||
#define _asyncio_stream_write_start __pyx_api_f_5capnp_3lib_5capnp__asyncio_stream_write_start | ||
static void (*__pyx_api_f_5capnp_3lib_5capnp__asyncio_stream_write_stop)(PyObject *) = 0; | ||
#define _asyncio_stream_write_stop __pyx_api_f_5capnp_3lib_5capnp__asyncio_stream_write_stop | ||
static void (*__pyx_api_f_5capnp_3lib_5capnp__asyncio_stream_read_start)(PyObject *, void *, size_t, size_t, ::kj::PromiseFulfiller<size_t> &) = 0; | ||
#define _asyncio_stream_read_start __pyx_api_f_5capnp_3lib_5capnp__asyncio_stream_read_start | ||
static void (*__pyx_api_f_5capnp_3lib_5capnp__asyncio_stream_read_stop)(PyObject *) = 0; | ||
#define _asyncio_stream_read_stop __pyx_api_f_5capnp_3lib_5capnp__asyncio_stream_read_stop | ||
static void (*__pyx_api_f_5capnp_3lib_5capnp__asyncio_stream_shutdown_write)(PyObject *) = 0; | ||
#define _asyncio_stream_shutdown_write __pyx_api_f_5capnp_3lib_5capnp__asyncio_stream_shutdown_write | ||
static void (*__pyx_api_f_5capnp_3lib_5capnp__asyncio_stream_close)(PyObject *) = 0; | ||
#define _asyncio_stream_close __pyx_api_f_5capnp_3lib_5capnp__asyncio_stream_close | ||
static PyObject *(*__pyx_api_f_5capnp_3lib_5capnp_make_async_message_reader)( ::kj::Own< ::capnp::MessageReader> ) = 0; | ||
#define make_async_message_reader __pyx_api_f_5capnp_3lib_5capnp_make_async_message_reader | ||
#if !defined(__Pyx_PyIdentifier_FromString) | ||
#if PY_MAJOR_VERSION < 3 | ||
#define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s) | ||
#else | ||
#define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s) | ||
#endif | ||
#endif | ||
|
||
#ifndef __PYX_HAVE_RT_ImportFunction_0_29_36 | ||
#define __PYX_HAVE_RT_ImportFunction_0_29_36 | ||
static int __Pyx_ImportFunction_0_29_36(PyObject *module, const char *funcname, void (**f)(void), const char *sig) { | ||
PyObject *d = 0; | ||
PyObject *cobj = 0; | ||
union { | ||
void (*fp)(void); | ||
void *p; | ||
} tmp; | ||
d = PyObject_GetAttrString(module, (char *)"__pyx_capi__"); | ||
if (!d) | ||
goto bad; | ||
cobj = PyDict_GetItemString(d, funcname); | ||
if (!cobj) { | ||
PyErr_Format(PyExc_ImportError, | ||
"%.200s does not export expected C function %.200s", | ||
PyModule_GetName(module), funcname); | ||
goto bad; | ||
} | ||
#if PY_VERSION_HEX >= 0x02070000 | ||
if (!PyCapsule_IsValid(cobj, sig)) { | ||
PyErr_Format(PyExc_TypeError, | ||
"C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)", | ||
PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj)); | ||
goto bad; | ||
} | ||
tmp.p = PyCapsule_GetPointer(cobj, sig); | ||
#else | ||
{const char *desc, *s1, *s2; | ||
desc = (const char *)PyCObject_GetDesc(cobj); | ||
if (!desc) | ||
goto bad; | ||
s1 = desc; s2 = sig; | ||
while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; } | ||
if (*s1 != *s2) { | ||
PyErr_Format(PyExc_TypeError, | ||
"C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)", | ||
PyModule_GetName(module), funcname, sig, desc); | ||
goto bad; | ||
} | ||
tmp.p = PyCObject_AsVoidPtr(cobj);} | ||
#endif | ||
*f = tmp.fp; | ||
if (!(*f)) | ||
goto bad; | ||
Py_DECREF(d); | ||
return 0; | ||
bad: | ||
Py_XDECREF(d); | ||
return -1; | ||
} | ||
#endif | ||
|
||
|
||
static int import_capnp__lib__capnp(void) { | ||
PyObject *module = 0; | ||
module = PyImport_ImportModule("capnp.lib.capnp"); | ||
if (!module) goto bad; | ||
if (__Pyx_ImportFunction_0_29_36(module, "wrap_dynamic_struct_reader", (void (**)(void))&__pyx_api_f_5capnp_3lib_5capnp_wrap_dynamic_struct_reader, "PyObject *( ::capnp::Response< ::capnp::DynamicStruct> &)") < 0) goto bad; | ||
if (__Pyx_ImportFunction_0_29_36(module, "call_server_method", (void (**)(void))&__pyx_api_f_5capnp_3lib_5capnp_call_server_method, " ::kj::Promise<void> *(PyObject *, char *, ::capnp::CallContext< ::capnp::DynamicStruct, ::capnp::DynamicStruct> &)") < 0) goto bad; | ||
if (__Pyx_ImportFunction_0_29_36(module, "wrap_kj_exception", (void (**)(void))&__pyx_api_f_5capnp_3lib_5capnp_wrap_kj_exception, "PyObject *( ::kj::Exception &)") < 0) goto bad; | ||
if (__Pyx_ImportFunction_0_29_36(module, "wrap_kj_exception_for_reraise", (void (**)(void))&__pyx_api_f_5capnp_3lib_5capnp_wrap_kj_exception_for_reraise, "PyObject *( ::kj::Exception &)") < 0) goto bad; | ||
if (__Pyx_ImportFunction_0_29_36(module, "get_exception_info", (void (**)(void))&__pyx_api_f_5capnp_3lib_5capnp_get_exception_info, "PyObject *(PyObject *, PyObject *, PyObject *)") < 0) goto bad; | ||
if (__Pyx_ImportFunction_0_29_36(module, "promise_task_add_done_callback", (void (**)(void))&__pyx_api_f_5capnp_3lib_5capnp_promise_task_add_done_callback, "void (PyObject *, PyObject *, ::kj::PromiseFulfiller<void> &)") < 0) goto bad; | ||
if (__Pyx_ImportFunction_0_29_36(module, "promise_task_cancel", (void (**)(void))&__pyx_api_f_5capnp_3lib_5capnp_promise_task_cancel, "void (PyObject *)") < 0) goto bad; | ||
if (__Pyx_ImportFunction_0_29_36(module, "_asyncio_stream_write_start", (void (**)(void))&__pyx_api_f_5capnp_3lib_5capnp__asyncio_stream_write_start, "void (PyObject *, ::kj::ArrayPtr< ::kj::ArrayPtr<uint8_t const > const > , ::kj::PromiseFulfiller<void> &)") < 0) goto bad; | ||
if (__Pyx_ImportFunction_0_29_36(module, "_asyncio_stream_write_stop", (void (**)(void))&__pyx_api_f_5capnp_3lib_5capnp__asyncio_stream_write_stop, "void (PyObject *)") < 0) goto bad; | ||
if (__Pyx_ImportFunction_0_29_36(module, "_asyncio_stream_read_start", (void (**)(void))&__pyx_api_f_5capnp_3lib_5capnp__asyncio_stream_read_start, "void (PyObject *, void *, size_t, size_t, ::kj::PromiseFulfiller<size_t> &)") < 0) goto bad; | ||
if (__Pyx_ImportFunction_0_29_36(module, "_asyncio_stream_read_stop", (void (**)(void))&__pyx_api_f_5capnp_3lib_5capnp__asyncio_stream_read_stop, "void (PyObject *)") < 0) goto bad; | ||
if (__Pyx_ImportFunction_0_29_36(module, "_asyncio_stream_shutdown_write", (void (**)(void))&__pyx_api_f_5capnp_3lib_5capnp__asyncio_stream_shutdown_write, "void (PyObject *)") < 0) goto bad; | ||
if (__Pyx_ImportFunction_0_29_36(module, "_asyncio_stream_close", (void (**)(void))&__pyx_api_f_5capnp_3lib_5capnp__asyncio_stream_close, "void (PyObject *)") < 0) goto bad; | ||
if (__Pyx_ImportFunction_0_29_36(module, "make_async_message_reader", (void (**)(void))&__pyx_api_f_5capnp_3lib_5capnp_make_async_message_reader, "PyObject *( ::kj::Own< ::capnp::MessageReader> )") < 0) goto bad; | ||
Py_DECREF(module); module = 0; | ||
return 0; | ||
bad: | ||
Py_XDECREF(module); | ||
return -1; | ||
} | ||
|
||
#endif /* !__PYX_HAVE_API__capnp__lib__capnp */ |
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
[build-system] | ||
requires = ["setuptools", "wheel", "pkgconfig", "cython<3"] | ||
build-backend = "backend" | ||
backend-path = ["_custom_build"] | ||
|
||
[tool.pytest.ini_options] | ||
asyncio_mode = "auto" |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
[metadata] | ||
description-file = README.md | ||
description_file = README.md | ||
license_files = LICENSE.md |
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