aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/pybind/embedding.cpp
diff options
context:
space:
mode:
authorsay <say@yandex-team.com>2023-12-08 17:40:48 +0300
committersay <say@yandex-team.com>2023-12-08 19:58:59 +0300
commit914f57e3243f53dd89dd3adb4d8b6d35c47f46ce (patch)
tree98a1f1f1f5e2c38db3a78da10aeb7eb7d4e952e0 /library/cpp/pybind/embedding.cpp
parente61293d91ee7c923944f627d8e1138bcb17cacad (diff)
downloadydb-914f57e3243f53dd89dd3adb4d8b6d35c47f46ce.tar.gz
Make support_retries() and get_type() methods of object instead of class ones. Reduce get_type_name() usage.
Diffstat (limited to 'library/cpp/pybind/embedding.cpp')
-rw-r--r--library/cpp/pybind/embedding.cpp63
1 files changed, 0 insertions, 63 deletions
diff --git a/library/cpp/pybind/embedding.cpp b/library/cpp/pybind/embedding.cpp
deleted file mode 100644
index cf8941a92af..00000000000
--- a/library/cpp/pybind/embedding.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-#define PY_SSIZE_T_CLEAN
-#include <Python.h>
-
-#include "embedding.h"
-
-#include <util/generic/ptr.h>
-#include <util/generic/yexception.h>
-
-namespace NPyBind {
-#if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 8
- class TDeleteRawMem {
- public:
- template <typename T>
- static inline void Destroy(T* t) noexcept {
- PyMem_RawFree(t);
- }
- };
-
- template <typename T>
- using TRawMemHolder = THolder<T, TDeleteRawMem>;
-
- static void SetProgramName(char* name) {
- TRawMemHolder<wchar_t> wideName(Py_DecodeLocale(name, nullptr));
- Y_ENSURE(wideName);
- Py_SetProgramName(wideName.Get());
- }
-#endif
-
- TEmbedding::TEmbedding(char* argv0) {
-#if PY_MAJOR_VERSION < 3
- Py_SetProgramName(argv0);
- Py_Initialize();
-#elif PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 8
- PyStatus status;
-
- PyConfig config;
- PyConfig_InitPythonConfig(&config);
- // Disable parsing command line arguments
- config.parse_argv = 0;
-
- status = PyConfig_SetBytesString(&config, &config.program_name, argv0);
- if (PyStatus_Exception(status)) {
- PyConfig_Clear(&config);
- Py_ExitStatusException(status);
- }
-
- status = Py_InitializeFromConfig(&config);
- if (PyStatus_Exception(status)) {
- PyConfig_Clear(&config);
- Py_ExitStatusException(status);
- }
-
- PyConfig_Clear(&config);
-#elif PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 8
- SetProgramName(argv0);
- Py_Initialize();
-#endif
- }
-
- TEmbedding::~TEmbedding() {
- Py_Finalize();
- }
-}