diff options
author | robot-piglet <robot-piglet@yandex-team.com> | 2023-10-03 15:02:38 +0300 |
---|---|---|
committer | robot-piglet <robot-piglet@yandex-team.com> | 2023-10-03 16:04:35 +0300 |
commit | 5478b8f55cc7055a4861c4030e0c401b5c72714c (patch) | |
tree | 3d003e5b4c1800297fcc491faffc9a006d174289 /library/cpp/pybind/embedding.cpp | |
parent | ca778ad9bfb31839b0f05a4995753bc61db648ad (diff) | |
download | ydb-5478b8f55cc7055a4861c4030e0c401b5c72714c.tar.gz |
Intermediate changes
Diffstat (limited to 'library/cpp/pybind/embedding.cpp')
-rw-r--r-- | library/cpp/pybind/embedding.cpp | 63 |
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(); - } -} |