aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/pybind/init.h
diff options
context:
space:
mode:
authorsay <say@yandex-team.com>2023-02-14 17:24:43 +0300
committersay <say@yandex-team.com>2023-02-14 17:24:43 +0300
commite0094c4ad6964e11564777bc0d859c68d8aa9de2 (patch)
tree5d2ad1a4df88da1f74385888891a2a5f9fbbc3ef /library/cpp/pybind/init.h
parent65a08c9fdece8dba50da8beb4d7c81447211dd45 (diff)
downloadydb-e0094c4ad6964e11564777bc0d859c68d8aa9de2.tar.gz
Migrate black linter on custom_lint pipeline
Diffstat (limited to 'library/cpp/pybind/init.h')
-rw-r--r--library/cpp/pybind/init.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/library/cpp/pybind/init.h b/library/cpp/pybind/init.h
new file mode 100644
index 00000000000..58874574ed6
--- /dev/null
+++ b/library/cpp/pybind/init.h
@@ -0,0 +1,25 @@
+#pragma once
+
+#define PY_SSIZE_T_CLEAN
+#include <Python.h>
+
+#include "ptr.h"
+
+namespace NPyBind {
+#if PY_MAJOR_VERSION >= 3
+
+#define PYBIND_MODINIT(name) PyMODINIT_FUNC PyInit_##name()
+
+ inline PyObject* ModInitReturn(TPyObjectPtr&& modptr) {
+ return modptr.Release();
+ }
+
+#else
+
+#define PYBIND_MODINIT(name) PyMODINIT_FUNC init##name()
+
+ inline void ModInitReturn(TPyObjectPtr&&) {
+ }
+
+#endif
+}