Skip to content

Commit

Permalink
Stable release
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeroIntensity committed Jun 24, 2024
1 parent 191e17c commit 1534cfd
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 12 deletions.
27 changes: 27 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,33 @@ build-backend = "setuptools.build_meta"

PyAwaitable needs to be installed as both a runtime dependency and build time dependency.

## Vendored Copies

PyAwaitable ships a vendorable version of each release, containing both a `pyawaitable.c` and `pyawaitable.h` file. For many user, it's much easier to vendor PyAwaitable than use it off PyPI.

Initialization is slightly different on a vendored version - instead of using `pyawaitable_init`, you are to use `pyawaitable_vendor_init`, which takes a module object. For example:

```c
#include "pyawaitable.h"
/* ... */

PyMODINIT_FUNC
PyInit_foo(void)
{
PyObject *m = PyModule_Create(/* ... */);
if (!m)
return NULL;

if (pyawaitable_init_vendor(m) < 0)
{
Py_DECREF(m);
return NULL;
}

return m;
}
```
## Acknowledgements
Special thanks to:
Expand Down
25 changes: 13 additions & 12 deletions include/vendor.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@
* (If you're seeing this message from a vendored copy, you're fine)
*/

#define PYAWAITABLE_ADD_TYPE(m, tp) \
do \
{ \
Py_INCREF(&tp); \
if (PyType_Ready(&tp) < 0) { \
Py_DECREF(&tp); \
return -1; \
} \
if (PyModule_AddObject(m, #tp, (PyObject *)&tp) < 0) { \
Py_DECREF(&tp); \
return -1; \
} \
#define PYAWAITABLE_ADD_TYPE(m, tp) \
do \
{ \
Py_INCREF(&tp); \
if (PyType_Ready(&tp) < 0) { \
Py_DECREF(&tp); \
return -1; \
} \
if (PyModule_AddObject(m, #tp, (PyObject *) &tp) < 0) { \
Py_DECREF(&tp); \
return -1; \
} \
} while (0)

#define PYAWAITABLE_MAJOR_VERSION 1
Expand All @@ -42,6 +42,7 @@
#define PyAwaitable_ABI pyawaitable_abi
#define PyAwaitable_Type PyAwaitableType
#define PyAwaitable_AwaitFunction pyawaitable_await_function
#define PyAwaitable_VendorInit pyawaitable_vendor_init
#endif

static int
Expand Down

0 comments on commit 1534cfd

Please sign in to comment.