Skip to content

Commit 1534cfd

Browse files
committed
Stable release
1 parent 191e17c commit 1534cfd

File tree

2 files changed

+40
-12
lines changed

2 files changed

+40
-12
lines changed

docs/index.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,33 @@ build-backend = "setuptools.build_meta"
5858

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

61+
## Vendored Copies
62+
63+
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.
64+
65+
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:
66+
67+
```c
68+
#include "pyawaitable.h"
69+
/* ... */
70+
71+
PyMODINIT_FUNC
72+
PyInit_foo(void)
73+
{
74+
PyObject *m = PyModule_Create(/* ... */);
75+
if (!m)
76+
return NULL;
77+
78+
if (pyawaitable_init_vendor(m) < 0)
79+
{
80+
Py_DECREF(m);
81+
return NULL;
82+
}
83+
84+
return m;
85+
}
86+
```
87+
6188
## Acknowledgements
6289
6390
Special thanks to:

include/vendor.h

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@
1010
* (If you're seeing this message from a vendored copy, you're fine)
1111
*/
1212

13-
#define PYAWAITABLE_ADD_TYPE(m, tp) \
14-
do \
15-
{ \
16-
Py_INCREF(&tp); \
17-
if (PyType_Ready(&tp) < 0) { \
18-
Py_DECREF(&tp); \
19-
return -1; \
20-
} \
21-
if (PyModule_AddObject(m, #tp, (PyObject *)&tp) < 0) { \
22-
Py_DECREF(&tp); \
23-
return -1; \
24-
} \
13+
#define PYAWAITABLE_ADD_TYPE(m, tp) \
14+
do \
15+
{ \
16+
Py_INCREF(&tp); \
17+
if (PyType_Ready(&tp) < 0) { \
18+
Py_DECREF(&tp); \
19+
return -1; \
20+
} \
21+
if (PyModule_AddObject(m, #tp, (PyObject *) &tp) < 0) { \
22+
Py_DECREF(&tp); \
23+
return -1; \
24+
} \
2525
} while (0)
2626

2727
#define PYAWAITABLE_MAJOR_VERSION 1
@@ -42,6 +42,7 @@
4242
#define PyAwaitable_ABI pyawaitable_abi
4343
#define PyAwaitable_Type PyAwaitableType
4444
#define PyAwaitable_AwaitFunction pyawaitable_await_function
45+
#define PyAwaitable_VendorInit pyawaitable_vendor_init
4546
#endif
4647

4748
static int

0 commit comments

Comments
 (0)